Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Thu Apr 25, 2019 8:11 pm

Is it possible to design a header in Microsoft Word, save that as a PDF then use that PDF and insert it at as a header in another document? I tried designing the header in Word then saving it as an image but the image has loss when inserted as a header.

I can manually create a header by coding each line with the Canvas.DrawString but that is very manual, very trial and error.

Just looking for a better way to design and include headers in other PDF documents.

Any ideas appreciated! Thanks!

damadake
 
Posts: 20
Joined: Wed Jan 18, 2017 12:56 pm

Fri Apr 26, 2019 6:19 am

Hello,

Thanks for your inquiry.
Please refer to the following sample code to insert the saved header PDF document into another PDF document. If there is any question, please provide the header PDF document which you saved in Microsoft Word, your "another document" as well as your desired output, then we will further look into it and guide you accordingly. You could send them to us via email([email protected]).
Code: Select all
  //load the target PDF file
  PdfDocument targetPdf = new PdfDocument();
  targetPdf.LoadFromFile(@"target.pdf");
  //load the header PDF file
  PdfDocument headerPdf = new PdfDocument();
  headerPdf.LoadFromFile(@"Header.pdf");
  //Create template
  PdfTemplate template = headerPdf.Pages[0].CreateTemplate();

  foreach (PdfPageBase page in targetPdf.Pages)
  {
      //set overlay mode
      page.Canvas.SetTransparency(1f, 1f, PdfBlendMode.Overlay);
      template.Graphics.SetTransparency(0.1f, 0.1f, PdfBlendMode.Overlay);
      page.Canvas.DrawTemplate(template, new PointF(0, 0));
  }
  //save file
  targetPdf.SaveToFile("result.pdf");

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1536
Joined: Wed Apr 25, 2018 3:20 am

Fri Apr 26, 2019 1:46 pm

That works very nicely, thank you!
:D

damadake
 
Posts: 20
Joined: Wed Jan 18, 2017 12:56 pm

Mon Apr 29, 2019 1:14 am

Hello,

Glad to hear that! Just feel free to contact us if you need assistance in the future.
Wish you all the best!

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1536
Joined: Wed Apr 25, 2018 3:20 am

Return to Spire.PDF