Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WKHTMLTOPDF Generating only first page as PDF

I'm working on a project that require generating a PDF file from HTML content. I'm using wkhtmltopdf which I believe is the best solution I've came accross so far.

I was wondering if there was a way of generating only a one page PDF.

I have a HTML rendered interface and I want the user to get the same result (let's say 90% similar) on the resulting PDF file.

In the following example the content is still on the first page but wkhtmltopdf generates a second one that contains nothing :

enter image description here

I would like to get a one page PDF no matter the content of the page. I'm using the version 0.12 of wkhtmltopdf and I could not find in the documentation any option that allow to enter the desired number of pages.

I don't know if some of you already encountered such issue and if the solution would be an option flag that I don't know ? Or maybe there is another way ?

like image 541
thiout_p Avatar asked May 19 '15 16:05

thiout_p


1 Answers

I'm generating some multi page PDFs. In some cases only the first page is needed. So I'm using pdftk to output only the first page.

I'm using a command like:

wkhtmltopdf http://stackoverflow.com temp.pdf
pdftk temp.pdf cat 1 output output.pdf
rm temp.pdf
like image 59
powerpete Avatar answered Oct 14 '22 06:10

powerpete