Print Page | Close Window

pageWidth, DAGetPageWidth results

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=2671
Printed Date: 10 Mar 26 at 11:26PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: pageWidth, DAGetPageWidth results
Posted By: ginidat
Subject: pageWidth, DAGetPageWidth results
Date Posted: 14 Jun 13 at 5:24PM
Hello all!

I've problems to get the page width and height of different existing documents
of different page sizes (as Adobe Reader confirms).


Using PageWidth (with measure unit "Inch") I allways get 8.5
Using DAGetPageWidth I allways get 0.0

maybe there is something wrong in my code (Delphi XE2):


handle := fPDFLib.DAOpenFileReadOnly( fn, '' );
fPDFLib.SetMeasurementUnits( 2 );
if ( fPDFLib.SelectPage( 1 ) = 1 ) then
   docWidth := fPDFLib.PageWidth;

OR
docWidth := fPDFLib.DAGetPageWidth( handle, 1 );



Have anyone an idea what is going wrong?

Thank's!
Cheers, Ginidat



Replies:
Posted By: Ingo
Date Posted: 14 Jun 13 at 5:31PM
Hi Gini!

Please keep in mind never mix da- and non-da-functions.
A DALoad... isn't a real load so the non-da-function PageWidt won't get a correct result.

Cheers and welcome here,
Ingo



Posted By: AndrewC
Date Posted: 15 Jun 13 at 8:44AM

You need to be using the following code.  As Ingo mentions the DA functions should only be used with other DA functions.  

  fh := QP.DAOpenFile(fn, '');
  ph := QP.DAFindPage(fh, 1);
  width := QP.DAGetPageWidth(fh, ph);

You might find it easier to use the non-DA functions which also support much more functionality.

  rey := QP.LoadFromFile(fn, '');
  if (ret = 1) then
  begin
    QP.SelectPage(1);
    QP.SetMeasurementUnits(2);
    pageWidth := QP.PageWidth();
  end;

Also by default QPL always has a single 1 page document loaded in memory and this is why QP.PageWidth is returning 8.5.

You might find it useful to read parts of the Developer Guide PDF that comes with QPL.

Andrew.


Posted By: ginidat
Date Posted: 17 Jun 13 at 1:27PM
Hello Andrew, Ingo,

thank you for help!

Now it works.
I think my fault was not to use the function "DAFindPage".

Thank's again!

Ginidat



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