Print Page | Close Window

PDF-Preview with RenderPageToStream

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: Sample Code
Forum Description: Share Debenu Quick PDF Library sample code with other forum members
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=1044
Printed Date: 24 Apr 24 at 5:18PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: PDF-Preview with RenderPageToStream
Posted By: Ingo
Subject: PDF-Preview with RenderPageToStream
Date Posted: 26 Mar 09 at 2:29AM
Hi All!

This sample for the function RenderPageToStream you
can use as a starting point for a small pdf-viewer.
In this case you have to set a variable for "dpi" to
have zoom-functionality and for "page" (to have forward-
and previous-functions). This could it be in the first
step for you.

If you want to split a big pdf-document into single
pages you can use a similar variant of my sample with
the function RenderDocumentToFile.

For this sample you need a form-, image-, fileload-
and button-component - That's all.

The sample is written in Delphi/Pascal but i think it's
readable enough to use it in any other language.

Cheers, Ingo
 


unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Buttons, ExtCtrls, jpeg, QuickPDF0712;

// . . .

var
  Form1: TForm1;
  fstring, s      : String;
  page, pagecount : Integer;
  QP              : TQuickPDF0712;
  Test_Stream     : Tmemorystream;
  jpg             : TJpegImage;

implementation

{$R *.DFM}

// . . .

procedure Pages(fap: String);
begin

   jpg         := TJpegImage.create;
   Test_Stream := Tmemorystream.Create;

   QP  := TQuickPDF0712.Create; 
   try
      QP.UnlockKey('YourKeyShouldBeHere');
      QP.LoadFromFile(the_selected_pdf_document);
      If ( QP.Encrypted > 0 ) Then
         QP.Unencrypt;
//    dpi=72 (you shouldn't use more than 300
//    page=1 (The selected page number)
//    options=1 (1=jpg ... read in the documentation)
      QP.RenderPageToStream(72,1,1,test_stream);
   finally
      QP.Free;
   end;
   test_stream.Seek(0,0);
   jpg.LoadFromStream (test_stream);
   image1.Picture.Assign(jpg);
   test_stream.Clear;
end;
 



Replies:
Posted By: HNRSoftware
Date Posted: 09 Aug 15 at 3:06PM
I realize this is an old post, but your example is very useful.  I am dealing with a pdf file from an Architect containing a lot of 11"x17" drawings and diagrams that need to be extracted to a more useful size.  QuickPDF is doing a great job with this, but I am now trying to design a more general version of the same exercise.  What I am finding is that any particular page in the pdf can take 1-20 seconds to render to a useful resolution.  I notice that you recommend less than 300 dpi, but in my case, 600dpi and  higher can be useful and/or necessary, and works just fine.  We need to be able to examine details in the drawings by using the computer screen as a magnifying glass.  In detail, this is working fine, but I am having trouble estimating how long a render will take.  I will probably solve this by designing a cache system and accept the delay for the first render of a page, and then it will speed up for subsequent displays/zooms.  I am fascinated by the situation that individual pdf pages are in the several hundred kilobyte range, but that jpg (or a variety of other file formats) renderings are in the multiple megabytes.   As always, thanks for the useful forum.  Howard Richoux


Posted By: Ingo
Date Posted: 10 Aug 15 at 8:51PM
Hi Howard,

often the architect plans are completely embedded in the pdf and shown with the pdf dimension settings. So it could be more senseful to extract the image with "SaveImageListItemDataToFile" out of the pdf to have the full quality...

Cheers, Ingo


-------------
Cheers,
Ingo




Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk