Chapter 17
Creating New PDFs

cpdf -create-pdf [-create-pdf-pages <n>]
     [-create-pdf-papersize <paper size>] -o out.pdf

cpdf -typeset <text file> [-create-pdf-papersize <size>]
     [-font <font>] [-font-size <size>] -o out.pdf

17.1 A new blank PDF

We can build a new PDF file, given a number of pages and a paper size. The default is one page, A4 portrait.

cpdf -create-pdf -create-pdf-pages 20
        -create-pdf-papersize usletterportrait -o out.pdf

The standard paper sizes are listed in Section 3.1, or you may specify the width and height directly, as described in the same chapter.

17.2 Convert a text file to PDF

A basic text to PDF convertor is included in cpdf. It takes a UTF8 text file (ASCII is a subset of UTF8) and typesets it ragged-right, splitting on whitespace. Both Windows and Unix line endings are allowed.

cpdf -typeset file.txt -create-pdf-papersize a3portrait
        -font Courier -font-size 10 -o out.pdf

The standard paper sizes are listed in Section 3.1, or you may specify the width and height directly, as described in the same chapter. The standard fonts are listed in chapter 8. The default font is TimesRoman and the default size is 12.

.NET Interface

 
CHAPTER 17. Creating New PDFs 
 
Cpdf.blankDocument(Double, Double, Int32) 
 
Creates a blank document with pages of the given width (in points), height (in 
points), and number of pages. 
 
Cpdf.blankDocumentPaper(Cpdf.Papersize, Int32) 
 
Makes a blank document given a page size and number of pages. 
 
Cpdf.textToPDF(Double, Double, Cpdf.Font, Double, String) 
 
Typesets a UTF8 text file ragged right on a page of size w * h in points in the 
given font and font size. 
 
Cpdf.textToPDFPaper(Cpdf.Papersize, Cpdf.Font, Double, String) 
 
Typesets a UTF8 text file ragged right on a page of the given size in the given 
font and font size.