PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Tue May 23, 2017 3:12 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Tue Apr 25, 2017 2:10 pm 
Offline

Joined: Tue Apr 25, 2017 1:55 pm
Posts: 2
Hi!
I am usingPDFsharp-MigraDoc-GDI.

How can I add a header and a footer on each page?

I am generating my pdf with PdfSharp like:

PdfDocument pdfDocument = PdfGenerator.GeneratePdf(html, PageSize.A4);

Then I use it to attach to an email:

byte[] fileContents = null;
using (MemoryStream stream = new MemoryStream())
{
pdfDocument.Save(stream, false);
fileContents = stream.ToArray();
// Send mail
stream.Dispose();
}

As I understand it, I can only add headers with MigraDoc?
But if I generate, using MigraDoc, I can't save to stream...


Much grateful for guidance.. :)


Top
 Profile  
Reply with quote  
PostPosted: Tue Apr 25, 2017 3:25 pm 
Offline
empira Employee
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 2640
Location: Cologne, Germany
Hi!
matkarl wrote:
But if I generate, using MigraDoc, I can't save to stream...
Why not? MigraDoc uses PdfDocument to create the PDF and you can save to a Stream as you show in your code snippet.
Just use the PdfDocument property of the PdfDocumentRenderer class.

matkarl wrote:
I am generating my pdf with PdfSharp like:
PdfDocument pdfDocument = PdfGenerator.GeneratePdf(html, PageSize.A4);
PdfGenerator is not part of PDFsharp. I never used that 3ed party tool and cannot help with its usage.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Tue May 02, 2017 7:49 am 
Offline

Joined: Tue Apr 25, 2017 1:55 pm
Posts: 2
Thank you for the reply, Thomas!

But I still do not know how to achieve what I want to...

How do I pass the HTML that I want to be rendered in the PDF?

Like I previously did with
Code:
PdfGenerator.GeneratePdf(html, PageSize.A4);


And how do I add headers and footers to the pages?
PdfDocument has no
Code:
AddSection()
method...

Some explaining lines of code would be appreciated! :D


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group