![]() ![]() Adding links in the generated PDF file.Adding headers and footers to the PDF file.Adding a document outline to the PDF file. ![]() ![]() Printing more then one HTML document into a PDF file.Building QTĬompiling against the specially wkhtmltopdf-patched version of Qt adds several features to wkhtmltopdf that are not available in most distributed and/or statically compiled versions: Those settings suit my MacBook Air: yours may need to be different. I use these in my /etc/zshenv: export MACOSX_DEPLOYMENT_TARGET=10.7Įxport CFLAGS='-arch x86_64 -O3 -fPIC -mmacosx-version-min=10.7 -pipe -march=native -m64'Įxport LDFLAGS='-arch x86_64 -mmacosx-version-min=10.7' You may also want to check your shell’s environment vars. Environmentīefore starting, make sure you have the latest Apple toolchain: Run system update, then run XCode, go to preferences -> downloads and make sure you’ve got the latest command line tools installed. I figured it would be worth trying to do better than that, targeting 64-bit 10.7, so I found some build instructions (thanks to comments on on this page and this one (no, google code doesn’t provide IDs for comments, duh)) which I was able to adapt. Homebrew has a recipe for wkhtmltopdf, but it’s not built against a custom qt stack, and so is missing several features. That could well be enough for many uses, but this version is built for 32-bit OS X 10.4, which makes it about 327 in computer years. Here’s the magic to make it accessible in a ‘normal’ way: sudo ln -s /Applications/wkhtmltopdf.app/Contents/MacOS/wkhtmltopdf /usr/local/bin In a bug report (why does anyone use google code? it’s horrible!) I found a reference to a binary lurking inside the app bundle, and sure enough, it’s there, and it works. as supplied it’s apparently useless, though I eventually solved this mystery. When you run it one of two things happens: nothing, or an interminable bounce requiring a force-quit, i.e. For Linux there is a simple download of a binary, but the OS X version (despite being the most recent version posted) is curiously supplied as an OS X app bundle. Getting those is not as straightforward as it should be, and the docs are really pretty inadequate (hence this post). To use it requires that you have a working copy of wkhtmltox and libwkhtmltox. “Great”, I thought, “I’ll just install that and spend time working on the layouts since the code looks really simple”. So, I looked around and found several neat, simple PHP wrappers for calling wkhtmltopdf, and even a PHP extension. I’ve used qtwebkit for generating server-side page images before using python-webkit2png, and that’s fine (unlike using Firefox running in xvfb!), but I need to produce PDFs. ![]()
0 Comments
Leave a Reply. |