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 - Problem with a PDF file and DrawImage
  FAQ FAQ  Forum Search   Register Register  Login Login

Problem with a PDF file and DrawImage

 Post Reply Post Reply
Author
Message
tropenix View Drop Down
Beginner
Beginner


Joined: 11 Mar 12
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote tropenix Quote  Post ReplyReply Direct Link To This Post Topic: Problem with a PDF file and DrawImage
    Posted: 13 Mar 12 at 6:42PM
I'm testing quickpdf activex with VB6 before to buy.
With same PDF files (generated from Crystal report export to pdf) the DrawImage function does not work correctly.
The image is inserted with very small dimensions, as well as with DrawText function
why?


ORIGINAL PDF
http://www.gibelsoftware.it/referto.pdf

MODIFIED PDF
http://www.gibelsoftware.it/refertoout.pdf


thanks



Back to Top
edvoigt View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 Mar 11
Location: Berlin, Germany
Status: Offline
Points: 111
Post Options Post Options   Thanks (0) Thanks(0)   Quote edvoigt Quote  Post ReplyReply Direct Link To This Post Posted: 13 Mar 12 at 8:24PM
Hi,

I see in your second PDF near to lower left corner a small image.

But without seeing your code snippet nobody may help you.

Inside the refertoout.pdf I see no trace of drawing with QuickPDF.


Cheers,

Werner
Back to Top
tropenix View Drop Down
Beginner
Beginner


Joined: 11 Mar 12
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote tropenix Quote  Post ReplyReply Direct Link To This Post Posted: 14 Mar 12 at 9:56AM

The small image is the image insert by code, but does not respect the coordinates and dimensions

    FP = QP.LoadFromFile(FileNameout, "")
    QP.SetOrigin 1
    QP.DrawText 100, 10, "PROVA DI INSERIMENTO TESTO"
    QP.SaveToFile (FileNameout)
   
    QP.LoadFromFile FileNameout, ""
    IM = QP.AddImageFromFile(App.Path + "\logoiq.JPG", 0)
    lWidth = QP.imageWidth()
    lHeight = QP.ImageHeight()
    npag = QP.PageCount
    For i = 1 To npag
      QP.SelectPage i
      QP.SelectImage (IM)
      QP.SetOrigin 1
      QP.DrawImage 100 , 100 , lWidth , lHeight
    Next i
    QP.SaveToFile (FileNameout)

thank tropenix

Back to Top
edvoigt View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 Mar 11
Location: Berlin, Germany
Status: Offline
Points: 111
Post Options Post Options   Thanks (0) Thanks(0)   Quote edvoigt Quote  Post ReplyReply Direct Link To This Post Posted: 14 Mar 12 at 10:28AM
Hi tropenix,

it is rather clear. You use QP.ImageWidth and QP.ImageHeight without thinking about the measurementunits. Both functions will give pixels. But inside your PDF you work with millimeters or points (default).

QP.DrawImage 100 , 100 , lWidth , lHeight

uses the pixelvalues (I guess 48x50 px) as point. A point is here defined as inch/72. An inch is 25.4 mm, so 48 points are 16.9 mm. If I see your refertoout.pdf in Adobe Reader, the image has big white borders, so it looks smaller, as it is. Not good for tests. And its posisition is not 100,100 from SetOrigin(1), which means topleft. It is so, because SetOrigin has to be used after Loadfromfile, origin is set for a document and not over boundaries for all of them.

What is to do? It depends only what you want. It's now your job, to calculate from pixelvalues to the wished scaling of images. Look to SetMeasurementUnits-function.

I wrote: Inside the refertoout.pdf I see no trace of drawing with QuickPDF.

I do not see too the text "PROVA DI INSERIMENTO TESTO" in . Because there SetOrigin is on right place, use a bigger y-value. The referencepoint is on baseline, not on top of text.


Cheers,

Werner
Back to Top
tropenix View Drop Down
Beginner
Beginner


Joined: 11 Mar 12
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote tropenix Quote  Post ReplyReply Direct Link To This Post Posted: 14 Mar 12 at 11:07AM

Hi edvoigt,

My proble is:

I merge any pdf document, and i must add text adn images on merged file.

the code tested add correctly text and image on some pages but not in others
 
Back to Top
edvoigt View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 Mar 11
Location: Berlin, Germany
Status: Offline
Points: 111
Post Options Post Options   Thanks (0) Thanks(0)   Quote edvoigt Quote  Post ReplyReply Direct Link To This Post Posted: 14 Mar 12 at 12:08PM
Hi,

I did a look inside of refertoout.pdf. There are the internals generated from Drawtext and Drawimage.

BT
1 0 0 1 100 831 Tm
(PROVA DI INSERIMENTO TESTO)Tj
ET
 q
121.92 0 0 127 254 460 cm
/QuickPDFIm79863349 Do
Q

The text should be drawn sharp on the upper border which is at 841 points. So his height has to be not more than 10 points. Ok. But it is other.

As I zoom with Adobe Reader to 1600% I see your text and image down in lower left corner. So I got another idea about the error-source. Its not in your code, but in the PDF, you want to modify. To proof this, take another input-PDF (made not with the program wich produces referto.pdf). And it explains that you have the problem by random.

I had such effects with same PDFs, whith incorect commands inside. To be more sure against this, set all normally defaults directly before doing your output. This is as first font and its size and measureunits.

You have rather the same situation as a subroutine would use unallowed global values and after its call all goes wrong. Here is the programmer of the PDF-source the bad gay.

 
Cheers
Werner
 
Back to Top
edvoigt View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 Mar 11
Location: Berlin, Germany
Status: Offline
Points: 111
Post Options Post Options   Thanks (0) Thanks(0)   Quote edvoigt Quote  Post ReplyReply Direct Link To This Post Posted: 14 Mar 12 at 1:27PM
Hi,

here is a solution. Because the PDF has bad code inside, we try to correct it.

  QP.LoadFromFile('problematic.pdf','');
  QP.NormalizePage(0); // brings some "health" in the page
// the world is now ok again 
  QP.SetMeasurementUnits(0);                // unit mm
  QP.SetOrigin(1);
  QP.AddImageFromFile('blueFolder.bmp', 0);
  QP.DrawText(100, 10, 'This text should be at 100,10');
  QP.DrawImage(100,100, QP.ImageWidth, QP.ImageHeight);
  QP.SaveToFile('refer.pdf');

Normalizepage works with this pdf from you. But be careful.


Werner
Back to Top
tropenix View Drop Down
Beginner
Beginner


Joined: 11 Mar 12
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote tropenix Quote  Post ReplyReply Direct Link To This Post Posted: 14 Mar 12 at 7:30PM
Hi,
thanks for your replay.
 
I had correct all pages of my pdf.
Now position text and image are correctly
 
very good
 
thanks Tropenix
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