Frequently Asked Question:
How to view a PDF in my Delphi application using DARenderPageToStream?
Question
How do I view a PDF in my Delphi application using the DARenderPageToStream function?
Answer
Yes, it's possible to view a PDF file in your Delphi application using the DARenderPageToStream function. I have included some Delphi code below which demonstrates how to do this.
var
MS: TMemoryStream;
fh, ph, SelectedPage, DPI: Integer;
begin
with PDFLibrary do
begin
SelectedPage := 1;
DPI := 72;
fh := DAOpenFileReadOnly(OpenDialogPDF.FileName, '');
ph := DAFindPage(fh, SelectedPage);
MS := TMemoryStream.Create;
DARenderPageToStream(fh, ph, 0, DPI, MS);
MS.Seek(0, soFromBeginning);
DAViewImage.Picture.Bitmap.LoadFromStream(MS);
MS.Free;
DACloseFile(fh);
end;
end;
Please note: the DARenderPageToStream function can only be used with Delphi.