The plugin can be used to conveniently load PDF pages as vector brushes. Just pass
the desired page to load in the user tag named Page and the plugin will load the
specified page. For example, this code loads page 10 as vector brush 1:
LoadBrush(1, "test.pdf", {UserTags = {Page = 10}})
|
If the Page user tag isn't specified, it will default to 1 which means that the
first page will be loaded. By default, the page backgrounds will be filled with
a static white background. If you want the background to be transparent instead,
set the Transparent user tag to True, e.g. like this:
LoadBrush(1, "test.pdf", {UserTags = {Page = 10, Transparent = True}})
|
In that case, the page's background will be made transparent. Finally, you can
also specify a user tag named Password to specify a password in case the PDF
file is password-protected.
Note that in case you need to load multiple pages as vector brushes at the same
time, it's more memory efficient to use pdf.OpenDocument() to open the
PDF and then pdf.GetBrush() to get vector brushes of the individual pages.
If you use LoadBrush() or @BRUSH, the whole PDF will be loaded into memory
for each page you convert to a vector brush, which can be quite memory hungry.
If you use pdf.OpenDocument() and then pdf.GetBrush() to get vector
brushes of the individual pages then PDF will only be stored in memory once.
Here is an example how to convert PDF pages to vector brushes using the pdf.OpenDocument() function and the pdf.GetBrush() command:
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.