Questions tagged [wkhtmltopdf]

A shell utility to convert HTML to PDF using the Webkit rendering engine and Qt.

Tool for converting web pages to PDF documents using the WebKit engine. These run entirely "headless" and do not require a display or display service.

Document objects:

wkhtmltopdf is able to put several objects into the output file, an object is either a single webpage, a cover webpage or a table of content. The objects are put into the output document in the order they are specified on the command line, options can be specified on a per object basis or in the global options area. Options from the Global Options section can only be placed in the global options area

A page objects puts the content of a singe webpage into the output document.

(page)? <input url/file name> [PAGE OPTION]...

Options for the page object can be placed in the global options and the page options areas. The applicable options can be found in the Page Options and Headers And Footer Options sections.

A cover objects puts the content of a singe webpage into the output document, the page does not appear in the table of content, and does not have headers and footers.

cover <input url/file name> [PAGE OPTION]...

All options that can be specified for a page object can also be specified for a cover.

Resources:

2447 questions
25
votes
3 answers

how to pass html as a string using wkhtmltopdf?

how to pass html as a string instead of url in wkhtmltopdf using asp.net, c#?
Eugene
  • 251
  • 1
  • 3
  • 3
24
votes
3 answers

Use wkhtmltopdf to set landscape orientation

How I can change the orientation of my pdf file which is generated with Wkhtmltopdf. I invoke it in PHP like following: $file = fopen("tmp/html/pdfTmp_$numRand.html", "w") or exit("Unable to open file!"); fwrite($file,…
Daykeras
  • 253
  • 1
  • 2
  • 4
22
votes
3 answers

Add content to the bottom of the last page

I am using wkhtmltopdf to create PDF reports from HTML, I need to create a custom report that follows this pattern: Some information at the top of the first page. A table that can have 1 to n rows (it should use any amount of pages it needs) Some…
juanefren
  • 2,818
  • 6
  • 32
  • 41
22
votes
3 answers

WKHTMLTOPDF Installation error on Ubuntu

We require features like header, footer, table of contents and cover page of pdf, which we want to generate from html/css. We tried WKHTML on windows and it worked like a charm, when moving to our server, we installed WKHTML on our ubuntu server,…
Rasikh Mashhadi
  • 1,422
  • 1
  • 15
  • 25
21
votes
2 answers

wkhtmltopdf print-media-type uses @media print ONLY and ignores the rest

I have an HTML file that uses one CSS file. Inside this file at the very bottom, I use this for styles that need to be applied ONLY to the printer version of the page: @media print{ ....print styles here... } When I call wkhtmltopdf…
Hill
  • 419
  • 1
  • 7
  • 12
21
votes
4 answers

Debugging javascript in wkhtmltopdf

Where I can see the output of javascript debug when wkhtmltopdf runs in debug mode (--debug-javascript)
El Kopyto
  • 1,157
  • 3
  • 18
  • 33
21
votes
1 answer

Unwanted left margin when using -webkit-transform: scale(...)

I am using wkhtmltopdf (which uses the Webkit rendering engine) to convert HTML files to PDF documents. The generated PDFs are A4. In other words, they have fixed dimensions, and thus a limited width. One of the tables in my PDF contains images,…
Kosta Kontos
  • 4,152
  • 7
  • 25
  • 28
21
votes
6 answers

wkhtmltopdf css sizes in cm/mm

I use wkhtmltopdf to produce A4 sized PDFs. When I create a
tag and set its style to height: 297mm; width: 210mm (which is the defined size of A4), set wkhtmltopdf's margin settings to 0 (wkhtmltopdf -B 0 -T 0 -L 0 -R 0 ...) and give the
Simon
  • 12,018
  • 4
  • 34
  • 39
21
votes
6 answers

Fix wkhtmltopdf headers clipping content?

My headers often clip content so that the content below it is not completely visible, it appears as though the page continues underneath the header before the header ends and as a result, not all of the content is shown. Is there a CSS rule I can…
Joel Peltonen
  • 13,025
  • 6
  • 64
  • 100
20
votes
3 answers

Insert folding marks on every page (wkhtmltopdf)

I'm using wkhtmltopdf 0.12.2.1 to create invoices and so on. I need to display folding marks on every page in a pdf. How can I repeat them with javascript on every page, if the content is larger than one? That's my basic markup
csy_dot_io
  • 1,199
  • 6
  • 19
20
votes
4 answers

wkhtmltopdf - encoding issue

I'm using wkhtmltopdf to export html pages to pdf, but it seems it has a problem with Czech characters... I load whole html into variable, then I change encoding and run wkhtmltopdf like this: $html = ob_get_clean(); $html =…
Michal S
  • 1,103
  • 6
  • 19
  • 31
19
votes
5 answers

Can I use wkhtmltopdf on AWS Lambda

I'm using a AWS Lambda function to merge PDF files stored on S3. In addition to that, I need now to create a PDF file (from HTML and CSS). I was trying to use wkhtmltopdf, but it seems that I would have to install it using apt-get install (which I…
Fabio Baldissera
  • 583
  • 1
  • 4
  • 15
19
votes
3 answers

How to set margin top for header?

The --margin-top option is for the contents margin, but I would like to set the margin from the top of the page to the header. The project I'm working on allows users to create header and footer themselves, so the height of the header or footer is…
GordonZ
  • 364
  • 1
  • 2
  • 10
19
votes
2 answers

Azure websites and wkhtmltopdf

So after beginning my azure websites-adventure, I have been encountering disappointment after disappointment to the point of 'almost' regretting taking the azure route..the latest: my app uses wkhtmltopdf(Rotativa) for all its PDF generation. And as…
19
votes
3 answers

wkhtmltopdf wait for condition before printing

We are using wkhtmltopdf to convert dynamic html pages to pdf. We need to wait until all the ajax requests are finished. Is there a possibility to delay the printing by a condition?
Levi
  • 657
  • 2
  • 6
  • 14