Welcome Guest Search | Active Topics | Sign In | Register

Error merging PDFs with identical field names and Error overlaying content from ConvertUrl into a templated pdf Options
Sit3coreD3v
Posted: Monday, June 29, 2015 12:45:34 AM
Rank: Newbie
Groups: Member

Joined: 6/29/2015
Posts: 9
I'm having 2 issues which haven't been a problem with other PDF components so maybe im just missing something in the documentation.
I am using the latest version of the component,

1. Error merging PDFs with identical field name
I run a loop over a list i have to generate some PDF's that require a form field to be filled in.
Invidually each PDF is generated correctly, it;s a simple page with 1 field.

When i merge these individual PDFS into 1 document only the fist instance of the pdf has the correct filed value filled in, the rest of the pages which have been derived usign the same code have this field empty.

I have tried saving each individual pDF to ensure the form field is correct filled in and it is. So issue only happens on merge and i think its due to the field name being identical.

2. I have a PDF template and would simply like to use ConvertUrl to render the contents on the Url onto a new PDF using the given template.
The ConvertUrl created a multi page PDF so would simply like a template to be applied to each of these pages. I havent found way to do this with this component.


Any advice appreciated
eo_support
Posted: Monday, June 29, 2015 12:38:21 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,229
Hi,

Thanks for posting in the forum. As to your questions:

1. Fields with identical names. No, you can not merge PDF with the identical field names and still keep all the fields functional. What you observed is indeed the result behavior: only one of them will be functional. Currently there is no way to avoid this;

2. You can call ConvertHtml (not ConvertUrl) to render HTML over an existing PDF template with limited HTML features. The following code demonstrates how to do this:

Code: C#
PdfDocument doc = new PdfDocument(your_template_file);
HtmlToPdf.ConvertHtml("<div style='position:absolute;top:100px;left:100px;'>test</div>", doc.Pages[0]);


Note that:

1. You can only render output page by page. The second argument of ConvertHtml must be a PdfPage object;
2. Some HTML features may not work correctly. Specifically, certain features that requires mixing with "background" (for example, a half transparent shadow) will trigger a solid white background to be added thus causing the output of ConvertHtml to completely obscure existing contents in your PDF file;
3. If your HTML needs external resources such as images, CSS or JavaScript, you may need to set HtmlToPdf.Options.BaseUrl correctly. At runtime BaseUrl is used to expand partial Url in your HTML into full HTML.

Hope this helps. Please feel free to let us know if you still have any more questions.

Thanks!
Sit3coreD3v
Posted: Monday, June 29, 2015 4:51:09 PM
Rank: Newbie
Groups: Member

Joined: 6/29/2015
Posts: 9
Thanks for your prompt response.

With respect to item 2, I have a url i want to convert, i could extract the HTML i guess but that still leaves the problem of manually having to add the content to each page or is there an easier way? I just cant see an easy way to say render a URL that goes over 32 pages (using convertUrl) if it has to be done page by page because id have to work out where each page starts and each page ends?

eo_support
Posted: Monday, June 29, 2015 5:08:59 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,229
Hi,

You can try use ConvertHtml with a PdfDocument as the second argument and set HtmlToPdf.Options.StartPageIndex to 0 at the same time.

Thanks!
Sit3coreD3v
Posted: Monday, June 29, 2015 11:47:47 PM
Rank: Newbie
Groups: Member

Joined: 6/29/2015
Posts: 9
Hi,
I have tried that, eg:
PdfDocument blankTemplate = new PdfDocument("c:\\temp\\blank.pdf");
string html = getUrlHTML(url); //custom function to get HTML
HtmlToPdf.ConvertHtml(html, blankTemplate, HtmlToPdf.Options);
blankTemplate.Save("c:\\temp\\Test.pdf");

My pdfDoucment template is a page PDF document that has the template i want to put the HTML into.

What i end up with is a pdf document but only the first page of it contains the template layout from my blank template. What i want is the same template applied to all pages. is this possible with this component?
Thanks
eo_support
Posted: Tuesday, June 30, 2015 9:32:23 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,229
Hi,

The HTML to PDF converter won't expand the template for you. You will need to expand the template to contain required number of blank pages first. For example, if you know your HTML can be 5 pages, then you can expand your template to be 5 pages long. You can do this by calling PdfDocument.Merge multiple times.

If you do not know how many pages your HTML will be, you can run the converter twice: The first run to find out how many pages it will be by checking this property:

http://www.essentialobjects.com/doc/eo.pdf.htmltopdfresult.lastpageindex.aspx

After that you can create the template to include that many pages and then run the converter again with the template.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.