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 22 in printed book and digital formats -- plus a one-year subscription (beginning with 23.1) 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 23.2 ('Making Mancala')
Instant purchase and download via GumRoad!

FEATURE

Making PDFs Faster

Generate Multiple PDFs at Once

Issue: 23.2 (March/April 2025)
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): 18,512
Starting Page Number: 43
Article Number: 23204
Resource File(s):

Download Icon project 23204.zip Updated: 2025-03-02 13:15:01

Related Web Link(s):

http://xdevmag.com/browse/22.6/22606/
http://xdevmag.com/browse/23.1/23104/
http://xdevmag.com/browse/11.1/11107/
http://xdevmag.com/browse/11.1/11107/

Excerpt of article text...

A few months ago, I wrote about how Xojo added preemptive threads (http://xdevmag.com/browse/22.6/22606/), which allow your apps to truly do more than one thing at a time. As I work on new projects, such as last issue's Batch Image Processor (http://xdevmag.com/browse/23.1/23104/), I have found it helpful to create the code using preemptive threads to make the app work faster.

Recently, I was using my html2pdf app that I wrote about in xDev 11.1 (http://xdevmag.com/browse/11.1/11107/). This app generates PDF files from Markdown or HTML documents. These PDFs are great for reading on an iPad, and I use this program all the time. The original version of the app generated one PDF at a time. I had a bunch of files to convert (about 50 documents), and this took several minutes. As I waited for it to finish, it occurred to me that I could make it use preemptive threads and speed it up.

Before it had even finished, I opened the project file in Xojo and began making adjustments. It took a bit of tweaking but wasn't difficult. In about 20 minutes, I had the app working, and when I did a test run of five files, they processed in about the same amount of time as one file!

This got me excited, so I dragged the full set of 50 files I'd just converted to my app—and bang, the entire batch was processed in seconds. Obviously, the speed varies according to your computer, how many CPU cores it has, and how complicated the HTML files you're converting are, but the fact that it can convert multiple files at once is a tremendous speedup.

I am now such a fan of this that I recommend going through all your old programs that do any kind of multifile processing and changing them to use preemptive threads!

Supporting Preemptive Threads

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