PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Migradoc use existing pdf as template
https://forum.pdfsharp.net/viewtopic.php?f=2&t=2408
Page 1 of 1

Author:  CaptainGerrard8 [ Fri Apr 12, 2013 1:34 pm ]
Post subject:  Migradoc use existing pdf as template

Hi,

i have created my pdf document, now i have to add a template (it's a pdf document with logo, footer ...) and write the content into the template.

it's absolute necessary to load my template (because i have to use it for a large number of projects), so i cannot write the logo in every pdf for every project.

Is there a possibility?

Author:  Thomas Hoevel [ Mon Apr 15, 2013 8:01 am ]
Post subject:  Re: Migradoc use existing pdf as template

Hi!

You can use pages from PDF files as background and have MigraDoc draw the text in front of it.
You can do it the "MigraDoc" way (e.g. by adding the background page to the page header) or the "Mix MigraDoc and PDFsharp" way (see the sample with the same name) by modifying pages with PDFsharp after MigraDoc created them.

Depends on how many different backgrounds you have and where to apply which background.
If there is only a first page (large logo) and a follow-up page (small logo), the "MigraDoc" way will probably be appropriate.

Sample:
http://www.pdfsharp.net/wiki/MixMigraDo ... ample.ashx
(Note that the sample draws several MigraDoc pages on one PDFsharp page - you would do it 1:1, but with added background)

Author:  CaptainGerrard8 [ Wed Apr 17, 2013 9:00 am ]
Post subject:  Re: Migradoc use existing pdf as template

Hi,

thanks for your reply.

But, there is no way to add a source PDF (with all my logos and texts)?
This would be a big big help, because i can't add in every project every logos.

Greetings

Author:  Thomas Hoevel [ Wed Apr 17, 2013 9:11 am ]
Post subject:  Re: Migradoc use existing pdf as template

CaptainGerrard8 wrote:
But, there is no way to add a source PDF (with all my logos and texts)?
I don't understand what you want.

You can use a source PDF with anything it contains - and use MigraDoc to add text, images, etc.

You always create a new PDF, but you can import pages from the source PDF and add MigraDoc content to it.

Author:  CaptainGerrard8 [ Wed Apr 17, 2013 1:23 pm ]
Post subject:  Re: Migradoc use existing pdf as template

sorry, my fault.

in my case, in every page there is the same header and the same footer.

so the "migradoc way" is engough.

But how can i add the background to the page header?

Author:  Thomas Hoevel [ Wed Apr 17, 2013 1:51 pm ]
Post subject:  Re: Migradoc use existing pdf as template

I think the code shown here is a good starter:
viewtopic.php?p=4370#p4370

Change this:
Code:
myImage.RelativeVertical = RelativeVertical.Page;
myImage.RelativeHorizontal = RelativeHorizontal.Page;


Set Width and Height of the image to match the page size.
And don't use "document.DefaultPageSetup.DifferentFirstPageHeaderFooter = true;"

Author:  CaptainGerrard8 [ Wed Apr 17, 2013 2:23 pm ]
Post subject:  Re: Migradoc use existing pdf as template

/edit

my mistake, sorry! it works perfect!

i think you have developed a very good software, but it would be pleasant if you create a api for users.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/