Table of Contents

23.12.1 Class PdfDocument (gb.poppler)

This class represents a PDF document. It enables its content to be read and rendered. The class behaves like a read-only array. This is how you create a new PDF document of type PdfDocument from a PDF file in Gambas:

Dim hPdfDocument As PdfDocument
hPdfDocument = New PdfDocument ( Path As String [ , Owner As String, Password As String ] )

You can use the PdfPage class to return a specific page of a PDF document as a virtual object based on its index. Index is a value between 0 and the value of the property PdfDocument.Max = PdfDocument.Count -1.

Dim hPdfDocument As PdfDocument
Dim hPdfPage As PdfPage
hPdfPage = hPdfDocument [ Index As Integer ]

23.12.1.1 Properties

The PdfDocument class has the following properties:

PropertyData typeDescription
AntialiasingBooleanReturns or sets the value whether or not antialiasing is used for drawing pages.
AuthorStringReturns the author of the PDF document.
CountIntegerReturns the number of pages of the PDF document.
MaxIntegerReturns the number of pages of the document minus one; Max = Count -1.
CreationDateDateReturns the date on which the PDF document was created.
CreatorStringReturns the creator of the PDF document.
ProducerStringReturns the producer of the PDF document.
Index .PdfDocumentIndexReturns the index (table of contents) of a PDF document as a virtual object of type .PdfDocumentIndex.
KeywordsStringReturns a comma-separated list as a string.
LinearizedBooleanSpecifies whether the document is linearised or not. Linearisation of PDF content enables efficient incremental access to the PDF file in a network environment.
ModificationDateDateReturns the date the PDF document was last modified.
ResolutionFloatReturns or sets the resolution of the PDF document in DPI.
RotationIntegerReturns or sets the global page rotation in degrees. The value must be a multiple of 90: 0, 90, 180 or 270. The rotation angle can also be negative, for example -90.
SubjectStringReturns the subject of the PDF document.
TextAntialiasingBooleanReturns the value or sets whether the text is anti-aliased when drawing a page.
TextHintingBooleanReturns the value or sets whether text hinting was used when drawing a page.
TitleStringReturns the title of the PDF document.
VersionStringReturns the version of the PDF document as a string.

Table 23.12.1.1.1 : Properties of the PdfDocument class

Notes

sMessage = Format(Stat(FMain.DocumentPath).LastChange, "dd.mm.yyyy hh:nn:ss")
Print sMessage

23.12.1.2 Methods

The PdfDocument class only has one method:

MethodReturn typeDescription
Find ( Label As String )IntegerReturns the page index of the page that has the identifier 'Label'. If no page was found, -1 is returned.

Table 23.12.1.2.1 : Method of the PdfDocument class

23.12.1.3 Excursus

On the page https://wiki.ubuntuusers.de/poppler-utils/ you will find a brief description of command line programmes from the poppler-utils collection, which you can use to obtain information about PDF documents or convert them into an XML file, for example.

Here is an example of reading the fonts used in a PDF document, which is not possible using the Gambas component gb.poppler:

hans@pc-a-mint20:~/Dokumente$ pdffonts k23.12.pdf
name                                 type              encoding         emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
BAAAAA+LiberationSans                TrueType          WinAnsi          yes yes yes     48  0
CAAAAA+DejaVuSansMono                TrueType          WinAnsi          yes yes yes     33  0
DAAAAA+LiberationSans-Italic         TrueType          WinAnsi          yes yes yes     43  0
EAAAAA+LiberationSans-Bold           TrueType          WinAnsi          yes yes yes     38  0