This is a migrated thread and some comments may be shown as answers.

Using a Template PDF to create a new pdf

1 Answer 591 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Niraja asked on 22 Nov 2019, 05:03 AM

I have a Template pdf (With company logo as letter head). I want to use this pdf as the first page when I'm creating my pdf. 

Here's my sample code. It creates the letter head in the first page and the rest of the content in a new page.


PdfFormatProvider provider = new PdfFormatProvider();
RadFixedDocument document = provider.Import(File.ReadAllBytes(InputFileName));

            using (RadFixedDocumentEditor editor = new RadFixedDocumentEditor(document))

                editor.ParagraphProperties.SpacingBefore = 10;
                editor.ParagraphProperties.HorizontalAlignment = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.HorizontalAlignment.Center;
                editor.CharacterProperties.FontSize = 40;
                editor.CharacterProperties.Font = boldItalicFont;
                editor.InsertRun("Summary of Proxy Votes");


1 Answer, 1 is accepted

Sort by
Telerik team
answered on 22 Nov 2019, 11:30 AM

Hi Niraja,

In this case, you should use the FixedContentEditor instead of the RadFixedDocumentEditor. The FixedContentEditor allows you to edit the existing page and insert the text. With this approach, you need to specify the initial position (bellow the logo). Here is an example of this: 

RadFixedDocument document = provider.Import(File.ReadAllBytes(@"D:\template.pdf"));

SimplePosition simplePosition = new SimplePosition();
simplePosition.Translate(20, 100);

FixedContentEditor contentEditor = new FixedContentEditor(document.Pages[0], simplePosition);
contentEditor.DrawText("Summary of Proxy Votes");

If you want to use the RadFixedDocumentEditor (which I believe is a better approach because you do not need to set the position), you will need to save the logo as an image and insert it to the new document instead of importing the entire document. This way the editor will be able to measure the logo and position it on the page. 

I hope this helps. Please let me know if you have additional questions.

Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question