ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
  • Overview
  • Simple handling of PDF files in WLanguage
  • Manipulating the content of a PDF file in WLanguage
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Overview
PDF is one of the most widely used formats for transmitting and storing electronic documents.
Several methods can be used to create or manage PDF files:
Simple handling of PDF files in WLanguage
Various functions allow you to perform simple operations on PDF files. These functions directly handle the PDF file:
PDFExtractPageExtracts a page from a PDF file in an Variable of type Image.
PDFIsProtectedChecks whether the PDF file requires a password in order to be read.
PDFMergeMerges several existing PDF files into a single PDF file. The files are merged one after another. The paths of PDF files can be found in an array.
PDFMergeWithPasswordMerges several existing and password-protected PDF files into a single PDF file.
PDFNumberOfPagesReturns the total number of pages found in a PDF file.
PDFPasswordProtects a PDF document with a password.
PDFSignApplies an approval signature to an existing PDF.
PDFToTextExtracts the text found in a PDF file.
WINDEV
Manipulating the content of a PDF file in WLanguage
To handle more simply 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.
pdfDocumentThe pdfDocument type allows to know all the characteristics of a PDF file: author, creation date, page content, ...
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.
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.
A pdfDocument variable allows loading the content of a PDF file in memory. For example:
MonPDF is pdfDocument = PDFOpen("test.pdf")
 
MonSecondPDF is pdfDocument = "C:\temp\exemplePDF.pdf"
From this variable, it is possible to access the pages of the PDF document and for each page, the text of the PDF document. 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 management functions (Adds, Deletes, ... ) directly on the array of pdfPage variables contained in the pdfDocument variable.
Example:
MonDocPDF is pdfDocument = PDFOpen("C:\temp\Monguide.pdf")
Trace(MonDocPDF.PDFVersion)
Trace(MonDocPDF.Author)
Trace(MonDocPDF.Page.Occurrence)
Trace(MonDocPDF.Page[1].Largeur)
Trace(MonDocPDF.Page[36].Hauteur)
 
FOR EACH UnElémentTexte OF MonDocPDF.Page[2].ElémentTexte
Trace(UnElémentTexte.Texte + " X = " +
UnElémentTexte.X + " Y = " + UnElémentTexte.Y + " L = " +
UnElémentTexte.Largeur + " H = " + UnElémentTexte.Hauteur)
END
 
MonDocPDF2 is pdfDocument = "C:\temp\plan.pdf"
// Ajout de pages
Add(MonDocPDF2.Page, MonDocPDF.Page[5])
// Insertion de pages
Insert(MonDocPDF2.Page, 1, MonDocPDF.Page[32])
// Enregistrement du PDF modifié
PDFSave(MonDocPDF2, "MonDocPDF2.pdf")
ShellExecute("MonDocPDF2.pdf")

Specific PDF functions allow managing 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.
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.
Remark: Binding to the PDF Reader control:
  • A pdfDocument variable can be assigned to a PDF Reader control.
  • A PDF document from a PDF Reader control can be retrieved in a pdfDocument variable.
    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