Skip to content

Commit 45ae06f

Browse files
author
epolevikov
committed
Upd
1 parent 6691468 commit 45ae06f

21 files changed

+150
-181
lines changed
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
---
2+
title: Reports with Embedded PDF Content
3+
author: Eugene Polevikov
4+
---
5+
6+
# Reports with Embedded PDF Content
7+
8+
This tutorial explains how to use the [PdfContent](TODO) control to do the following:
9+
10+
* Append PDF file pages to a report and make their paper kind the same as in the inital report.
11+
* Add sequential page numbers to the report and PDF file pages.
12+
* Include additional information in the embedded PDF file pages.
13+
14+
The image below shows an invoice report that contains information about order items.
15+
16+
![Final Report Page 1](../../../../images/create-report-with-pdf-content-final-report-page1.png)
17+
18+
The following image illustrates the first PDF file page embedded to the invoice report. This page has the same paper kind as the initial report. [Report controls](TODO) are used to add item title, item price, line, logo image, and sequential page numbers to this page.
19+
20+
![Final Report Page 2](../../../../images/create-report-with-pdf-content-final-report-page2.png)
21+
22+
To create the above report with PDF content, follow the steps described in these sections:
23+
24+
* [Create the Main Report](#create-the-main-report)
25+
* [Create a Report with PDF Content](#create-a-report-with-pdf-content)
26+
* [Add the Report with PDF content to the Main Report](#add-the-report-with-pdf-content-to-the-main-report)
27+
28+
## Create the Main Report
29+
30+
1. Create a new Visual Studio project and add a new blank report to it. Refer to the following topic for instructions: [](TODO).
31+
2. Design the report layout. In this tutorial, we create an invoice report that contains information about order items.
32+
![Main Report Layout](../../../../images/pdfcontent-embedded-mode-main-report-layout.png)
33+
34+
To supply the report with data, use the following JSON string:
35+
36+
[!include[](../../../../templates/xrpdfcontent-embedded-mode-json-data.md)]
37+
38+
The following image illustrates the main report's **Preview**:
39+
40+
![Main Report Preview](../../../../images/pdfcontent-embedded-mode-main-report-preview.png)
41+
42+
## Create a Report with PDF Content
43+
44+
1. [Add](TODO) a new blank report to your project. Remove the report's margins.
45+
46+
![Add a New Blank Report and Remove Margins](../../../../images/create-report-with-pdf-content-add-new-blank-report-and-remove-margins.png)
47+
48+
2. Drop the [](TODO) control from the **Toolbox** onto the *Detail* [band](TODO).
49+
50+
![Drop the XRPdfContent Control Onto the Detail Band](../../../../images/create-report-with-pdf-content-drop-xrpdfcontent-control-onto-detail-band.png)
51+
52+
3. Expand the control's smart tag, click the [Source](TODO) or [SourceURL](TODO) property's ellipsis button, and select PDF file. In this demo, we use the following PDF specification: [Specification.pdf](https://github.com/DevExpress-Examples/DataSources/blob/master/Specification.pdf).
53+
54+
![Specify PDF File Source](../../../../images/create-report-with-pdf-content-specify-pdf-file-source.png)
55+
56+
57+
4. Disable the control's [Generate Own Pages](xref:DevExpress.XtraReports.UI.XRPdfContent.GenerateOwnPages) property. Adjust the control size to make PDF content fit the entire *Detail* band. For this, set the *Detail* band's [Height](xref:DevExpress.XtraReports.UI.XRControl.HeightF) to *1095* and the control's [Width](xref:DevExpress.XtraReports.UI.XRControl.WidthF) and [Height](xref:DevExpress.XtraReports.UI.XRControl.HeightF) to *850* and *1095*.
58+
59+
![Make PDF Content Fit the Entire Detail Band](../../../../images/create-report-with-pdf-content-make-pdf-content-fit-entire-detail-band.png)
60+
61+
5. Disable the report's [DesignerOptions.ShowExportWarnings](xref:DevExpress.XtraReports.UI.DesignerOptions.ShowExportWarnings) property. [Bind](xref:400379) the report to the following JSON data:
62+
63+
[!include[](../../../../templates/xrpdfcontent-embedded-mode-json-data.md)]
64+
65+
6. Place two [labels](xref:DevExpress.XtraReports.UI.XRLabel), a [line](xref:DevExpress.XtraReports.UI.XRLine), and a [picture box](xref:DevExpress.XtraReports.UI.XRPictureBox) on the PDF page header as shown below:
66+
67+
![Add Controls to Page Header](../../../../images/create-report-with-pdf-content-make-pdf-content-add-controls-to-page-header.png)
68+
69+
Use the following locations and sizes:
70+
71+
{|
72+
|-
73+
! Control Name !! Location !! Size
74+
|-
75+
| xrLabel1 || 105, 94 || 280, 44
76+
|-
77+
| xrLabel2 || 105, 138 || 118, 30
78+
|-
79+
| xrLine1 || 105, 69 || 687, 20
80+
|-
81+
| xrPictureBox1 || 647, 24 || 145, 45
82+
|}
83+
84+
7. Set the line's [Width](xref:DevExpress.XtraReports.UI.XRLine.LineWidth) and [Fore Color](xref:DevExpress.XtraReports.UI.XRControl.ForeColor) to *2* and *Orange* respectively. Assign the following image to the picture box's [Image Source](xref:DevExpress.XtraReports.UI.XRPictureBox.ImageSource) property:
85+
86+
![DevAV Icon](../../../../images/devav.png)
87+
88+
Make xrLabel1's font bold. Set up label appearance as shown in the table below:
89+
90+
{|
91+
|-
92+
! Control Name !! Font !! Font Size !! Text Property's Expression
93+
|-
94+
| xrLabel1 || Segoe UI || 21 || *ProductName*
95+
|-
96+
| xrLabel2 || Segoe UI || 12 || *ProductPrice*
97+
|}
98+
99+
![Bind Labels to Data](../../../../images/create-report-with-pdf-content-make-pdf-content-bind-labels-to-data.png)
100+
101+
To display a product name and price of each order item on a corresponding PDF file page, set the [XRPdfContent.PageRange](xref:DevExpress.XtraReports.UI.XRPdfContent.PageRange) property's [expression](xref:403357) to *[DataSource.CurrentRowIndex] + 1*.
102+
103+
![Assign Expression to the Page Range Property](../../../../images/create-report-with-pdf-content-assign-expression-to-page-range.png)
104+
105+
8. Add the [XRPageInfo](xref:DevExpress.XtraReports.UI.XRPageInfo) control to the PDF page footer. Use the following settings for this control:
106+
107+
{|
108+
|-
109+
! Location !! Size !! Font !! Font Size !! Text Alignment !! Text Format String
110+
|-
111+
| 0, 1045 || 850, 50 || Segoe UI || 12 || Middle Center || Page {0} of {1}
112+
|}
113+
114+
![Add Page Numbers](../../../../images/create-report-with-pdf-content-add-page-numbers.png)
115+
116+
Open **Preview** to show the result. The image below shows the report's first page:
117+
118+
![Final Report Preview](../../../../images/create-report-with-pdf-content-preview.png)
119+
120+
## Add the Report with PDF Content to the Main Report
121+
122+
1. Add a [footer](xref:DevExpress.XtraReports.UI.ReportFooterBand) to the main report. Right-click the design surface, choose **Insert Band**, and select **ReportFooter**.
123+
124+
![Add Report Footer](../../../../images/create-report-with-pdf-content-add-report-footer.png)
125+
126+
2. Add the [](xref:DevExpress.XtraReports.UI.XRSubreport) control to the footer. Assign the report with PDF content to the control's [Report Source](xref:DevExpress.XtraReports.UI.SubreportBase.ReportSource) property. Enable the control's [Generate Own Pages](xref:DevExpress.XtraReports.UI.SubreportBase.GenerateOwnPages) property.
127+
128+
![Add the Subreport](../../../../images/create-report-with-pdf-content-add-subreport.png)
129+
130+
3. Add the [XRPageInfo](xref:DevExpress.XtraReports.UI.XRPageInfo) control to the report's [Bottom Margin](xref:DevExpress.XtraReports.UI.BottomMarginBand) band. Set the control's [Text Alignment](xref:DevExpress.XtraReports.UI.XRControl.TextAlignment) to *Middle Center* and [Text Format String](xref:DevExpress.XtraReports.UI.XRPageInfo.TextFormatString) to *Page {0} of {1}*.
131+
132+
![Add Page Numbers to Main Report](../../../../images/create-report-with-pdf-content-add-page-number-to-main-report.png)
133+
134+
Open **Preview** to show the result.
135+
136+
![Final Report Page 1](../../../../images/create-report-with-pdf-content-final-report-page1.png)
137+
138+
![Final Report Page 2](../../../../images/create-report-with-pdf-content-final-report-page2.png)

0 commit comments

Comments
 (0)