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

Use a PDF as a template for a MigraDoc?
https://forum.pdfsharp.net/viewtopic.php?f=2&t=938
Page 1 of 1

Author:  Pete [ Thu Nov 12, 2009 11:54 am ]
Post subject:  Use a PDF as a template for a MigraDoc?

Hi,

I already have code outputting a document almost exactly as I require.
I know how to read in a pdf document and write over it using a PdfDocument but I would have to re-write everything.

Is it possible to use the same code but add the pdf template at the start?

I guess it would be like using MigraDoc.Rendering.DocumentRenderer.RenderPage but render the whole MigraDoc.DocumentObjectModel.Document instead of a Page.

Author:  Thomas Hoevel [ Thu Nov 12, 2009 1:17 pm ]
Post subject:  Re: Use a PDF as a template for a MigraDoc?

Hi!

What do you mean with template?

We mix PDF pages (containing the Corporate Design) with content generated by MigraDoc to create the final PDF document.

Author:  Pete [ Thu Nov 12, 2009 1:20 pm ]
Post subject:  Re: Use a PDF as a template for a MigraDoc?

Yep that's what I mean!

I already have it outputting to pdf and rtf but would like to mix the pdf output with a corporate letterhead/design like you mention but without having to re-write too much.

Author:  Thomas Hoevel [ Thu Nov 12, 2009 2:55 pm ]
Post subject:  Re: Use a PDF as a template for a MigraDoc?

That's what we do - no problem.

The MigraDoc document must know where it may write (not to overwrite the letterhead).

In the most simple case you have a big letterhead for the first page and small letterhead for following pages.
Then you can create the document with MigraDoc - and finally run a routine that works like the Watermark sample and adds the letterheads.

Or is your case more complex?

Author:  Pete [ Thu Nov 12, 2009 2:58 pm ]
Post subject:  Re: Use a PDF as a template for a MigraDoc?

My case isn't complex at all, I'm just new to MigraDoc and PDFSharp and don't know how to do it in code.

I can see how to open a PDF Doc and do the above paragraph by paragraph thanks to the samples section, but that would require re-doing a lot of work and is also quite cumbersome compared to the MigraDoc code so would like a way to push that straight in.

Author:  Pete [ Mon Nov 16, 2009 2:20 pm ]
Post subject:  Re: Use a PDF as a template for a MigraDoc?

Can anyone point me at an example of doing this with MigraDoc please?

Author:  RandyHJ57 [ Tue May 09, 2017 1:02 pm ]
Post subject:  Re: Use a PDF as a template for a MigraDoc?

Thomas Hoevel wrote:
That's what we do - no problem.

The MigraDoc document must know where it may write (not to overwrite the letterhead).

In the most simple case you have a big letterhead for the first page and small letterhead for following pages.
Then you can create the document with MigraDoc - and finally run a routine that works like the Watermark sample and adds the letterheads.

Or is your case more complex?


I'm glad to hear this is possible. I am brand new to PDFSharp and MigraDoc. I understand that you don't want to write peoples' code for them (that is what Professional Support is for and you have to make a living), but it would be nice to at least have an algorithm on the steps to follow to write this myself (and learn the products along the way).

I have a sample document that I need recreate programmatically. It has a .png image that serves as a letterhead and a rectangle with text inside that is placed on the right side of the page near the top. I assuming that I would use PDFSharp to place the image and to draw the rectangle with the text inside.

Below these I have the body of the document (almost like a mail merge template) that I assume I would use MigraDoc to create.

What I lack is an algorithm of the steps to go through to recreate this document as a PDF. Do I need to sign up for professional support and pay the license fee to get this kind of information? I am working for a government agency and need to create these "letters" as PDF files for multiple users.

Thank you,

RandyHJ57

Author:  Thomas Hoevel [ Tue May 09, 2017 2:09 pm ]
Post subject:  Re: Use a PDF as a template for a MigraDoc?

Hi!
RandyHJ57 wrote:
[...] but it would be nice to at least have an algorithm on the steps to follow to write this myself (and learn the products along the way).
The are many ways.
We use PDF files for background and content - we create booklets, not letters.

If you can get the fixed part ("letterhead") as a PDF file, just use that as the background.
Or use PDFsharp to create an XForm and use that as the background on any page:
http://www.pdfsharp.net/wiki/XForms-sample.ashx

There are many different requirements and many different solutions - there isn't a single algorithm that suits all.

Author:  RandyHJ57 [ Tue May 09, 2017 3:36 pm ]
Post subject:  Re: Use a PDF as a template for a MigraDoc?

Thomas Hoevel wrote:
Hi!
RandyHJ57 wrote:
[...] but it would be nice to at least have an algorithm on the steps to follow to write this myself (and learn the products along the way).
The are many ways.
We use PDF files for background and content - we create booklets, not letters.

If you can get the fixed part ("letterhead") as a PDF file, just use that as the background.
Or use PDFsharp to create an XForm and use that as the background on any page:
http://www.pdfsharp.net/wiki/XForms-sample.ashx

There are many different requirements and many different solutions - there isn't a single algorithm that suits all.


Thank you so much for answering my post and responding to such an old thread.

One more question -

If I need to place text in a bordered box in a specific position on the page, should I use PDFSharp, or will MigraDoc do the same job for me?

Author:  RandyHJ57 [ Wed May 10, 2017 12:15 pm ]
Post subject:  Re: Use a PDF as a template for a MigraDoc?

RandyHJ57 wrote:
Thomas Hoevel wrote:
Hi!
RandyHJ57 wrote:
[...] but it would be nice to at least have an algorithm on the steps to follow to write this myself (and learn the products along the way).
The are many ways.
We use PDF files for background and content - we create booklets, not letters.

If you can get the fixed part ("letterhead") as a PDF file, just use that as the background.
Or use PDFsharp to create an XForm and use that as the background on any page:
http://www.pdfsharp.net/wiki/XForms-sample.ashx

There are many different requirements and many different solutions - there isn't a single algorithm that suits all.


Thank you so much for answering my post and responding to such an old thread.

One more question -

If I need to place text in a bordered box in a specific position on the page, should I use PDFSharp, or will MigraDoc do the same job for me?


I have successfully placed my logo in the proper position at the proper size and also formatted my page height, width and margins.

I was wondering about sections. Are sections just logical containers with no spatial characteristics except what is set in formatting? Putting it another way, can sections be placed beside each other or at any position on the page, or am I missing it altogether?

Thanks,

Randy

Author:  Thomas Hoevel [ Thu May 11, 2017 2:16 pm ]
Post subject:  Re: Use a PDF as a template for a MigraDoc?

RandyHJ57 wrote:
I was wondering about sections. Are sections just logical containers with no spatial characteristics except what is set in formatting? Putting it another way, can sections be placed beside each other or at any position on the page, or am I missing it altogether?
Every section starts on a new page, so you cannot have two sections on one page.
Page size and page numbers are bound to sections.
I don't know which problem you want to solve with multiple sections on one page, so I cannot suggest a different solution.

Author:  RandyHJ57 [ Mon May 15, 2017 4:50 pm ]
Post subject:  Re: Use a PDF as a template for a MigraDoc?

Thomas Hoevel wrote:
RandyHJ57 wrote:
I was wondering about sections. Are sections just logical containers with no spatial characteristics except what is set in formatting? Putting it another way, can sections be placed beside each other or at any position on the page, or am I missing it altogether?
Every section starts on a new page, so you cannot have two sections on one page.
Page size and page numbers are bound to sections.
I don't know which problem you want to solve with multiple sections on one page, so I cannot suggest a different solution.


I was just asking a question about the nature of sections, which you answered. Thank you.

What I am attempting to do is write text inside a rectangle with borders and place it in an exact position on the page (right side of page next to a TextFrame.

So on the left, you have a TextFrame with a person's name, address, city and state. On the right, you have a rectangle with borders and inside the rectangle you have text that wraps inside the rectangle.

I am thinking I should be using PDFSharp to draw the rectangle with the text inside and using MigraDoc for the rest of my document (letterhead, TextFrame, body of document, and footer). Does this sound right?

I tried creating an XForm object but couldn't get everything to behave the way I wanted it to.

Any suggestions?

Thanks,

Randy

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