|
Rank: Newbie Groups: Member
Joined: 6/3/2014 Posts: 5
|
Hi,
Im currently using your component and so far is great, we are using the tfoot tag on the html for a table and the EO.Pdf.HtmlToPdf.ConvertUrl works like a charm, it renders the footer on each page, we wanted to tweak the position of this specific tag to be always in the bottom of the PDF page itself but no luck on it, we tried to use EO.Pdf.HtmlToPdf.Options.FooterHtmlPosition = 14f; but it doesnt do anything to those "footers" that are created via the "tfoot" tag, is there a way to move or position the "tfoot" at the bottom of the page always?
thanks
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
If you just want something to repeat at the bottom of each page, you would use HtmlToPdf.Options.FooterHtmlFormat. This property works with FooterHtmlPosition. TFOOT is specifically for repeating table footer, it's not for general purpose page footer.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 6/3/2014 Posts: 5
|
Thanks for your reply, Is there a way to setup the position of the tfoot on each page??
The problem I have by using the FooterHtmlFormat is that the footer value can change depending on the URL and I wont know the value of the footer until the page is rendered, so having something static on the FooterHtmlFormat at the time of setting up the options before calling EO.Pdf.HtmlToPdf.ConvertUrl its not working for me.
Or another way would be how can I add the value of FooterHtmlFormat after I have my pdf rendered, lets say something like this wont work:
EO.Pdf.HtmlToPdf.Options.FooterHtmlPosition = 12f; var htmlDoc = EO.Pdf.HtmlToPdf.ConvertUrl(url, outputStream); EO.Pdf.HtmlToPdf.Options.FooterHtmlFormat = "<div>New Footer {1}</div>";
where {1} will depend the ConvertUrl.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi, In that case you do not have to use FooterHtmlFormat. You can just run the converter once to generate all the main content, then do a loop on all pages to add whatever additional output you want to add to the page. The code would be something like this:
Code: C#
//Do the main conversion
PdfDocument doc = new PdfDocument();
HtmlToPdf.ConvertUrl(main_content_url, doc);
foreach (PdfPage page in doc.Pages)
{
//You must set OutputArea to the footer area
HtmlToPdf.Options.OutputArea = .....
//Add output to page
HtmlToPdf.ConvertHtml("footer", page);
}
Inside the loop you can also use the "PDF Creator" interface (the AcmXXX objects) to generate output. The ACM interface is less powerful but is faster. You can take a look of the "PDF Creator" documentation to see how to use those. Please let us know if you still have any questions. Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 6/3/2014 Posts: 5
|
I was able to use your code but once I added the HTML into the page document, the resulting PDF doesnt have the styles from the Page nor the images, lets say I add something like:
<div class='myClass'>This is the footer</div> <img src='/content/i/equal-b.svg'>
It only shows "This is a footer" without the class styled nor the image, I tried that piece of HTML on your code and in the FooterHtmlFormat and neither of them recognized the styles from the original URL Page, Would I need to add the styles and the entire URL of the images as part of the HTML Im adding?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
No. The additional HTML you rendered does not share the same resources/style sheets as the main contents. You can either use inline CSS, or use link element to reference the CSS file and then set HtmlToPdf.Options.BaseUrl. You also need to set HtmlToPdf.Options.BaseUrl in order for images to work correctly. The basic rule is the additional ConvertHtml call has nothing to do with the previous ConvertUrl call, so it does not get anything from the previous call.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 6/3/2014 Posts: 5
|
Hi and good morning, thanks I will proceed to do that. Btw we found that using tfoot produces some weird errors in the pdf rendering and depending on the amount of data on the table it doesnt render properly page, I have an example for you to see. I tried to render the following URL with the Html2Pdf.exe and the result was the last page cutting the tfoot in half, it happens in our enviroment as well, maybe you can tell us why so we can fix it or if its something to be fixed from your side. http://jwhomes.com/Find-Your-Home/Georgia/Neighborhoods-in-the-Atlanta-GA-Area/Neighborhoods-in-Marietta-GA/Meeting-Park-Neighborhood/price-sheetThanks.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
You have a single table with a single tbody row that contains everything and you are only using thead and tfoot in order to add page header/footers. Please do not use thead/tfoot this way. Use the loop we explained in our previous post to add table header/footers.
The reason that you are having problem with the tfoot on the last page is, when we try to repeat table header/footers, we try to avoid situations where a page only contains the table footer but no table rows. So the last tfoot is always attached to at least one tbody row. This causes problem for your case because your whole document only has a single tbody row.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 6/3/2014 Posts: 5
|
Ok, thanks
We end up getting rid of the tfoot and use FooterHtmlFormat whith the baseurl and inline styles, it end up working fine.
Cheers,
|
|