Developer Tools
|
Office Productivity Applications
|
Platform-Agnostic APIs
|
Home | Online Demos | Downloads | Buy Now | Support | About Us | News | Working Together | Contact Us
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 .NET Developer Tools | |
---|---|
Gnostice Document Studio .NETMulti-format document-processing component suite for .NET developers. |
PDFOne .NETA .NET PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, and bookmark PDF documents in .NET applications. |
Our Delphi/C++Builder developer tools | |
---|---|
Gnostice Document Studio DelphiMulti-format document-processing component suite for Delphi/C++Builder developers, covering both VCL and FireMonkey platforms. |
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. |
Our Java developer tools | |
---|---|
Gnostice Document Studio JavaMulti-format document-processing component suite for Java developers. |
PDFOne (for Java)A Java PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, bookmark PDF documents in Java applications. |
Our Platform-Agnostic Cloud and On-Premises APIs | |
---|---|
StarDocsCloud-hosted and On-Premises REST-based document-processing and document-viewing APIs |
Privacy | Legal | Feedback | Newsletter | Blog | Resellers | © 2002-2024 Gnostice Information Technologies Private Limited. All rights reserved. |