Print Page | Close Window

How do I use QuickPDF in Lazarus?

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=3708
Printed Date: 03 May 24 at 2:14AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: How do I use QuickPDF in Lazarus?
Posted By: RedOctober2018
Subject: How do I use QuickPDF in Lazarus?
Date Posted: 13 May 19 at 3:11AM
I remember reading about how to do this in one of the QuickPDF manuals but cannot find it now.  It was just a short one page instruction that showed what to include in the USES clause, and how to create the QuickPDF object, and unlock it, ready for use.  That is what I need now.

Task:
Convert old Delphi X3 application to Lazarus 1.8.4  The old app uses QuickPDF v10.13 extensively.


Current Progress:
I was able to successfully register both the 32 bit and 64 bit DLLs using the following .bat file:

<pre>
c:
cd\
cd "C:\Program Files (x86)\Debenu\PDF Library\ActiveX"
echo.
regsvr32 DebenuPDFLibraryAX1013.dll
echo.
cd\
cd "C:\Windows\SysWOW64"
regsvr32 "C:\Program Files (x86)\Debenu\PDF Library\ActiveX\DebenuPDFLibrary64AX1013.dll"
echo.
</pre>


OS Platform:
Windows Server 2016

QuickPDF is a great product and I want to use it in the newly converted app, so as to give our customer the same .pdf viewing experience and minimize the conversion pain on me and my dev team.

Thanks in advance to anyone who can provide some help.









Replies:
Posted By: Ingo
Date Posted: 13 May 19 at 8:02AM
Hi,


here's a link to a piece of Lazarus-code to have a look on:
http://www.quickpdf.org/forum/freepascal-lazarus-and-quickpdf_topic1825.html

If you're using the dll-version of QuickPDF there shouldn't raise problems as well.



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



Posted By: RedOctober2018
Date Posted: 13 May 19 at 2:56PM
Hi, Thanks Ingo.  I saw that thread during my most recent search for an answer to my question.  However, I do remember there was a different code snippet in an official QuickPDF manual that was more recent than that 2011 thread.  I recall it did not use a variant.  It used an ActiveX instead.  It's the usage of QuickPDF under ActiveX I guess I shd be looking for.


Posted By: RedOctober2018
Date Posted: 13 May 19 at 3:49PM
I followed the instructions here and got the ActiveX component to install into the tool bar.

http://wiki.lazarus.freepascal.org/LazActiveX" rel="nofollow - http://wiki.lazarus.freepascal.org/LazActiveX


Posted By: RedOctober2018
Date Posted: 13 May 19 at 9:54PM
Still having a problem.  I was able to install the ActiveX wrapper to create a component for QuickPDF, but I'm unable to get it to render to a TImage.  The component loads the file (I proved it by saving to a file with a different name), but it refuses to render to my TImage so I can see it.  My Image component is always blank.



Here is my code:

function TfrmMain.TempRenderPDFPage(const qwkpdf_axl: TAxcPDFLibrary; const fnm: String; const img: TImage; const sbx: TScrollBox; const pg: Integer; const zm: Integer; var err_msg: String): Boolean;
var
  vch: Variant;  // Variant containing the Canvas Handle
  bmp: TBitmap;
  dpi: Integer;
begin
  Result := True;
  err_msg := '';

  if not UnlockedOK(qwkpdf_axl) then  // Unlock always works
    begin
      Result := False;
      err_msg := 'Unable to unlock QuickPDF ActiveX';
      Exit;
    end;

  ReleasePdfImg(img);  // This just sets the image picture.bitmap to null

  dpi := 92;

  if Assigned(qwkpdf_axl) then
    begin
      bmp := nil;
      try
        bmp := TBitmap.Create;
        img.Picture.Assign(bmp);
        vch := bmp.Canvas.Handle;

        Result := (qwkpdf_axl.OleServer.LoadFromFile(fnm, '') = 1);
        if not Result then
          begin
            err_msg := 'Unable to load PDF Viewer from file: ' + fnm;
            Exit;
          end;

        Result := (qwkpdf_axl.OleServer.RenderPageToDC(dpi, pg, vch) = 1);
        img.Canvas.Draw(0, 0, bmp);  // Not sure if this is correct.  The example just says "Canvas.Draw" as if it's referring to the main form, but that didn't work, so I'm trying img.Canvas, but that doesn't work either.
        if not Result then
          begin
            err_msg := 'Unable to render image from QuickPDF ActiveX';
            Exit;
          end;
      finally
        bmp.Free;
      end;
    end;
end;



Posted By: RedOctober2018
Date Posted: 14 May 19 at 12:41AM
I found that the problem is that the bmp must be given a width and height or else it's zero for both and nothing will be drawn.  

http://wiki.freepascal.org/Developing_with_Graphics#Working_with_TBitmap_and_other_TGraphic_descendents" rel="nofollow - http://wiki.freepascal.org/Developing_with_Graphics#Working_with_TBitmap_and_other_TGraphic_descendents

Now working on trying to get the TBitmap height and width to accept the width and height of the page in the .Pdf file.  (one is long, the other is a double)



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