Logo
My Account |  Site Map | Contact Us  
Welcome Guest Search | Active Topics | Sign In | Register

PDF: Background image not repeated on multiple html page Options
digio applications
Posted: Tuesday, June 19, 2012 8:23:12 AM
Rank: Member
Groups: Member

Joined: 6/19/2012
Posts: 11
We just persuaded the PDF converter and just noticed that if the body has a repeating background and the content is longer than one page the background image is not repeated on the second page (the background color is). The same goes for a table cell which has a repeating background image and the content is longer than one page, the background image is missing on the second page.
We use the latest version: 4.0.15.2

Example:
Code: Visual Basic.NET
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="utf-8" EnableViewState="False" %>
<%@ Import Namespace="EO.Pdf" %>
<script runat="server">	
	Sub Page_Load()
		Dim objPdfDocument As New PdfDocument
		Dim objResult As HtmlToPdfResult
						
		HtmlToPdf.Options.BaseUrl = "http://www.test.local"
		HtmlToPdf.Options.PageSize = PdfPageSizes.A4
		HtmlToPdf.Options.AutoFitX = HtmlToPdfAutoFitMode.ShrinkToFit
		HtmlToPdf.Options.AutoFitY = HtmlToPdfAutoFitMode.None
		HtmlToPdf.Options.NoLink = True
		HtmlToPdf.Options.PreserveHighResImages = True
				
		objResult = HtmlToPdf.ConvertHtml("<html><body style=""background-image:url(back.gif);background-repeat:repeat;"">Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br />Line<br /></body></html>", objPdfDocument)

		Response.Clear()
		Response.ContentType = "application/pdf"
		Response.AddHeader("content-disposition", "attachment;filename=""test.pdf""")
		objPdfDocument.Save(Response.OutputStream)
		Response.Flush()
		Response.End()
	End Sub
</script>
</html>
CSPi
Posted: Tuesday, June 19, 2012 8:36:42 AM
Rank: Newbie
Groups: Member

Joined: 5/29/2012
Posts: 4
Beat me to it - I have the same problem too!!

This problem has appeared between versions 3.0.104.2 and 4.0.15.2.

I have an example zip file showing the PDF output from both versions and the HTML / stylesheets used if this would be helpful. Let me know.

Jason.
eo_support
Posted: Tuesday, June 19, 2012 9:31:19 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 21,938
Hi,

This is a known issue and we already have a new build that fixed this issue. We will post the new build shortly and reply again when the download page is updated.

Thanks!
eo_support
Posted: Tuesday, June 19, 2012 10:05:38 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 21,938
Hi,

We have posted a new build (.17) that should fix this problem. Please take a look and let us know how it goes. If you still have problems, please post a test file and we will see what we can find.

Thanks!
digio applications
Posted: Tuesday, June 19, 2012 10:22:30 AM
Rank: Member
Groups: Member

Joined: 6/19/2012
Posts: 11
Problem fixed, thank you.
poseidonCore
Posted: Friday, January 17, 2020 12:52:44 AM
Rank: Member
Groups: Member

Joined: 8/17/2012
Posts: 21
Hi

This problem seems to have reappeared. It happened a fair few released back and I have been waiting for it to be picked up, but in the latest 2020 release, it is still not working.

Here is a test page for you:

https://poseidoncore.com/public/example.html

This produces the following output from your site:

http://api.essentialobjects.com/Files/TempPDFs/84ac6115-ead2-490e-9f6e-6e7b39413001.pdf

The default behaviour of the background property should be repeat on all pages, but this does not seem to be honoured any more in the PDF output.

Many thanks

Todd
eo_support
Posted: Friday, January 17, 2020 3:55:04 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 21,938
Hi,

Please move the background attributes from the body element to the root div element (in your case, the div element with class="WordSection1" immediately inside the body element) and also add background-repeat: repeat-y to the element.

The root of the problem is the body element does not represent the entire web page ---- it only represents the browser window, which for EO.Pdf it usually covers the first PDF page. So for example, if a web page is 3000 pixels high and each PDF page is 1000 pixels high, then the internal browser window used by EO.Pdf is only 1000 pixel high. This means the body element, along with its background, only covers the first 1000 pixels. The rest are not covered.

If you have no control over the source HTML file, you can use our HtmlToPdfSession object to run JavaScript after you load the page to perform the modification with JavaScript before performing the conversion. See here for more details on how to use HtmlToPdfSession object:

https://www.essentialobjects.com/doc/pdf/htmltopdf/session.aspx

The sample code uses session.Fill to fill textboxes. You will need to use session.ExecScript to run JavaScript code to apply the background to the root DIV element.

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

Thanks!

poseidonCore
Posted: Friday, January 17, 2020 8:32:40 PM
Rank: Member
Groups: Member

Joined: 8/17/2012
Posts: 21
Thanks. This remedy does work, even without explicitly adding "background-repeat: repeat-y", which is assumed by default. I can rework most of the templates to accommodate this new behaviour.

However, your explanation is in conflict with the fact that it did work previously for this page, and so I can only imagine that you have evolved the internal workings of the program (which is understandable given how much the concept of a viewport has evolved). Sadly, given that most sites don't take a document-focused approach of splitting up sections into root DIVs, this change may be problematic for others.

But for me, this works now :-)

Thanks again!
eo_support
Posted: Tuesday, January 21, 2020 3:43:08 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 21,938
Hi,

Yes. We did fix this before by modifying the browser engine's drawing code. However the original modification was modified on the WebKit browser engine (which our old version uses) and was not ported over to the new Blink engine (which our current version uses) due to concern about browser engine optimizations. Browser engines are constantly being optimized to draw as less as possible, where as our goal is to draw more here. In this cases, the blink engine contains a number of bypass paths that shortcircuit the unnecessary drawing out of the window.

We will "open" the necessary bypasses in our next build so it should work fine without you having to change your HTML. However as the optimization never stops, this has the potential of becoming somewhat of a cat and mouse game. So it might break again in future build. In any case, let us know if you see any problems and we will do what we can.

Thanks!
eo_support
Posted: Friday, January 24, 2020 10:54:15 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 21,938
Hi,

We have posted a new build that should render the background image properly without any HTML code changes. You can download the new build from our download page. Please take a look and let us know how it goes.

Thanks!
poseidonCore
Posted: Friday, January 24, 2020 9:41:48 PM
Rank: Member
Groups: Member

Joined: 8/17/2012
Posts: 21
Hi

I just tested this new version on an unmodified template and it worked great.

Thanks so much for your help!
poseidonCore
Posted: Sunday, January 26, 2020 2:21:08 AM
Rank: Member
Groups: Member

Joined: 8/17/2012
Posts: 21
Just an update: I had to pull this new version (EO.Total 20.0.33) from production because when the PDF library was called successively to convert HTML documents, images no longer showed in the successive PDFs. It is odd, because it worked perfectly for the first document.

I didn't change any code in my program: I only updated the PDF library itself.

It may be specific to my setup and so I'll keep looking for clues. I reverted to the previous version and there was no such issue.

I'll report back when I have a lead.

Thanks.
eo_support
Posted: Sunday, January 26, 2020 9:51:14 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 21,938
Ah. Thanks for letting us know. Please share with us when you find anything.


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.