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
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Extracts a page from a PDF file in a variable of type Image.
New in version 2025
IOS Widget This function is now available in iOS widget mode.
iPhone/iPad This function is now available for iPhone/iPad applications.
AndroidAndroid Widget The syntax for manipulating a pdfDocument variable is now available.
Example
// Extracts page 3 from the text.pdf file
MyImage is Image = PDFExtractPage("text.pdf", 3)
// Extracts page 3 from the text.pdf file
MyPDF is pdfDocument = PDFOpen("test.pdf")
MyImage is Image = PDFExtractPage(MyPDF, 3)
EDT_NumPagePDF.BackgroundColor = White
IF EDT_NumPagePDF = 0 THEN
	Info("Specify a page page number to be extracted")
	EDT_NumPagePDF.BackgroundColor = PastelRed
	SetFocusAndReturnToUserInput(EDT_NumPagePDF)
	RETURN
END

sNewPath is string = fSelectDir(sOriginalPath, ...
	"Directory selector", "Select the page extraction directory")

// Search in the DOC_Contact data file for the text contained in the Table control.
HReadSeek(DOC_Contact, DOCID_Contact, TABLE_Win_Document_List.COL_DOCID_Contact)
IF HFound() THEN
	HourGlass()
	MyPDFPath is string = sNewPath + "\" + ...
			DOC_Contact.DOCID_Contact + "." + DOC_Contact.Format
	// Document is a memo that contains the PDF file
	IF NOT HExtractMemo(DOC_Contact, Document, MyPDFPath) THEN
		Error(HErrorInfo())
	ELSE
		IF PDFNumberOfPages(MyPDFPath) < EDT_NumPagePDF THEN
			Error("The PDF document does not contain enough pages", "Processed canceled")
			RETURN
		END
		MyPDFImage is Image = PDFExtractPage(MyPDFPath, EDT_NumPagePDF)
		// Delete original PDF
		fDelete(MyPDFPath)
		MyPNGImage is string = sNewPath + "\" + DOC_Contact.DOCID_Contact + ...
			 "_Page" + EDT_NumPagePDF + ".PNG"
		dSaveImagePNG(MyPDFImage, MyPNGImage)
		ShellExecute(MyPNGImage)
	END
	HourGlass(False)
END
Syntax

Extracting a page from a PDF using the file path Hide the details

<Result> = PDFExtractPage(<File path> , <Page number> [, <Width> [, <Height> [, <Password>]]])
<Result>: Image (image variable)
Image variable that contains the image of the extracted page. The returned image is a raster image.
Note: If the PDF file does not exist, or if the page does not exist, the Image variable returned will be invalid. The ErrorOccurred variable will be set to True.
<File path>: Character string
Path of the PDF file from which the page will be extracted.
<Page number>: Integer
Number of the page to be extracted.
<Width>: Optional integer
Width at which the page is to be rasterized.
If this parameter is not specified (or is set to 0), the height and width will be calculated from the page size (in millimeters), using a DPI of 300.
<Height>: Optional integer
Height at which the page is to be rasterized.
If this parameter is not specified (or is set to 0), the height and width will be calculated from the page size (in millimeters), using a DPI of 300.
<Password>: Optional character string or secret string
Password of the PDF document.
New in version 2025
Secret strings: If you use the secret string vault, the type of secret string used for this parameter must be "Ansi or Unicode string".
To learn more about secret strings and how to use the vault, see Secret string vault.
AndroidAndroid Widget Secret strings are not available for this parameter in Android/Android widget applications.

Extracting a page from a PDF file using a pdfDocument variable Hide the details

<Result> = PDFExtractPage(<PDF document> , <Page number> [, <Width> [, <Height> [, <Password>]]])
<Result>: Image (image variable)
Image variable that contains the image of the extracted page. The returned image is a raster image.
Note: If the PDF file does not exist, or if the page does not exist, the Image variable returned will be invalid. The ErrorOccurred variable will be set to True.
<PDF document>: pdfDocument variable
Name of the pdfDocument variable that corresponds to the PDF document to be used.
<Page number>: Integer
Number of the page to be extracted.
<Width>: Optional integer
Width at which the page is to be rasterized.
If this parameter is not specified (or is set to 0), the height and width will be calculated from the page size (in millimeters), using a DPI of 300.
<Height>: Optional integer
Height at which the page is to be rasterized.
If this parameter is not specified (or is set to 0), the height and width will be calculated from the page size (in millimeters), using a DPI of 300.
<Password>: Optional character string or secret string
Password of the PDF document.
New in version 2025
Secret strings: If you use the secret string vault, the type of secret string used for this parameter must be "Ansi or Unicode string".
To learn more about secret strings and how to use the vault, see Secret string vault.
AndroidAndroid Widget Secret strings are not available for this parameter in Android/Android widget applications.
Business / UI classification: Business Logic
Component: wd300pdf.dll
Minimum version required
  • Version 20
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 11/23/2024

Send a report | Local help