Print Page | Close Window

Image doesn't add for each pdf-file

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=3107
Printed Date: 01 May 24 at 3:34PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Image doesn't add for each pdf-file
Posted By: Damir
Subject: Image doesn't add for each pdf-file
Date Posted: 26 Apr 15 at 2:00PM
Hi, experts!

I use the next code (VBScript) to add image inside the pdf-file:

Dim ClassName
Dim LicenseKey
Dim FileName

ClassName = "DebenuPDFLibrary64AX1114.PDFLibrary"
LicenseKey = "****" ' INSERT LICENSE KEY HERE
FileName = "C:\Users\damir\Downloads\111\22.pdf"
Pic = "C:\Users\damir\Downloads\111\sign.png"

Dim DPL
Dim Result

Set DPL = CreateObject(ClassName)
Result = DPL.UnlockKey(LicenseKey)

If Result = 1 Then
DPL.LoadFromFile FileName , ""
d = DPL.AddImageFromFile(Pic, 0)

lWidth = DPL.ImageWidth
lHeight = DPL.ImageHeight

Call DPL.SelectPage(1)
h = DPL.PageHeight
w = DPL.PageWidth
Call DPL.DrawImage(w/2, h/2, lWidth, lHeight)
 
Call DPL.SaveToFile("C:\Users\damir\Downloads\111\SignedFile.pdf")

End If
Set DPL = Nothing

It's works great, but not for each pdf-file. I can understand the reason. The string "d = DPL.AddImageFromFile(Pic, 0)" doesn't return me "0" Non-zero, so it looks like imade adding works. Maybe the reason it's a lot of layouts. Maybe image is under the layout.
Please help me!
https://drive.google.com/open?id=0B7WQynP0e6CrUi1WRTQ4VmM1WDg&authuser=0" rel="nofollow - https://drive.google.com/open?id=0B7WQynP0e6CrR1JkVUFmOFloRHc&authuser=0
https://drive.google.com/open?id=0B7WQynP0e6CrR1JkVUFmOFloRHc&authuser=0" rel="nofollow - https://drive.google.com/open?id=0B7WQynP0e6CrUi1WRTQ4VmM1WDg&authuser=0
https://drive.google.com/open?id=0B7WQynP0e6CrVmFXelFrSzA2Nzg&authuser=0" rel="nofollow - https://drive.google.com/open?id=0B7WQynP0e6CrVmFXelFrSzA2Nzg&authuser=0



Replies:
Posted By: erico
Date Posted: 27 Apr 15 at 6:25PM
You may want to edit your post and remove your license key.


-------------
Eric O


Posted By: Damir
Date Posted: 27 Apr 15 at 6:55PM
Edited. I solved the problem. I type the coordinates incorrect.


Posted By: AndrewC
Date Posted: 06 May 15 at 8:18AM
Damir,

The ImageWidth and ImageHeight functions return the width and height of the image in pixels.

To get the DPI of an image you need to use ImageHorizontalResolution and ImageVerticalResolution.  With these values you can calculate the true width and height of the image if drawn at a 1:1 ratio.

This is important because all of the Drawing functions are specified using the current measurement system set which could be points, mm or inches.  Using the pixel width / height returned by ImageWidth / ImageHeight will result in possibly strange results. 

This is why you are forced to use w/2 and h/2 in order to get a smaller image.

Here is the correct code to add and draw an image at a 1:1 ratio.

http://www.quickpdf.org/forum/creating-a-multi-page-pdf-from-a-multipage-tiff_topic2125.html

Andrew


Posted By: Damir
Date Posted: 06 May 15 at 8:30AM
Andrew, thank you for answering. I'll test "Image...Resolution" method in my code. I really have a trouble with "strange results", wich I get via "ImageWidth(Height)" method. Thank you for example too



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