3.2 Loading pages as vector brushes

To load PDF pages as vector brushes you have to open the PDF document using the pdf.OpenDocument() function and then convert the desired pages to Hollywood vector brushes using the pdf.GetBrush() command.

Here is an example:

 
pdf.OpenDocument(1, "test.pdf")
pdf.GetBrush(1, 1, 1)
DisplayBrush(1, #CENTER, #CENTER)
FreeBrush(1)
pdf.CloseDocument(1)

The code above will open the PDF document named test.pdf and convert its first page to a vector brush. It will then show this vector brush in the center of the display. Note that the vector brush will still depend on the PDF document so it is not allowed to call pdf.CloseDocument() on the document while you still need the brush. That's why we free the brush first and close the document afterwards. Otherwise there will be an error.

You can find out the number of pages in the PDF document by first getting the object type for PDF documents and then using Hollywood's GetAttribute() function, like so:

 
PDF_DOCUMENT = pdf.GetObjectType()
numpages = GetAttribute(PDF_DOCUMENT, 1, #PDFATTRPAGES)

The code above gets the number of pages from the PDF document that uses the identifier 1 and stores it in the variable numpages.


Show TOC