Another possibility exists if you have the Developers Express PDFViewer component. The library has an API that converts a PDF to TIFF or PNG. Here is a working sample:
Uses
dxGDIPlusClasses, dxPDFDocument;
procedure TfrmMain.DisplayPDF(const Filename: string);
var
i: integer; // page counter
ndx: integer; // new image location in viewer
ADocument: TdxPDFDocument; // the loaded PDF document
ImgContainer: TdxSmartImage; // Temporary storage for converted pages
ImgStream: TMemoryStream; // Interface between temporary storage and image viewer
begin
if AnsiCompareText(ExtractFileExt(FileName), '.PDF') = 0 then
begin
Screen.Cursor := crHourGlass;
ADocument := TdxPDFDocument.Create;
ImgContainer := TdxSmartImage.Create;
ImgStream := TMemoryStream.Create;
try
ADocument.LoadFromFile(FileName);
// Convert the PDF placing all the pages in the SmartImage Container
// A scale of 4.5 renders good resolution - a higher scale requires more memory and performance suffers
if dxPDFDocumentExportToTIFF(ADocument, 4.5, ImgContainer, nil, ra0) then
begin
// Save the converted image to a stream as a TIFF file
ImgContainer.SaveToStreamByCodec(ImgStream, dxImageTIFF);
// Step through each page adding it to the image viewer
for i := 0 to ADocument.PageCount - 1 do
begin
// Reposition the stream to 0 since the SetImageFromStream method locates the page based on the SourceImageIndex value
ImgStream.Position := 0;
// Prepare viewer for a new image
ndx := imgMView.AppendImage;
// Load the page into the viewer at index ndx from the streams image at index i
imgMView.SetImageFromStream(ndx, ImgStream, i, ioTIFF);
end;
end;
finally
ImgStream.Free;
ImgContainer.Free;
ADocument.Free;
Screen.Cursor := crDefault;
end;
end;
end;
I don't have either of the two plugins that Nigel supports so I can't compare the performance between the methods.