Insert image underneath multiple section reports

Posted by: michael.mayfield on 12 May 2022, 11:27 am EST

  • Posted 12 May 2022, 11:27 am EST

    I need to add an image to the last page of a report queue.

    The image would span mutliple subreports. So, an image control sent to back will not work.

    Is there a way to draw an image underneath the text on the last page of the report?

    The code below renders the last page empty when exporting to a PDF.

    I suspect the image was off the page but, the content of the last page is no longer present.

    ```
    

    void InsertSignatureImageOnLastPage()

    {

    Image image = Image.FromFile(@“C:\Users\xxxxx\Pictures\Signature.jpg”);

    		foreach (var report in this)
    		{
        var page = report.SectionReport.Document.Pages[report.SectionReport.Document.Pages.Count - 1];
        
        page.DrawImage(image, page.Width - 125F, page.Height - 75F, 125f, 75F);
    		}
    	}
    
  • Posted 13 May 2022, 5:52 am EST

    Hi Michael,

    >> I suspect the image was off the page but, the content of the last page is no longer present.

    Assuming you are printing the report in default PaperKind(Letter) settings. The image size you have mentioned is too large.

    For PaperKind = Letter page.Width is 8.27(inches) page.Height is 11.69(inches) using values 125,75 as size would stretch the image beyond the page.

    Also, the Page.DrawImage method draws on top of the rendered document therefore this will not fulfill your requirement of the image being underneath the text.

    I would suggest you to use the report.Watermark property to print an image underneath the text on your report.

    Also set the report.WatermarkPrintOnPages property as the last page number of report. The WatermarkPrintOnPages property takes comma-separated string of page numbers(e.g. “1,2,…,n”) as input. So to set the value as the last page number you would have create another instance of the report and Run the report to get the report.Document.Pages.Count.ToString() value that you can then set as the Last page number.

    For reference, I have attached a sample along with.

    BackgroundImageSectionReport.zip

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels