Add content on top of existing pdf-page

1 Answer 184 Views
PdfProcessing WordsProcessing
Kees
Top achievements
Rank 2
Iron
Iron
Kees asked on 23 May 2022, 02:17 PM

Hi,

In one of my projects, I add a kind of 'stamp' to an existing pdf page by rendering an HTML page on top of the page. I do this with a third-party library other than Telerik.

To reduce the number of different licenses needed I try to accomplish this with the Telerik DPL but I can't figure out if this is possible, and if yes, then how?

Can I add a document page (ie imported from a htmlpage) on top of a page in an existing pdf (the original page should still be visible)

If it is possible then a small sample will be really helpful.

Thanks in advance!

Kees Alderliesten

1 Answer, 1 is accepted

Sort by
0
Tanya
Telerik team
answered on 25 May 2022, 11:38 AM

Hello Kees,

You can implement this requirement using the WordsProcessing library to convert the HTML to PDF and then PdfProcessing to merge the content. Following are the steps you will need to perform:

  1. Import the HTML using HtmlFormatProvider
  2. Export the RadFlowDocument to a PDF preserving the data into a stream
  3. Merge the pages of the two PDF documents using the API PdfStreamWriter. We have a good KB article demonstrating that: Merge two document pages into a new single page.

Hope this information is helpful.

Regards,
Tanya
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Kees
Top achievements
Rank 2
Iron
Iron
commented on 30 May 2022, 10:50 AM

Hi Tanya,

Thank you, I got it working!

The sample in step 3 places the documents side-by-side, but changing the Size and offsetX fixed that.

This kind of sample should be included in the docs, not in a knowledge base. The one-line 'samples' in the docs are way too short to figure out this kind of tricks.

Thanks again,
kind regards,
Kees Alderliesten

Tanya
Telerik team
commented on 01 Jun 2022, 01:15 PM

Hi Kees,

I am glad to hear that you managed to achieve the requirement. We will consider adding this information to the documentation pages. Thank you for sharing your feedback.

Tags
PdfProcessing WordsProcessing
Asked by
Kees
Top achievements
Rank 2
Iron
Iron
Answers by
Tanya
Telerik team
Share this question
or