PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sun Oct 22, 2017 4:47 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Wed May 31, 2017 3:24 pm 
Offline

Joined: Wed May 31, 2017 3:21 pm
Posts: 3
Hello. I was wondering if this is possible with PDFSharp and MigraDoc, with the help of HtmlRenderer for PDFSharp:

I want to generate a PDF using a .NET solution that is pieced together from URLs for each part of the content, such as:

Creating repeating headers from a link (url) as the source
Creating repeating footers from a link (url) as the source
Creating the inner content from a link (url) as the source
Be able to replace tokens in appropriate places (e.g. {page_num})

So every bit of the content will derive from HTML, and then replace certain areas {token} with page numbers and other data. Think of an invoice with line items, but being able to completely design the entire thing from HTML snippets. I would also like to avoid converting the HTML to an image and inserting the image as the header. I need it to obey stylesheets upon PDF generation. I need to iterate over the pages after generation and replace tokens for page number, etc.

Any pointers or advice would greatly be appreciated. Thank you so much.


Top
 Profile  
Reply with quote  
PostPosted: Wed May 31, 2017 3:58 pm 
Offline
empira Employee
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 2720
Location: Cologne, Germany
Hi!

The HTML Renderer is not an empira product and I do not have any experience with it.

We use MigraDoc to create documents from code. This gives us flexibility far beyond the scope of HTML templates - we have tables with optional columns (we skip columns that would be empty anyway) and often we have a "presentation mode" (what the end-user will see) and a "control mode" (with extra information for editors).
MigraDoc handles page breaks, adds page numbers automatically and supports headers and footers.


As I understand it the HTML Renderer uses PDFsharp, not MigraDoc. Placeholders in HTML just require a call to "string.Replace()", so that will be somewhat easy. I cannot give you any hints about headers, footers, page numbers or other details.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Wed May 31, 2017 4:06 pm 
Offline

Joined: Wed May 31, 2017 3:21 pm
Posts: 3
Thank you for your reply. HtmlRenderer (https://github.com/ArthurHub/HTML-Renderer) does the job of converting URLs to PDFs and works with PDFSharp. In my case, I need the end user to be able to generate an HTML page which is dynamic, changes depending on several factors, or if they simply want to change the design of it, for these different components (Header, Footer, etc.) on the spot. I suppose a more narrowed down question to pull out a part of this would be, can MigraDoc create a header from HTML? Or, can an existing HTML converted to PDF be inserted as the header? I know you said you can't give hints on headers, not sure if you mean code or just answers, but I wanted to reply for all to see where I'm going with this.

I greatly appreciate your help and response.


Top
 Profile  
Reply with quote  
PostPosted: Wed May 31, 2017 4:50 pm 
Offline

Joined: Wed May 31, 2017 3:21 pm
Posts: 3
If I need to, I think I can talk the client into letting us design the header and footer in code, and use the PDF generating from an HTML page for the content. Can it handle this? Inserting an existing PDF that can span multiple pages within a header and footer model created with MigraDoc? Thank you again.


Top
 Profile  
Reply with quote  
PostPosted: Thu Jun 01, 2017 8:16 am 
Offline
empira Employee
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 2720
Location: Cologne, Germany
ModGen wrote:
I know you said you can't give hints on headers, not sure if you mean code or just answers, but I wanted to reply for all to see where I'm going with this.
There are no automatic headers and footers with PDFsharp.
I don't know if the HTML Renderer supports headers and footers.
MigraDoc supports headers and footers (and I can help with that), but it cannot import HTML.

MigraDoc uses PDFsharp to create PDF files, but the APIs are completely different.
See also:
http://www.pdfsharp.net/Overview.ashx


It might be possible to create the page bodies with HTML Renderer and add headers and footers from code, maybe in a second step. To get this going, HTML Renderer must give you top and bottom margins that allow you to add headers and footers.
And you could even use MigraDoc for the headers and footers by creating a MigraDoc document that only has page breaks in the body of the document.

_________________
Regards
Thomas Hoevel
PDFsharp Team


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

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 3 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