ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Standard functions / PDF functions
  • Overview
  • Simple operations on PDF files in WLanguage
  • Manipulating the content of a PDF file in WLanguage
  • Types of variables
  • Operations with variable types
  • Read and write in controls from a PDF form
  • Functions for manipulating pdfDocument variables
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Overview
PDF is one of the most widely used formats for sending and storing electronic documents.
There are several ways to create or manipulate PDF files:
Simple operations on PDF files in WLanguage
Several functions can be used to perform simple operations on PDF files. These functions allow you to directly manipulate a PDF file:
PDFExtractPageExtracts a page from a PDF file in a variable of type Image.
PDFIsProtectedChecks whether the PDF file requires a password to be read.
PDFMergeMerges several PDF files into a single PDF file. Files are merged one after the other. The paths of the PDF files can be included in an array.
PDFMergeWithPasswordMerges several password-protected PDF files into a single PDF file.
PDFNumberOfPagesReturns the total number of pages in a PDF file.
PDFPasswordProtects a PDF document with a password.
PDFSignAdds an approval signature to an existing PDF.
PDFToTextExtracts text from a PDF file.
WINDEV
Manipulating the content of a PDF file in WLanguage

Types of variables

To easily manipulate the content of a PDF file, WLanguage offers different types of variables:
pdfAttachmentThe pdfAttachment type is used to define all the advanced characteristics of an attachment in a PDF document.
pdfBookmarkThe pdfBookmark type is used to define all the advanced characteristics of a bookmark in a PDF document.
New in version 2025
pdfControl
The pdfControl type is used to get all the characteristics and values of a control present in a PDF form.
New in version 2025
pdfControlOption
The pdfControlOption type is used to get and set the following characteristics of an option of a control present in a PDF form:
  • option text.
  • selected or deselected state of the option.
pdfDocumentThe pdfDocument type is used to get all the characteristics of a PDF file, including author, date created, page content, etc.
pdfPageThe pdfPage type is used to define all the advanced characteristics of a page from a PDF document loaded in memory.
pdfParameterThe pdfParameter type defines all the characteristics of the PDF file to be generated.
New in SaaS
pdfProtection
The pdfProtection type allows you to identify the protection options applied to a PDF document present in a variable of type pdfDocument.
This new variable type is available from WINDEV Suite SaaS 2025 Update 3.
pdfSignatureThe pdfSignature type is used to define the advanced characteristics of the signature that will be applied to a PDF file when signing an existing PDF (via PDFSign).
pdfTextElementThe pdfTextElement type is used to find out all the characteristics of a text element in a PDF page.

Operations with variable types

pdfDocument variables can be used to load the content of a PDF file into memory. For example:
MonPDF is pdfDocument = PDFOpen("test.pdf")

MonSecondPDF is pdfDocument = "C:\temp\exemplePDF.pdf"
You can use this variable to access the pages of the PDF document and the text of each page. For example:
MonPDF is pdfDocument = "test.pdf"
 
FOR EACH PageDuDocument OF MonPDF.Page
	FOR EACH ElémentPage OF PageDuDocument.ElémentTexte
		Trace(ElémentPage.Texte)
	END
END
With these types of variables, it is possible to delete or add pages to a document using array functions (Add, Delete, etc. ) directly on the array of pdfPage variables contained in the pdfDocument variable.
Example:
MyPDFDoc is pdfDocument = PDFOpen("C:\temp\Myguide.pdf")
Trace(MyPDFDoc.PDFVersion)
Trace(MyPDFDoc.Author)
Trace(MyPDFDoc.Page.Count)
Trace(MyPDFDoc.Page[1].Width)
Trace(MyPDFDoc.Page[36].Height)
FOR EACH ATextElement OF MyPDFDoc.Page[2].TextElement
	Trace(ATextElement.Text + " X = " + 
	ATextElement.X + " Y = " + ATextElement.Y + " L = " + 
	ATextElement.Width + " H = " + ATextElement.Height)
END
MyPDFDoc2 is pdfDocument = "C:\temp\plan.pdf"
// Add pages
Add(MyPDFDoc2.Page, MyPDFDoc.Page[5])
// Insert pages
Insert(MyPDFDoc2.Page, 1, MyPDFDoc.Page[32])
// Save modified PDF
PDFSave(MyPDFDoc2, "MyPDFDoc2.pdf")
ShellExecute("MyPDFDoc2.pdf")
New in version 2025

Read and write in controls from a PDF form

You can navigate through the controls in each page of a PDF form using a variable of type pdfControl.
You can read and, if necessary, change the value of each control using a variable of type pdfControlOption.
MonPDF is pdfDocument = "test.pdf"
FOR EACH PageDuDocument OF MonPDF.Page
	FOR j = 1 _TO_ PageDuDocument.Champ..Count
		champ is pdfControl = PageDuDocument.Champ[j]
		let sNom = champ.Name
		let sValeur = champ.Value
		Trace("La valeur du champ " + sNom + " est : " + sValeur)
	END
END

Functions for manipulating pdfDocument variables

You can use specific PDF functions to manipulate pdfDocument variables:
PDFAddImageAdds an image to a page in an existing PDF file.
PDFAddWatermarkAdds a watermark to all or some pages of an existing PDF file.
PDFCloseCloses the PDF file loaded in memory in a pdfDocument variable.
PDFExtractPageExtracts a page from a PDF file in a variable of type Image.
PDFGetSignatureGets the signature of a PDF document as a buffer.
PDFGetSignatureDateGets the date of one of the signatures of a PDF document.
PDFNbSignaturesGets the number of signatures in a PDF document.
PDFOpenOpens a PDF document and loads it in a pdfDocument variable.
PDFSaveSaves the content of a pdfDocument variable in a ".PDF" file.
PDFSignAdds an approval signature to an existing PDF.
PDFToTextExtracts text from a PDF file.
Note: Link to PDF Reader control field:
  • A variable of type pdfDocument can be assigned to a PDF Reader control.
  • A PDF document from a PDF Reader control can be retrieved in a variable of type pdfDocument.
    Example:
    MonDocPDF is pdfDocument
    MonDocPDF = PDF_LecteurPDF
Minimum version required
  • Version 14
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 05/14/2025

Send a report | Local help