PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • Overview
  • Simple operations on PDF files
  • Advanced operations on PDF files
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
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 operations on PDF files
Various functions allow you to perform simple operations on PDF files. These functions directly handle the PDF file:
Versions 20 and later
PDFExtractPage
New in version 20
PDFExtractPage
PDFExtractPage
Returns an Image type variable containing a page from a PDF file.
Versions 14 and later
PDFIsProtected
New in version 14
PDFIsProtected
PDFIsProtected
Checks whether the PDF file requires a password in order to be read.
Versions 17 and later
PDFMerge
New in version 17
PDFMerge
PDFMerge
Merges 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.
Versions 17 and later
PDFMergeWithPassword
New in version 17
PDFMergeWithPassword
PDFMergeWithPassword
Merges several existing and password-protected PDF files into a single PDF file.
Versions 14 and later
PDFNumberOfPages
New in version 14
PDFNumberOfPages
PDFNumberOfPages
Returns the total number of pages found in a PDF file.
Versions 24 and later
PDFPassword
New in version 24
PDFPassword
PDFPassword
Protects a PDF document with a password.
Versions 14 and later
PDFToText
New in version 14
PDFToText
PDFToText
Extracts the text found in a PDF file.
Versions 25 and later
WINDEV
Advanced operations on PDF files
To handle more simply the content of a PDF file, WLanguage offers different types of variables:
Versions 25 and later
pdfDocument
New in version 25
pdfDocument
pdfDocument
The pdfDocument type is used to find out all the advanced characteristics of a PDF file loaded in memory.
Versions 25 and later
pdfPage
New in version 25
pdfPage
pdfPage
The pdfPage type is used to define all the advanced characteristics of a page of a PDF document loaded in memory.
Versions 25 and later
pdfTextElement
New in version 25
pdfTextElement
pdfTextElement
The 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:
MyPDF is pdfDocument = PDFOpen("test.pdf")
 
MySecondPDF is pdfDocument = "C:\temp\examplePDF.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:
MyPDF is pdfDocument = "test.pdf"
 
FOR EACH DocumentPage OF MyPDF..Page
FOR EACH PageElement OF DocumentPage..TextElement
Trace(PageElement..Text)
END
END
With these types of variables, it is possible to delete or add pages to a document using array management functions (Add, Delete, ... ) 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")

Specific PDF functions allow managing pdfDocument variables:
Versions 25 and later
PDFClose
New in version 25
PDFClose
PDFClose
Closes the PDF file loaded in memory in a pdfDocument variable.
Versions 25 and later
PDFOpen
New in version 25
PDFOpen
PDFOpen
Opens a PDF document and loads it in a pdfDocument variable.
Versions 25 and later
PDFSave
New in version 25
PDFSave
PDFSave
Saves the content of a pdfDocument variable in a ".PDF" file.
Remark: Link with 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:
    MyPDFDoc is pdfDocument
    MyPDFDoc = PDF_PDFReader
New in version 25
WINDEV
Advanced operations on PDF files
To handle more simply the content of a PDF file, WLanguage offers different types of variables:
Versions 25 and later
pdfDocument
New in version 25
pdfDocument
pdfDocument
The pdfDocument type is used to find out all the advanced characteristics of a PDF file loaded in memory.
Versions 25 and later
pdfPage
New in version 25
pdfPage
pdfPage
The pdfPage type is used to define all the advanced characteristics of a page of a PDF document loaded in memory.
Versions 25 and later
pdfTextElement
New in version 25
pdfTextElement
pdfTextElement
The 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:
MyPDF is pdfDocument = PDFOpen("test.pdf")
 
MySecondPDF is pdfDocument = "C:\temp\examplePDF.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:
MyPDF is pdfDocument = "test.pdf"
 
FOR EACH DocumentPage OF MyPDF..Page
FOR EACH PageElement OF DocumentPage..TextElement
Trace(PageElement..Text)
END
END
With these types of variables, it is possible to delete or add pages to a document using array management functions (Add, Delete, ... ) 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")

Specific PDF functions allow managing pdfDocument variables:
Versions 25 and later
PDFClose
New in version 25
PDFClose
PDFClose
Closes the PDF file loaded in memory in a pdfDocument variable.
Versions 25 and later
PDFOpen
New in version 25
PDFOpen
PDFOpen
Opens a PDF document and loads it in a pdfDocument variable.
Versions 25 and later
PDFSave
New in version 25
PDFSave
PDFSave
Saves the content of a pdfDocument variable in a ".PDF" file.
Remark: Link with 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:
    MyPDFDoc is pdfDocument
    MyPDFDoc = PDF_PDFReader
WINDEV
Advanced operations on PDF files
To handle more simply the content of a PDF file, WLanguage offers different types of variables:
Versions 25 and later
pdfDocument
New in version 25
pdfDocument
pdfDocument
The pdfDocument type is used to find out all the advanced characteristics of a PDF file loaded in memory.
Versions 25 and later
pdfPage
New in version 25
pdfPage
pdfPage
The pdfPage type is used to define all the advanced characteristics of a page of a PDF document loaded in memory.
Versions 25 and later
pdfTextElement
New in version 25
pdfTextElement
pdfTextElement
The 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:
MyPDF is pdfDocument = PDFOpen("test.pdf")
 
MySecondPDF is pdfDocument = "C:\temp\examplePDF.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:
MyPDF is pdfDocument = "test.pdf"
 
FOR EACH DocumentPage OF MyPDF..Page
FOR EACH PageElement OF DocumentPage..TextElement
Trace(PageElement..Text)
END
END
With these types of variables, it is possible to delete or add pages to a document using array management functions (Add, Delete, ... ) 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")

Specific PDF functions allow managing pdfDocument variables:
Versions 25 and later
PDFClose
New in version 25
PDFClose
PDFClose
Closes the PDF file loaded in memory in a pdfDocument variable.
Versions 25 and later
PDFOpen
New in version 25
PDFOpen
PDFOpen
Opens a PDF document and loads it in a pdfDocument variable.
Versions 25 and later
PDFSave
New in version 25
PDFSave
PDFSave
Saves the content of a pdfDocument variable in a ".PDF" file.
Remark: Link with 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:
    MyPDFDoc is pdfDocument
    MyPDFDoc = PDF_PDFReader
Minimum version required
  • Version 14
This page is also available for…
Comments
Click [Add] to post a comment