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







In an earlier article, we showed two ways of converting PDF to images. In both cases, you had to use an external GDI+ library. In Version 4 of PDFtoolkit, one of the GDI libraries is now used internally and export to image formats has been simplified.
In Version 4, a new method TgtPDFDocument.SaveAsImage() has been introduced. You specify the format using the TgtImageType argument and the image settings in the TgtImageProperties argument.
public procedure SaveAsImage( aPageRange: String; aImagetype: TgtImageType = itBitmap; aLocation: String = ''; aFileNamePrefix: String = ''; aImageProperties: TgtImageProperties = nil ); public TgtImageType = ( itBitmap, itJPEG, itEMF, itSinglePageTIFF, itMultiPageTIFF );
If you have installed Version 4, just create a new VCL forms application project, drop a button, use this code example. You will see how easy it is to export PDF pages to images.
unit Export_PDF_To_Images;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtDlgs,
gtPDFDoc, gtExPDFDoc, gtCstPDFDoc, gtPDFUtils, gtExProPDFDoc;
type
TForm3 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
{$R *.dfm}
procedure TForm3.Button1Click(Sender: TObject);
var
gtPDFDocument1: TgtPDFDocument;
OpenTextFileDialog1: TOpenTextFileDialog;
I, N: Integer;
begin
OpenTextFileDialog1 := TOpenTextFileDialog.Create(nil);
gtPDFDocument1 := TgtPDFDocument.Create(nil);
OpenTextFileDialog1.Filter := 'PDF documents (*.pdf)|*.pdf';;
if OpenTextFileDialog1.Execute then begin
try
// Unload any previously loaded file
if gtPDFDocument1.IsLoaded then begin
gtPDFDocument1.Reset;
end;
// Make the user select a PDF document and load it
gtPDFDocument1.LoadFromFile(OpenTextFileDialog1.FileName);
// Export first two pages as JPEG images
gtPDFDocument1.SaveAsImage('1,2', itJPEG);
// Export first two pages as TIFF images
gtPDFDocument1.SaveAsImage('1,2', itSinglePageTIFF);
// Export first two pages as a single multi-page TIFF image
gtPDFDocument1.SaveAsImage('1,2', itMultiPageTIFF);
// Free IO resources
gtPDFDocument1.Reset;
except on Err:Exception
do begin
gtPDFDocument1.Reset;
ShowMessage('Sorry, an exception was raised. ' + Err.Classname + ':' + Err.Message);
end;
end;
end;
end;
end.
Gnostice DevTools Team member Ramnish has created an application for demonstrating how PDF-to-image export works.
---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).