Pechkin icon indicating copy to clipboard operation
Pechkin copied to clipboard

Size of page content is not OK

Open enKor opened this issue 12 years ago • 8 comments

Hi, I have another problem with content of the PDF. I have created HTML. Simplified: it contains TABLE HR TABLE and this is wrapped by DIV. The width of tables is 826px and height about 1100px. In global config I have set up the PDF page size to A4. But my content is magnified up/down, but never is fit to the A4 page. If I try to print it in a browser, the preview looks OK, but PDF do not. Any suggestions, please?

enKor avatar Oct 12 '12 09:10 enKor

I can't reproduce it. With .SetPaperSize(PaperKind.A4) the table <table style="width: 826px; height: 1100px; background-color: gray;"> is fit into one page nicely.

Of course,

  • I use default margins, and
  • The content in my table isn't huge, so it doesn't cause table's stretch.

To further help you, I need the example, on which you get the strange behavior.

gmanny avatar Oct 19 '12 16:10 gmanny

Hi, here is the link http://www.prevlec.cz/db/ShowReport.aspx?code=repTiskProtokolu&id0=280284&usrlg=FiaL79o12

enKor avatar Oct 22 '12 15:10 enKor

So, what you need to do is have these two tables on different pages of the PDF file?

gmanny avatar Oct 22 '12 15:10 gmanny

Well, I've got those tables on separate pages: http://yhub.ru/u/p/tmp7B74.tmp.pdf

That's the code:

SynchronizedPechkin sc = new SynchronizedPechkin(new GlobalConfig().SetPaperSize(PaperKind.A4));
byte[] buf = sc.Convert(new ObjectConfig().SetPrintBackground(true).SetAllowLocalContent(true).SetCreateForms(false).SetPageUri("http://www.prevlec.cz/db/ShowReport.aspx?code=repTiskProtokolu&id0=280284&usrlg=FiaL79o12"));

gmanny avatar Oct 22 '12 15:10 gmanny

You can also try to use CSS3 property page-break-after, like this:

<style type="text/css" media="screen,print">
    // just put this into your styles:
    .break_page_here { page-break-after: always; }
</style>

<!-- and then put this div where the page break is necessary -->
<div class="break_page_here "></div>

(from here: http://code.google.com/p/wkhtmltopdf/issues/detail?id=173) Note that putting the class on another elements (or using inline style attribute) could not work, but the above method does.

gmanny avatar Oct 22 '12 15:10 gmanny

The problem is not the page separation, it works fine, but I recieve this PDF as result. The right and bottom margin is to big... The tables should fit to the A4 page. How to do that? PDF: (link removed)

enKor avatar Oct 23 '12 07:10 enKor

When I added .SetZoomFactor(1.1) to the ObjectConfig it made the content fit the width of the page. Taking margins into account some proportions were off, but it's a start.

gmanny avatar Nov 12 '12 22:11 gmanny

Yes, if when I used ZoomFactor(2.0) and IntelligentShringing(true), it works fine. Thanx

enKor avatar Nov 13 '12 08:11 enKor