Special

Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 15 in printed book and digital formats -- plus a one-year subscription so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview


Buy Now

Issue 11.1 ('PDF')
Instant purchase and download via GumRoad!

FEATURE

Command Line PDFs

Generating PDFs from HTML with Real Studio

Issue: 11.1 (January/February 2013)
Author: Marc Zeedar
Author Bio: Marc taught himself programming in high school when he bought his first computer but had no money for software. He's had fun learning ever since.
Article Description: No description available.
Article Length (in bytes): 46,018
Starting Page Number: 34
Article Number: 11107
Resource File(s):

Download Icon 11107project.zip Updated: 2013-01-04 14:09:44

Related Web Link(s):

http://rsdeveloper.com/browse/6.3/6315/
http://rsdeveloper.com/browse/6.4/6411/
http://apple.com
http://www.apple.com/ipad-mini/overview
http://madalgo.au.dk/~jakobt/wkhtmltoxdoc/wkhtmltopdf-0.9.9-doc.html
http://madalgo.au.dk/~jakobt/wkhtmltoxdoc/wkhtmltopdf-0.9.9-doc.html
http://rsdeveloper.com/images/rsd10book3d-small.png

Excerpt of article text...

In RSD 6.3 (http://rsdeveloper.com/browse/6.3/6315/), I wrote on how to generate very basic PDFs using some Real Studio classes. In the subsequent issue, Christian Schmitz explained how to do it using his Monkeybread Plugins (http://rsdeveloper.com/browse/6.4/6411/), but it's not a topic we've covered in a while. There's nothing wrong with either approach, but I recently had a project where I wanted to generate PDFs from simple HTML files. I wanted more features than I had with the PDF classes approach, and I didn't want the complexity of plugins. It occurred to me that maybe there was a command-line app that would convert HTML to PDF.

A little searching online and I discovered wkhtmltopdf, a wonderful command-line tool that does just what I wanted. It's free (https://code.google.com/p/wkhtmltopdf/), multi-platform (it's built upon Apple's Webkit, the foundation for Apple's Safari web browser), and it works well. Using it isn't exactly easy, but it's more geeky than complicated, as the documentation is technical.

In principal you can call wkhtmltopdf from your Real Studio application, feed it some HTML, and receive back a formated PDF. All this can be done in the background, so the user never has to even know how you're doing it. From the user's perspective, your app just generated a PDF.

Installing wkhtmltopdf

One drawback to using wkhtmltopdf is that it, in general, must be separately installed. For some uses, this could be a problem, though most likely you could automate the installation of this tool along with your own application. On Macintosh, I came up with a way to embed the tool within the application bundle (see the "Embedding wkhtmltopdf in Mac Apps" sidebar for the details), but since the tool under Windows is more complicated (with several DLLs and other files), I didn't attempt to figure out how to do that there. (It might be possible; I just didn't try it.)

...End of Excerpt. Please purchase the magazine to read the full article.