Developer Tools
|
Office Productivity Applications
|
Platform-Agnostic APIs
|
||||||||||||||||||||||||||







Home | Online Demos | Downloads | Buy Now | Support | About Us | News | Working Together | Contact Us
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 .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-2026 Gnostice Inc. All rights reserved. |