Print Page | Close Window

RenderPageToFile problem with an image

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=3806
Printed Date: 28 Apr 24 at 8:55PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: RenderPageToFile problem with an image
Posted By: Ingo
Subject: RenderPageToFile problem with an image
Date Posted: 21 Apr 20 at 10:09PM
Hi :)

now i'm "on the other side" - hoping there's somebody out there to help ;-)
I have invoices made by HP Exstream, PDF version 1.3, no encryption.
On each page there's a coloured logo in the top area.
If i render a page with 72 dpi to jpg the logo remains in the top area of the created image.
If i render the same page with 100 dpi to jpg the logo is in the bottom area of the created image.
If i render the same page with 150 dpi to jpg the logo is in the middle of the created image.
With 300 dpi the logo is between middle and top...
I can't separate or extract this logo as an image nor i can separate it on a single layer.

First i've thought: No problem... CombineContentStreams and NormalizePage will fix it.
But both functions are without any effects :(

After LoadFromFile i'm doing:
        If QP.EncryptionStatus > 0 Then
           QP.Decrypt;
        QP.SetOrigin(1);  //  oben, links
        QP.CombineContentStreams;
        QP.NormalizePage(0);

I'm using QuickPDF 17.11 with Delphi XE5.
My project is compiled as 32 bit.

I can't publish the relevant invoices cause they are from a customer.



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




Replies:
Posted By: tfrost
Date Posted: 22 Apr 20 at 7:34PM
Have you tried a different renderer, or PDFIUM?  What happens if you try converting it to image in some other PDF utility, just for comparison purposes - do they also get it wrong?


Posted By: Ingo
Date Posted: 22 Apr 20 at 9:35PM
Hi,

i've changed the code to RenderPageToStream but with no success.
I'll try using PDFium...




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



Posted By: Ingo
Date Posted: 22 Apr 20 at 10:16PM
Hi,

Now i've linked to PDFium.
I've downloaded the dll from github.
The dll is in my app-path.
Variable selren shows me a 4 - so PDFium is selected.
If i set 72 as dpi the resulting image is 9 kb but it's completely blank/white.
If i set 200 as dpi the resulting image is 61 kb but it's completely blank/white.


  QP := TDebenuPDFLibrary1711.Create;
  try
    okay := QP.LoadFromFile(FName, '');

    QP.SetPDFiumFileName('pdfium.dll');
    selren := QP.SelectRenderer(4);

//  ShowMessage(IntToStr(selren));

    If QP.EncryptionStatus > 0 Then
      QP.Decrypt;
    QP.CombineContentStreams;
    QP.NormalizePage(0);

    Try
      result := QP.RenderDocumentToFile(dpi, 1, 1, 1, Pchar(target));
//    ShowMessage(IntToStr(QP.LastErrorCode) + ' / ' + IntToStr(result));
    Finally
    End;

  finally
    if (QP.PageCount > 0) then
      QP.Free;
  end;



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



Posted By: Ingo
Date Posted: 23 Apr 20 at 10:54PM
If i'm doing only a preview on an image component then it works fine and the graphical elements from the invoice are always on the right position and it doesn't matter which zoom factor (dpi) i'm using:

procedure TForm11.SpeedButton1Click(Sender: TObject);
var ms          : TMemoryStream;
    jpg         : TJPEGImage;
    test_stream : TMemoryStream;
begin
   if ( zoom < 300 ) then
      zoom := zoom + 10;
   QP  := TDebenuPDFLibrary1211.Create;
   try
      QP.LoadFromFile(Edit1.text, '');
      If ( QP.EncryptionStatus > 0 ) Then
         QP.Decrypt;
      QP.CombineContentStreams;
      test_stream := TMemoryStream.Create;
      QP.RenderPageToStream(zoom,page,1,test_stream);
   finally
      QP.Free;
   end;
   try
      test_stream.Seek(0,0);
      jpg := TJPEGImage.Create;
      jpg.LoadFromStream (test_stream);
      Form11.Image1.Picture.Assign(jpg);
   finally
      test_stream.Free;
      jpg.Free;
   end;
end;



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



Posted By: Ingo
Date Posted: 23 Apr 20 at 11:03PM
a sample gives me a rendered jpg-file with 134 kb and a blank page.
If i resave it with IrfanView then i've a jpg with only 51 kb (i think better compression with only white pixels).
So i think in the initial blank image there is something unvisible?

 


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



Posted By: Ingo
Date Posted: 28 Apr 20 at 5:17PM
The main prob with the confused image objects after rendering with a new dpi value still exists.
The blank page while rendering via PDFium to an imagefile with QP 17.11 is solved while using the old version 14.11 ;-)



-------------
Cheers,
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