Skip to content
This repository has been archived by the owner on Jan 2, 2023. It is now read-only.

Different margins for the cover page #3692

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

andkorsh
Copy link

Fix for the issue #3635.
For the proper backward compatibility it probably makes sense to configure this separately with something like --disable-margins-for-cover-page.

@katesowles
Copy link

Can someone get this straightened out and released?

@sp0tteh
Copy link

sp0tteh commented Nov 27, 2017

Seems to only been an issue with the osx build timing out?

The job exceeded the maximum time limit for jobs, and has been terminated.

@hakimio
Copy link

hakimio commented Jan 2, 2018

Few issues with the patch:

  • All margins, including left and right should be set to 0. Not just top and bottom.
  • I don't see why second call to "translate()" method on line 1004 in pdfconverter.cc is needed. It actually adds extra margin which you try to get rid with the first call to "translate()".
  • It doesn't work correctly with SVG background images. The background image gets messed up. I have attached an example of such cover page and following are margin settings I have used:
            'margin-right' => 9,
            'margin-left' => 9,
            'margin-top' => 12,
            'margin-bottom' => 12,
            'header-spacing' => 2,
            'footer-spacing' => 2

cover.zip

@hakimio
Copy link

hakimio commented Jan 3, 2018

Here is a small modification to Andrew's patch for people who want to get rid of all margins in cover page. Lines 1000-1004 in pdfconverter.cc should be replaced with the following:

if (objects[d].settings.isCover) {
	painter->save();
	painter->translate(-leftMargin * printer->width() / printer->widthMM(), -topMargin * printer->height() / printer->heightMM());
	printer->setPageMargins(0, 0, 0, 0, settings.margin.left.second);
}

@hakimio
Copy link

hakimio commented Jan 4, 2018

@ashkulz Do you know why after applying the patch SVG background image is still effected by the margin setting even all the other elements are positioned correctly on the cover page?

See the "cover.zip" file I have attached in my previous post as an example of this behavior.

Also, here is an illustration of the issue (grey margin outline instead of blue background fill):

issue

@mpseidel
Copy link

great to see this is coming - would love to be able to use it as well

@hakimio
Copy link

hakimio commented Jan 18, 2018

@mpseidel It will take a lot more work to get it to a state where it can be merged. If you have some time and understand how it works feel free to modify the patch.

@mpseidel
Copy link

@hakimio got it - unfortunately this is not my area of expertise :/
I ended up generating the cover and the main document separately and joining them via pdfunite. Good enough for me for now.

stncrn added a commit to stncrn/wkhtmltopdf that referenced this pull request Feb 2, 2018
Patching cover page for 0mm margins.

Original modification from andkorsh@c09862d

altered following this comment :
wkhtmltopdf#3692 (comment)
@anupmaurya484
Copy link

@hakimio got it - unfortunately this is not my area of expertise :/
I ended up generating the cover and the main document separately and joining them via pdfunite. Good enough for me for now.

Hello, i try to solved that issue but i can't do this solved ,
Have you solved that issue ?
The issue is "Different margins for the cover page"

@anupmaurya484
Copy link

anupmaurya484 commented Sep 19, 2018

@ashkulz Do you know why after applying the patch SVG background image is still effected by the margin setting even all the other elements are positioned correctly on the cover page?

See the "cover.zip" file I have attached in my previous post as an example of this behavior.

Also, here is an illustration of the issue (grey margin outline instead of blue background fill):

issue

Hello, i try to solved that issue but i can't do this solved ,
I have update the code but i don't know, how to generate new .exe file.
Would you help me ? and can you are make it one video, "how to generate .exe file using for wkhtmltopdf source file" so very very help full for me
Thank you

@hakimio
Copy link

hakimio commented Sep 19, 2018

@anupmaurya484 No, I won't be making videos like that but you can read how to create wkhtmltopdf packages here.

@anupmaurya484
Copy link

This link to used download the exe file and replace the old exe file then set cover page with margintop and marginbuttom.
Link : https://drive.google.com/open?id=1MaGhIqbwdDptXYZUoZ_YBTABWdnCCkx5
thanks @hakimio

@ega896
Copy link

ega896 commented Dec 11, 2018

@anupmaurya484
It still works bad. Adds invisible footer, and when body is more than size of page adds second invisible page and then table of contents becomes broken (must be page 2 not page 3).
image

@ega896
Copy link

ega896 commented Dec 11, 2018

If i remove last paragraph from html code all becomes good.
image

@QuincyHe
Copy link

I noticed the invisible footer as well. It seems that setting margins on the fly does not work. When you try to put full page content into cover, the printer still inserts a page break as if the margins were not changed. Although the painter can start at the very top of the page, the total content height that the printer used for calculation is still smaller than the page height (Height - top and bottom margins)

@Nstd
Copy link

Nstd commented Jan 7, 2022

Is this conflicts resolved?

@Franklin89
Copy link

@andkorsh Any update on this?

@t0byman
Copy link

t0byman commented Mar 1, 2022

Need this!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet