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
14
votes
4 answers

wkhtmltopdf command fails

I am trying to convert a HTML file to PDF using wkhtmltopdf. For that purpose I have installed wkhtmltopdf on a Debian box and am trying to run this command: /usr/bin/xvfb-run -a -s "-screen 0 640x480x16" wkhtmltopdf…
phidah
  • 5,794
  • 6
  • 37
  • 58
14
votes
1 answer

WkHTMLtoPDF Unicode Issue

I've already read several similar StackOverflow posts and none of them were able to resolve my issue. The Issue I have a PDF that's being generated by WkHTMLtoPDF which contains a unicode RIGHT SINGLE QUOTATION MARK (U+2019, or ’) character.…
stevendesu
  • 15,753
  • 22
  • 105
  • 182
14
votes
1 answer

Page size in PDF generated by wkhtmltopdf is 25% smaller than expected

I am using the following CSS a web page that the user will print: .page { padding: 1.04cm 1.54cm 1.04cm 1.54cm; width: 21cm; min-height: 29.7cm; height: 29.7cm; } When using Print Preview in Google Chrome or IE, it looks fine: the…
user6269864
14
votes
3 answers

wicked_pdf does not run on Ubuntu server : wkhtmltopdf: cannot connect to X server

I'm trying to use wicked_pdf on my prod server but it keeps failling : RuntimeError (Failed to execute: "/usr/bin/wkhtmltopdf" -q "file:////tmp/wicked_pdf20130709-23109-1adqx5g.html"…
Syl
  • 3,719
  • 6
  • 35
  • 59
14
votes
1 answer

Header height and positioning header from top of page in wkhtmltopdf

In my application, the user is allowed to define his own headers and margins for printing. For the header, the user can provide the following two fields: (a) Page Top Margin in mm (from top of the page) (b) Header Margin in mm (from top of the…
mohitp
  • 1,305
  • 2
  • 16
  • 20
13
votes
2 answers

Is there a version of wkhtmlto(pdf/image) that supports CSS3 Columns?

I am using both wkhtmltopdf and wkhtmltoimage to generate my preview image and a pdf of a document. The only problem is, I need column support. Getting it to work with Javascript is becoming time consuming and really getting me nowhere. Is there a…
Justin Lonas
  • 189
  • 1
  • 11
13
votes
4 answers

Unable to merge 2 PDFs using MemoryStream

I have a c# class that takes an HTML and converts it to PDF using wkhtmltopdf. As you will see below, I am generating 3 PDFs - Landscape, Portrait, and combined of the two. The properties object contains the html as a string, and the argument for…
Sanketh. K. Jain
  • 489
  • 1
  • 9
  • 24
13
votes
2 answers

Qt: Could not initialize OLE (error 80010106) - (libwkhtmltox.dll) on C#

im using this libwkhtmltox.dll to convert my html to pdf. Im using c# .netCore. Usage: private static string CreatePdf(string content, string fileName) { var fullPath = $"{_projectSettingsOptions.Pdf}/{fileName}"; using (var…
13
votes
3 answers

Rendered PDF looks different in production - Rails, PDFKit, wkhtmltopdf

I am using Rails pdfkit gem to render multi-page pdf files. The rendered pdf file picks up the CSS(SCSS) styling and page breaks as expected. However, when I try to render the same pdf document in production, it seems like the styling only loads…
dimitry_n
  • 2,939
  • 1
  • 30
  • 53
13
votes
7 answers

Install WKHTMLTOX (WKHTMLTOPDF + WKHTMLTOIMAGE) on AWS ElasticBeanstalk

I need WKHTMLTOX to be installed with my AWS EB app. I found this tutorial and it works except it supports old version. Did anyone install the latest (0.12.3) version on AWS EB as this is a bit different folders structure?
Strabek
  • 2,391
  • 3
  • 32
  • 39
13
votes
3 answers

How to convert an HTML file to PDF using wkhtmlpdf in Java

I want to convert an HTML file into a PDF file using wkhtmltopdf. wkhtmltopdf is the best option for me as it renders the HTML file using WebKit. The problem is that I want to do the same using Java but wkhtmltopdf does not provide any Java API. I…
Surajeet Bharati
  • 1,363
  • 1
  • 18
  • 36
13
votes
2 answers

Could not create PDF: sh: wkhtmltopdf: command not found

Just having some trouble with wkhtmltopdf. It works fine in command line but in PHP I keep getting this error: Could not create PDF: sh: wkhtmltopdf: command not found. It does work after a stop and restart of Apache, but it stops working after a…
stefan
  • 2,685
  • 2
  • 24
  • 31
13
votes
5 answers

Why do wkhtmltopdf.exe produce different results on different Windows machines?

I have a simple test.html file:
This is a test to see what happens when this kind of text gets processed by wkhtmltopdf
Which I run through wkhtmltopdf.exe like this: wkhtmltopdf.exe…
smerlung
  • 1,459
  • 1
  • 13
  • 32
13
votes
3 answers

Setting a resolution for xvfb-run and wkhtmltopdf / wkhtmltoimage

I'm trying desperately to give xvfb-run some resolution arguments to take screenshots of websites with wkhtmltox in different resolutions. I'm using both xvfb-run and wkhtmltox on CentOS. xvfb-run --server-args="-screen 0 1024x768x24" wkhtmltoimage…
Tomukas
  • 155
  • 1
  • 2
  • 8
13
votes
3 answers

wkhtmltopdf attempting to load from http rather than file

Here's an odd little problem that's led me to post my first question on SO. I am using wkhtmltopdf to convert an HTML document to a PDF as part of a Rails app. To do so, I am rendering the Rails web page to a static HTML file in a temp directory,…
lascarides
  • 335
  • 3
  • 9