Welcome Guest Search | Active Topics | Sign In | Register

background image shifts to up or down Options
YGDS2
Posted: Friday, June 17, 2016 10:56:22 AM
Rank: Newbie
Groups: Member

Joined: 2/23/2016
Posts: 6
Hi,
We have problem with fixing background image. Whenever we try to centering the bacground image it shift up or down.


We are using header and footer as external htmls and body as well.

Header, footer and body are positioned as below. (Outputarea shows body html I believe)

ho.FooterHtmlPosition = 10.5f;
ho.HeaderHtmlPosition = 0f;
ho.OutputArea = new RectangleF(0.5f, 0.7f, 8f, 9.8f);

In our body html we have

<div style="width:760px;min-height:931px;background:url('file:///Z:/PdfConverter/HtmlFiles/htmlDirectory/bg.jpg') repeat-y #fff;margin:0px auto;" id="bdydv">

Our bg image has dimeons of 760px to 931px and out html is 5 pages.

So at every page bg shifts about half inch down.

How can this possible and how can we fix this issue?


eo_support
Posted: Friday, June 17, 2016 5:37:34 PM
Rank: Administration
Groups: Administration

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

We do not see any reason why your background image shifts. The image itself should not shift if the DIV is positioned correctly. So you may want to try to replacing the background image with a solid background color to see if the DIV is positioned correctly. If that DIV is the only element you have in the body, then the top of the DIV should be at 0.7 inch from the top edge of the page.

If the problem continues, you can try to isolate the problem into a test project and send the test project to us. See here for more details:

http://www.essentialobjects.com/forum/test_project.aspx

We will take a look as soon as we receive that.

Thanks!
YGDS2
Posted: Wednesday, June 22, 2016 2:21:07 AM
Rank: Newbie
Groups: Member

Joined: 2/23/2016
Posts: 6
Hi,
Regarding to this issue, I sent you an email with project included yesterday. Could you please give a feedback about the issue?

Thanks,
eo_support
Posted: Wednesday, June 22, 2016 10:21:39 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,067
Yes. We have received the email. We are working on it and will let you know as soon as we have an update on this.
YGDS2
Posted: Monday, June 27, 2016 3:06:03 AM
Rank: Newbie
Groups: Member

Joined: 2/23/2016
Posts: 6
Hi,
Do you have any update regarding to this issue?

Thanks,
eo_support
Posted: Monday, June 27, 2016 7:39:55 PM
Rank: Administration
Groups: Administration

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

We have looked into this and we do not see any problems. The half inch shift that you see is exactly the half in top margin that you set on the PDF page. Specifically, if you open the HTML in a browser, you will see the top tip of the background image roughly aligns to the 11th line of the text. This alignment is exactly the same in the result PDF file. So there doesn't appear to be any problems at all. If you see something different, please let us know and we will look into this again.

Thanks!
YGDS2
Posted: Tuesday, June 28, 2016 2:00:24 AM
Rank: Newbie
Groups: Member

Joined: 2/23/2016
Posts: 6
Hi again,
As I understand you are mentioning the first page of the PDF document. Have you looked at the other page and check the bacground image there?

Because in second page, background image is align to the 14th line. And it shifts lower on each page further.

This doesn't seem to be a normal case.

Thanks!
eo_support
Posted: Tuesday, June 28, 2016 10:05:12 AM
Rank: Administration
Groups: Administration

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

That's because your PDF page pixel height is not the same as the DIV height (the page pixel height is (9.8 - 0.7) / (8 - 0.5) * 72 = 922, which is smaller than the min height you specified in your DIV) . This causes part of the DIV on the first page overflows to the second page and pushes the second DIV on the second page down. You need to adjust the DIV height so that it fits exactly on one page instead.

Thanks!
YGDS2
Posted: Wednesday, June 29, 2016 11:56:15 AM
Rank: Newbie
Groups: Member

Joined: 2/23/2016
Posts: 6
Hi,

Sory if this is silly question but how do you calculate in order to find 922. (9.8 - 0.7) / (8 - 0.5) * 72 this is equal 87,36. I really didn t get how you find 922.

Thanks

eo_support
Posted: Wednesday, June 29, 2016 12:22:16 PM
Rank: Administration
Groups: Administration

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

Sorry about the mistake. The correct formula should be (9.8 - 0.7) / (8 - 0.5) * 760. Here is how it's calculated:

pixel height = inch height * pixel per inch / zoom level
= (9.8 - 0.7) * 72 / zoom level
= (9.8 - 0.7) * 72 / (inch width * pixel per inch / min width)
= (9.8 - 0.7) * 72 / ((8 - 0.5) * 72 / 760)
= (9.8 - 0.7) * 72 / (8 - 0.5) / 72 * 760
= (9.8 - 0.7) / (8 - 0.5) * 760
= 922

Hope this clears up.

Thanks!


YGDS2
Posted: Wednesday, July 13, 2016 1:51:37 PM
Rank: Newbie
Groups: Member

Joined: 2/23/2016
Posts: 6
Hi
With your calculation I prepared files for following configurations. The div height was set to 905 since for below configuration gives 905 according to you calculation. But there is still shifting appears.

ho.PageSize = new SizeF(8.5f, 11f);
req.HtmlContent = File.ReadAllText(@"xxxxxx", Encoding.GetEncoding("utf-8"));
string htmlContent = req.HtmlContent;
ho.HeaderHtmlFormat = File.ReadAllText(@"xxxx", Encoding.GetEncoding("utf-8"));
ho.FooterHtmlFormat = File.ReadAllText(@"xxxx", Encoding.GetEncoding("utf-8"));
ho.FooterHtmlPosition = 10.55f;
ho.HeaderHtmlPosition = 0f;
ho.OutputArea = new RectangleF(0.5f, 0.81f, 8f, 9.77f);

However with above configuration I could minimize shifting to down maybe 1 inch. The prepared page size is 916px and image is also 916px

So there is still question in my mind on how to prepare a non shifting background image? What is the best practice for multiple background image with footer and header images as well?

Thanks,

eo_support
Posted: Wednesday, July 13, 2016 3:55:10 PM
Rank: Administration
Groups: Administration

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

You should not rely on such calculations for layout control. We gave you the calculation in our previous reply is just to show you why the problem occurs. However in reality there are a lot of other issues that can cause the calculation to be off (rounding errors, default margin/paddings, etc). If you want the image to be precisely positioned on each page, run a separate conversion for each page. That way every page you will have a fresh start and you will be able to control the position precisely.

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.