Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - RenderPageToFile problem with an image
  FAQ FAQ  Forum Search   Register Register  Login Login

RenderPageToFile problem with an image

 Post Reply Post Reply
Author
Message
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Topic: RenderPageToFile problem with an image
    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.



Edited by Ingo - 21 Apr 20 at 10:11PM
Cheers,
Ingo

Back to Top
tfrost View Drop Down
Senior Member
Senior Member


Joined: 06 Sep 10
Location: UK
Status: Offline
Points: 437
Post Options Post Options   Thanks (0) Thanks(0)   Quote tfrost Quote  Post ReplyReply Direct Link To This Post 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?
Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store