1. Technology

TQPDF - Delphi Wrapper for the QPDF Library

Including an Open Source PDF Linearization Delphi Application

By

TQPDF PDF Linearizer

TQPDF PDF Linearizer

TQPDF PDF Linearizer

Portable Document Format (PDF) is an open, de facto, electronic publishing standard, created by Adobe Systems Incorporated. PDF is a worldwide standard for electronic documents.

If you need to create, edit and manipulate PDF documents from your Delphi applications, there are quite a few libraries you can choose from: PDF managing tools for Delphi.

What if you are *only* looking for a way to inspect and manipulate the structure of PDF files? What if your PDF needs are not to create new PDF documents? What if you are not interested in bookmarks, outlines, annotations, etc.

What if you "only" need to know the version of the PDF, if it is encrypted, if it is linearized (optimized for "Fast Web View" access). What if you only want to put a password on a PDF or alter document permissionsf...

QPDF - A PDF-To-PDF Structural, Content-Preserving Tool

I have a Delphi application that needs to "validate" existing PDF documents. One task is to get (and optionally change) the version of the PDF document, check if it is password protected in any way and check if it is optimized for fast web view (and optimize if needed).

I did try a few native Delphi PDF tools but was unlucky - to find one that does it all.

After searching the Internet for a PDF library I could use, I've stumbled on an open source C++ QPDF - a command-line program that does structural, content-preserving transformations on PDF files.

As described on the QPDF project's web site, QPDF is a C++ library and set of programs that inspect and manipulate the structure of PDF files. It can encrypt and linearize files, expose the internals of a PDF file, and do many other operations useful to end users and PDF developers.

Bingo! This is what I am looking for. But, :(, it's a C++ library and I need to use it in Delphi. Also, it was originally created to be used on UNIX/UNIX-like systems, not on Windows.

To cut a long story short, I've contacted the author, Jay Berkenbilt, asking him to produce a (Windows) DLL I could call from my Delphi code. Jay found this idea interesting and after a few months a DLL was created exporting functions I was able to call from my Delphi application.

To make it easy for me to work with the functions from the DLL I've coded a Delphi wrapper class: TQPDF.

Note: QPDF is not a PDF content creation library, a PDF viewer, or a program capable of converting PDF into other formats. In particular, QPDF knows nothing about the semantics of PDF content streams. If you are looking for something that can do that, you should look elsewhere. However, once you have a valid PDF file, QPDF can be used to transform that file in ways perhaps your original PDF creation can't handle. For example, programs generate simple PDF files but can't password-protect them, web-optimize them, or perform other transformations of that type.

TQPDF - Delphi wrapper for QPDF.DLL

QPDF.DLL defines a basic "C" API for qpdf. It provides access to a subset of the QPDF library's capabilities to make them accessible to callers who can't handle calling C++ functions or working with C++ classes.

TQPDF Delphi class wraps the DLL in a Delphi object.

You can get the TQPDF source code from QPDF' web site.

Also, I've written a sample demo application to linearize (optimize for fast web view) existing PDF documents using the TQPDF class. PDF Linearizer source code is also available on the QPDF's web site.

  1. About.com
  2. Technology
  3. Delphi
  4. Best Components and Tools
  5. TQPDF - Delphi Wrapper for the Open Source QPDF C++ Library

©2014 About.com. All rights reserved.