Developer Tools
|
Office Productivity Applications
|
Enterprise Solutions
|
|||||||||||||||||||||||







Yes, you can use PDFtoolkit to identify blank pages in a PDF document. The content extraction method TgtPDFDocument.GetPageElements can identify and extract PDF page elements in a specified page. The method returns the page elements in a special list of type TgtPDFPageElementList. You can loop through all pages in a document and check the count of the list returned by GetPageElements method in each iteration. When the count is zero, then the current page is blank. Here is how it is done.
program FindBlankPages;
{$APPTYPE CONSOLE}
uses
SysUtils,
gtCstPDFDoc,
gtPDFClasses,
gtExPDFDoc,
gtExProPDFDoc,
gtPDFDoc;
var
gtPDFDocument1: TgtPDFDocument;
gtPDFPageElementList1: TgtPDFPageElementList;
I: Integer;
begin
// Create a PDF document object
gtPDFDocument1 := TgtPDFDocument.Create(Nil);
try
// Load a document
gtPDFDocument1.LoadFromFile('doc_with_blank_pages.pdf');
// Check if the document is loaded
if gtPDFDocument1.IsLoaded then
// Sift through all pages in the document
for I := 1 to gtPDFDocument1.PageCount do
begin
// Load the list with all text and image elements in
// the current page
gtPDFPageElementList1
:= gtPDFDocument1.GetPageElements(I,
[etText, etimage],
muPixels);
// Check if a page has no text or image elements
if gtPDFPageElementList1.Count = 0 then
// We have a winner - a blank page!
Writeln('Searching page #'
+ IntToStr(i)
+ '... This page is BLANK.')
else
// The current page is not blank.
Writeln('Searching page #'
+ IntToStr(i)
+ '... This page has '
+ IntToStr(gtPDFPageElementList1.Count)
+ ' page/image elements.');
// Remember to clear the list
gtPDFPageElementList1.Clear;
end;
except on Err: exception do
Writeln('Error: ' + Err.Message);
end;
// Clean up
FreeAndNil(gtPDFPageElementList1);
gtPDFDocument1.Reset;
FreeAndNil(gtPDFDocument1);
Writeln('Press Enter key to exit.');
Readln;
end.
After you detect a blank page, you can as mentioned earlier write a "This page is intentionally left blank." message on it. Or, you can simply delete the page. Of course, with PDFtoolkit, you have more choices than that. Have fun.
---o0O0o---
| Our Developer Tools | |
|---|---|
eDocEngine VCLA Delphi/C++Builder component suite for creating documents in over 20 formats and also export reports from popular Delphi reporting tools. |
PDFtoolkit VCLA Delphi/C++Builder component suite to edit, enhance, view, print, merge, split, encrypt, annotate, and bookmark PDF documents. |
XtremePDFConverter VCLA Delphi/C++Builder component to intelligently convert PDF to user-friendly Word RTF documents. |
|
PDFOne .NETA .NET PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, and bookmark PDF documents in .NET applications. |
XtremeDocumentStudio .NETMulti-format document-processing component suite for .NET developers |
PDFOne (for Java™)A Java™ PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, bookmark PDF documents in Java™ applications. |
XtremeFontEngine (for Java)Java font engine to render glyphs from Type 1, Type 2 (CFF), and TrueType fonts |
| Our Office Productivity Applications |
|---|
Free PDF ReaderA free, fast, and portable application for viewing, printing and converting PDF documents. |
| Privacy | Legal | Feedback | Newsletter | Resellers | © 2002-2013 Gnostice Information Technologies Private Limited. All rights reserved. |
This site is best viewed on a screen with minimum resolution of 1152 x 864 pixels. Windows XP users are advised to use Microsoft ClearType Tuning for optimal experience. Also, please use the latest version of a standards-compliant browser such as Firefox, Opera, or Dragon (Chromium).