Print Page | Close Window

Abstract error

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: General Discussion
Forum Description: Discussion board for Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=327
Printed Date: 17 May 24 at 9:33AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Abstract error
Posted By: cpri
Subject: Abstract error
Date Posted: 21 Feb 06 at 2:22AM

I want to use quickpdf to view some pdf files. So the first thing I used was RenderPageToFile and then save this image as a jpg. Then using a simple image loader I load the picture into my program This works fine. The bad thing about this approach is that I have to save a image to disk. To overcome this problem I used the function RenderPageToStream. (See code)

[code]

procedure TForm1.Button1Click(Sender: TObject);
var
 QP: TiSEDQuickPDF;
 Test_Stream:Tstream;
 JPEG : TJpegImage;

begin
 QP := TiSEDQuickPDF.Create;
 try

   QP.UnlockKey('');
   if QP.SetGDIPlusFileName('c:\winnt\system\gdiplus.dll')=0 then
    showmessage('Error');
   QP.DrawText(100, 500, 'Hello World!');
   QP.SaveToFile('c:\test.pdf');
//  QP.RenderDocumentToFile(75,1,1,1,'C:\test.jpg');
   Test_Stream:=Tstream.Create;
   QP.RenderPageToStream(75,1,1,test_stream);
   JPEG:=TJpegImage.create;

   JPEG.LoadFromStream(test_stream);
   image1.Picture.Assign(Jpeg);
   showmessage('done');
 finally
   QP.Free;
   test_stream.Free ;
 end;

end;

[code]

Now I get an "abstract error" when I tried to run the RenderPageToStream function.

 




Replies:
Posted By: Ingo
Date Posted: 21 Feb 06 at 5:04AM
Hi CPRI!

Please edit your sample...
!!! The Reg-Key !!!


Posted By: JanN
Date Posted: 21 Feb 06 at 5:13AM
I repeat: Please remove your Reg-Key from your post!


Now to your problem: You should use TMemoryStream or TFileStream instead of TStream. These two do not raise that error.


Posted By: cpri
Date Posted: 21 Feb 06 at 6:32AM

Ok sorry for the key. The idea was to skip this line in my code when pasting it to the forum but somehow I forgot (It won't happen again I promise).

I tried the TmemoryStream. but now I got a JPEG error #42. (this error is raised when I try to load the jpeg into image container)



Posted By: cpri
Date Posted: 21 Feb 06 at 7:28AM

Error fixed. It was due to the fact that the stream wasn't at the right position.

for those who are intresseted in the code here it is (without the reg key ;-))

procedure TForm1.Button1Click(Sender: TObject);
var
 QP: TiSEDQuickPDF;
 Test_Stream:Tmemorystream;
 JPEG : TJpegImage;

begin
 QP := TiSEDQuickPDF.Create;
 try

   QP.UnlockKey('....');
   if QP.SetGDIPlusFileName('c:\winnt\system\gdiplus.dll')=0 then
    showmessage('Error');
   QP.DrawText(100, 500, 'Hello World!');
   QP.SaveToFile('c:\test.pdf');
//  QP.RenderDocumentToFile(75,1,1,1,'C:\test.jpg');
   Test_Stream:=Tmemorystream.Create;
   QP.RenderPageToStream(75,1,1,test_stream);
   JPEG:=TJpegImage.create;
   test_stream.Seek(0,0);
   JPEG.LoadFromStream(test_stream);
   image1.Top :=0;
   image1.Left:=0;
   image1.Height :=jpeg.Height ;
   image1.Width :=jpeg.Width;
   image1.Picture.Assign(Jpeg);

 finally
   QP.Free;
   test_stream.Free ;
   JPEG.Free ;

 end;

 



Posted By: Ingo
Date Posted: 21 Feb 06 at 9:08AM
Hi Cpri!

Thanks for this...
You can put it in the sample section ;-)

Best regards,
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