Print Page | Close Window

PageCount not working

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=1679
Printed Date: 16 Dec 25 at 9:14PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: PageCount not working
Posted By: pmaltais
Subject: PageCount not working
Date Posted: 14 Dec 10 at 8:00PM
Hi,

I load PDF documents wich contain more than one page. PageCount always returns 1. I'm using LoadFromStream. What am I missing?

Note that further in the code I display the document in a PDF Viewer and the document is perfectly displayed. 

Here is my code listing:

// oDocument is a business object containing the PDF stream and other data related to it...
  try
    sLicence := 'my_reg_key';
    myPDFLibCtrl := TQuickPDF0722.Create();
    if (myPDFLibCtrl.UnlockKey(sLicence) = 1) then
    begin
      myPDFLibCtrl.LoadFromStream(oDocument.fileStream);
      oDocument.numberOfPages := myPDFLibCtrl.PageCount;
      Result := SaveNewDocument(oDocument);
    end
    else
    begin
      ShowMessage('Quick PDF Library: Invalid licence.');
    end;
  finally
    if Assigned(myPDFLibCtrl) then
    begin
      myPDFLibCtrl.Free();
      myPDFLibCtrl := nil;
    end;
  end;



Thanks for your help.

Patrick Maltais, programmer



Replies:
Posted By: pmaltais
Date Posted: 14 Dec 10 at 8:54PM
I have found the problem. The Stream must be repositionned to its beginning. I added the line

oDocument.fileStream.Seek(0, soFromBeginning);

just before the LoadFromStream call and it works perfectly.

Thanks


Posted By: Rowan
Date Posted: 15 Dec 10 at 1:00PM
Thanks for sharing. Useful tip.



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