Print Page | Close Window

Newbe Question

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=1134
Printed Date: 31 Jan 26 at 11:52AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Newbe Question
Posted By: RhoTu
Subject: Newbe Question
Date Posted: 06 Jul 09 at 9:58PM
Can anyone explain why the following code gives me a 'range check' error?  Test program has a TImage and a TButton.  If I issue the SetFillColor or the DrawBox functions the error occurs upon the RenderPageToDC(dpi,currPage,image1.Canvas.Handle) call.
 
procedure TForm1.Button1Click(Sender: TObject);
var
  qp:TMyQuickPDF;
  currPage,dpi:integer;
begin
  qp:=TMyQuickPDF.create; // unLockKey called in TMyQuickPDF.create after inherited create
  currpage:=qp.SelectedPage;
  dpi:=screen.PixelsPerInch;
  qp.SetPageDimensions(11*dpi,8.5*dpi);
//  qp.SetFillColor(0.8,0.1,0.1);
  qp.SetTextColor(0.01,0.01,0.9);
//  qp.DrawBox(1*dpi,1*dpi,4*dpi,1*dpi,0);
  qp.DrawTextBox(1*dpi,1*dpi,4*dpi,1*dpi,'This is a Test',0);
  qp.RenderPageToDC(dpi,currPage,image1.Canvas.Handle);
  freeAndNil(qp);
end;
 
TIA
 
RT
 



Replies:
Posted By: Ingo
Date Posted: 06 Jul 09 at 10:08PM
Hi What's in dpi?



Posted By: RhoTu
Date Posted: 06 Jul 09 at 10:11PM
Screen.PixelsPerInch=96


Posted By: Ingo
Date Posted: 07 Jul 09 at 5:47AM
Sorry... i didn't see it ;-)
What are the returning values of your functions?
result := QP.SetPageDimensions(...
result2 := QP.DrawBox(...
Perhaps then you see where's the prob.
If SetPageDimensions doesn't work then (later) your DrawBox getting out of range...
Something like this ...

Cheers, Ingo


Posted By: DELBEKE
Date Posted: 07 Jul 09 at 7:26AM
You should also set the orgin with
Qp.SetOrigin(1); //Origin at top/left


Posted By: RhoTu
Date Posted: 07 Jul 09 at 2:54PM
Sorry, none of the suggestions work.  I still get no '0' returns, yet I get the range check error but not all of the time.  Using D7 and VISTA64.  Can someone with Delphi see if they get the error as well?
 
 
procedure TForm1.Button1Click(Sender: TObject);
var
  qp:TMyQuickPDF;
  currPage,dpi:integer;
  i:integer;
begin
  try
    qp:=TMyQuickPDF.create; // unLockKey called in TMyQuickPDF.create after inherited create
    if 0=qp.SetOrigin(1)then
      showMessage('result: '+intToStr(i));
    currpage:=qp.SelectedPage;
    dpi:=screen.PixelsPerInch;
    if 0=qp.SetPageDimensions(11*dpi,8.5*dpi) then
      showMessage('result: '+intToStr(i));
    if 0=qp.SetTextColor(1,1,1) then
      showMessage('result: '+intToStr(i));
    if 0=qp.SetFillColor(0.2,0.4,0.1) then
      showMessage('result: '+intToStr(i));
    if 0=qp.DrawBox(1*dpi,1*dpi,4*dpi,1*dpi,2) then
      showMessage('result: '+intToStr(i));
    if 0=qp.DrawTextBox(1*dpi,1*dpi,4*dpi,1*dpi,'This is a Test',0) then
      showMessage('result: '+intToStr(i));
    if 0=qp.RenderPageToDC(dpi,currPage,image1.Canvas.Handle) then
      showMessage('result: '+intToStr(i));
  except on e:exception do
    showMessage(e.Message);
  end;
  freeAndNil(qp);
end;
 


Posted By: Ingo
Date Posted: 07 Jul 09 at 4:07PM
Perhaps you should check if the value in dpi is the correct one?


Posted By: ukobsa
Date Posted: 08 Jul 09 at 8:30AM

What is the first message that you get? Note that getting back zero indicates an error while not zero indicates success!

What is the value of curPage? And how is TMyQuickPDF defined? Is there any additional code in it. And what happens when after setting the page dimensions you try to read them again? Are the values right?

best regards,

Ulrich




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