|
Rank: Newbie Groups: Member
Joined: 3/24/2014 Posts: 7
|
Two single pages of data header works fine (works)First page wraps to 2 pages then header breaks (issue)On page 2 the header covers up the title and table (alpha 90% so you can see through) Setting HtmlToPdf.Options.RepeatTableHeaderAndFooter to true or false makes no difference, the header always repeats. How can I remove the header repeating, or pad the wrapped data. ALSO the page 1 header positions moves occasionally on refresh and will overlap the product title box (see image)
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
|
|
Rank: Newbie Groups: Member
Joined: 3/24/2014 Posts: 7
|
Which is why I wrote: BrentWiens wrote: Setting HtmlToPdf.Options.RepeatTableHeaderAndFooter to true or false makes no difference, the header always repeats.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi, I am sorry that I missed that. However we have verified RepeatTableHeaderAndFooter here and it seems to be working fine. One thing that you must keep in mind is that RepeatTableHeaderAndFooter is reset to true after every conversion. So if you want to set it to false, you have to set it before every conversion. The page 2 overlapping issue might have to do with your padding/margin on your body element. When contents are broken into multiple pages, the body element's top padding only apply to the top of the first page, this can cause the top of the contents on the second page to be higher than that of the first page. Usually this is not a problem because the difference is not much, but it can become very apparent when you have a header on each page. The page 1 overlapping/moving issue might have to do with your script. If you use JavaScript to set styles, then the converter may run before your JavaScript has finished updating the style. This is because the converter does not know when your JavaScript has finished running. If that's the problem you wish to have consistent result, you can use manual trigger feature: http://www.essentialobjects.com/doc/4/htmltopdf/eo_js.aspx#manual_triggerWith the manual triggering feature, the conversion will not start until you call the triggering function. Thus you can add some code in your page to detect whether the page is running inside the converter and if so, call the triggering function after you have finished updating everything. Hope this helps. Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 3/24/2014 Posts: 7
|
Thanks for the detailed reply. However I was not able to get any of the solutions workingRepeatTableHeaderAndFooter issue:I have verified I am setting it to false always and still repeats
Code: Visual Basic.NET
Dim doc As New PdfDocument()
HtmlToPdf.Options.PageSize = New SizeF(11.0F, 8.5F)
HtmlToPdf.Options.RepeatTableHeaderAndFooter = False
If Not HtmlToPdf.Options.RepeatTableHeaderAndFooter.Equals(False) Then Throw New Exception("RepeatTableHeaderAndFooter is true")
HtmlToPdf.Options.OutputArea = New RectangleF(0.25F, 0.9F, 10.5F, 8.0F)
If Not HtmlToPdf.Options.RepeatTableHeaderAndFooter.Equals(False) Then Throw New Exception("RepeatTableHeaderAndFooter is true")
HtmlToPdf.ConvertUrl(baseURL & URL_PREFIX & url & 1, doc)
HtmlToPdf.Options.RepeatTableHeaderAndFooter = False
If Not HtmlToPdf.Options.RepeatTableHeaderAndFooter.Equals(False) Then Throw New Exception("RepeatTableHeaderAndFooter is true")
HtmlToPdf.Options.OutputArea = New RectangleF(0.25F, 0.85F, 10.5F, 9.0F)
HtmlToPdf.ConvertUrl(baseURL & URL_PREFIX & url & 2, doc)
HtmlToPdf.Options.RepeatTableHeaderAndFooter = False
If Not HtmlToPdf.Options.RepeatTableHeaderAndFooter.Equals(False) Then Throw New Exception("RepeatTableHeaderAndFooter is true")
doc.Save(path & filename)
Page 1 periodic overlapping/moving issue:Tried using TriggerMode of Dual with 2 second sleep, but issue still exists
Code: Visual Basic.NET
HtmlToPdf.Options.TriggerMode = HtmlToPdfTriggerMode.Dual 'Page must be fully loaded and JS must call eopdf.convert();
Code: HTML/ASPX
<script type="text/javascript">
function PrintPDF() {
if (eopdf) {
setTimeout(function () {
eopdf.convert();
}, 2000) // 2 second sleep
}
}
window.onload = PrintPDF()
</script>
*New* HtmlToPdf.ConvertHtml() issue:On http://www.essentialobjects.com/doc/4/htmltopdf/header.aspx I tried doing "Using AfterRenderPage" section to see if that would work for overlapping/moving issue. The HtmlToPdf.ConvertHtml() always times out when I am using it in an event handler, either the exact same as the example or more simplified:
Code: Visual Basic.NET
HtmlToPdf.Options.AfterRenderPage = New PdfPageEventHandler(Sub(s As Object, e As PdfPageEventArgs)
HtmlToPdf.Options.OutputArea = New RectangleF(0.25, 0, 10.5F, 1.0F)
HtmlToPdf.ConvertHtml("<h1>Test</h1> <br />", e.Page) 'Times out
Dim breakpoint = 2 'Never hit
breakpoint *= 4
End Sub)
|
|
Rank: Newbie Groups: Member
Joined: 3/24/2014 Posts: 7
|
Also is there a way to set the top padding for repeated pages so header doesn't overlap?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi, Your code looks fine. There are a few things: 1. You do not need to set RepeatTableHeaderAndFooter before Save. You only need to set it before ConvertUrl/ConvertHtml; 2. By using a 2 seconds delay to trigger the conversion manually does not eliminate the possibility of that your script has not finished running yet. The same can be achieve through HtmlToPdf.Options.MinLoadWaitTime. The reason for the manual trigger is for you to precisely control when you want the conversion start; 3. Your ConvertHtml times out because you the manual trigger mode is still in effect thus inside your HTML you still need to call eopdf.convert(). Alternatively, you can also set TriggerMode back to Auto. This will not affect the outer conversion's options; I would recommend two things: 1. Use the debug console feature to debug your JavaScript code to make sure that your code were executed as expect: http://www.essentialobjects.com/doc/4/htmltopdf/js.aspxFor example, if you use JavaScript code to load CSS styles, add a console.log call after your CSS styles has been loaded. Check the debug console to see if you see that message. 2. Try to comment code out block by block to locate the problem trigger. Most of the time as soon as you know the trigger, you will know why it happens. However if you still can not explain why it happens after you have located the trigger, you can try to isolate the problem into a test project and send the test project to us. Please see here for test project guidelines: http://www.essentialobjects.com/forum/postst8144_Test-project-guidelines.aspxPlease let us know once you have that so that we can tell you where to send it. Thanks!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
BrentWiens wrote:Also is there a way to set the top padding for repeated pages so header doesn't overlap? You would set HtmlToPdf.Options.OutputArea for that. Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 3/24/2014 Posts: 7
|
Thanks for the quick reply. I solved the repeating header by removing all the white space from top of html page, and just using repeated header. With regards to the periodic overlapping/moving issue of page 1 header (if page 1 loops then on both those pages, last page never has issue) The issue isn't with the JavaScript as the issue still exists after removing the JavaScript.
Code: Visual Basic.NET
HtmlToPdf.Options.NoScript = True
HtmlToPdf.Options.MinLoadWaitTime = 2000
HtmlToPdf.DebugConsole = Console.Out
Shall I generate a test project for this?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
Sure. If it happens only sometimes then please try to create a test project and send that to us. We will PM you as to where to send it.
Thanks!
|
|