Article Preview
Buy Now
COLUMN
Column
Issue: 18.6 (November/December 2020)
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): 29,119
Starting Page Number: 85
Article Number: 18607
Resource File(s):
project18607.zip Updated: 2020-11-02 09:51:31
Related Web Link(s):
http://www.xdevmag.com/browse/11.1/11107
http://www.xdevmag.com/browse/16.2/16204
http://www.xdevmag.com/browse/17.5/175003
http://www.xdevmag.com/browse/18.1/18106
Excerpt of article text...
One of the most exciting new features of Xojo 2020r1 for me is the built-in support for creating PDFs. If you aren't familiar with it, it basically lets you draw a PDF using standard
graphics
command (drawFilledRectangle
,drawLine
,drawText
, etc.).Note that I've only just started to play with the new class, so this article is a mere introduction. But it should give you an overview and the included demo app will give you a testing ground to explore the feature.
PDF Basics
Xojo 2020r1 introduces a new class,
PDFDocument
, which is used to generate PDFs. On the surface this class is pretty simple. There really aren't many methods or properties at all (https://docs.xojo.com/PDFDocument).That is deceptive, however, because there are several parts to the system. For instance, all drawing of the PDF is done via its
graphics
object. This looks and works similar to thegraphics
object of apicture
. In theory, you can use your same picture-drawing code only send it to aPDFDocument.graphics
object. In practice, as I'll explain, things aren't quite so copacetic.Other
PDFDocument
commands include a method to add fonts to the PDF, save the PDF to a file, and even create a PDF via JSON data. I won't really get into those items in this article, but they are worth exploring in the future.
...End of Excerpt. Please purchase the magazine to read the full article.