|
| 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 | + |
| 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 | + |
| 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 | +  |
| 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 | + |
| 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 | +  |
| 47 | + |
| 48 | +2. Drop the [](TODO) control from the **Toolbox** onto the *Detail* [band](TODO). |
| 49 | + |
| 50 | +  |
| 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 | +  |
| 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 | +  |
| 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 | +  |
| 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 | +  |
| 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 | +  |
| 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 | +  |
| 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 | +  |
| 115 | + |
| 116 | +Open **Preview** to show the result. The image below shows the report's first page: |
| 117 | + |
| 118 | + |
| 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 | +  |
| 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 | +  |
| 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 | +  |
| 133 | + |
| 134 | +Open **Preview** to show the result. |
| 135 | + |
| 136 | + |
| 137 | + |
| 138 | + |
0 commit comments