Creating+PDF+files

//by Richard Russell, October 2007//

A popular method for creating a **PDF** (Portable Document Format) file from a Windows application is to use a 'PDF Printer Driver' (or 'Virtual Printer'). This installs like an ordinary printer but rather than outputting to paper it creates a PDF file. There are many such products including:


 * [|PDF Creator] (GPL)
 * [|BullZip PDF Printer] (Freeware)
 * [|CutePDF Writer] (Freeware)
 * [|doPDF] (Freeware)
 * [|PDF24 Creator] (Freeware)
 * [|Neevia docuPrinter LT] ($19)
 * [|ReaSoft PDF Printer] ($25)
 * [|Gnostice Print2eDoc] ($29)
 * [|PDF Printer Pilot] ($29)
 * [|Solid PDF Creator] ($29.95)
 * [|PDFcamp] ($30)
 * [|Polestar Virtual Printer] ($30)
 * [|eXPert PDF] ($72)
 * [|pdfMachine] ($84)
 * [|GetPDF] ($89)
 * [|Virtual PDF Printer] ($90)

The approximate prices are given in US$ and are believed to be correct at the time of writing. In some cases more expensive enhanced or 'professional' versions are also available. I have received recommendations from users for **CutePDF** and **doPDF** (make sure you download the [|latest version] of the latter).

If you use such a program to create a PDF file from your BBC BASIC program there is one small problem - each individual page will come out as a separate document! This happens because traditional BBC BASIC programs (e.g. as written for the BBC Micro or Acorn Archimedes) have no way of indicating the end of the **document**, only the end of a **page**. Therefore //BBC BASIC for Windows// closes the current 'document' at the end of each page and opens a new 'document' at the start of the next page. This isn't apparent when outputting to a real printer, but is when creating a PDF.

This is easily solved by replacing the code which you would normally use to indicate the end of a printed page (typically **VDU 2,1,12,3**) with the following code:

code format="bb4w" SYS "EndPage", @prthdc% SYS "StartPage", @prthdc% VDU 2,1,30,3 code To close the document, after all the pages have been output, send a **VDU 2,1,12,3** as usual.