Image loaded for Annotation is too small

A forum for questions or concerns related to the PDF-XChange Core API SDK

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
whoit
User
Posts: 269
Joined: Tue Jul 07, 2015 3:30 pm

Image loaded for Annotation is too small

Post by whoit »

Hi -

I'm experiencing a problem where I load any raster image from file and the resulting size is too small.

Specifically, I have a 100x100 pixel sample that is loaded as 72x72 and of course is too small
when placed onto a page.
This happens with every raster image I try - bmp, jpg, png.

I'm using the CoreAPI C# Sample code from Alex (https://github.com/tracker-software/PDF ... oreAPIDemo)
and looking at the values returned in this line:

Code: Select all

//LoadStampFromTheImageFile
si.GetSize(out nWidth, out nHeight);
Can you please address this?

Thanks,
Wayne
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Image loaded for Annotation is too small

Post by Sasha - Tracker Dev Team »

Hello Wayne,

Are you able to reproduce in the "6.4. Load stamp from image file" sample itself (24*24 image is being loaded there)?

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
whoit
User
Posts: 269
Joined: Tue Jul 07, 2015 3:30 pm

Re: Image loaded for Annotation is too small

Post by whoit »

Hi Alex -

OK, I did some more testing and this is what I found:

1) I have two sample images - A.png and B.png
A.png is 72x72 @ 72dpi
B.png is 80x31 @ 150dpi

2) When I use A.png as an IPXC_Image (for general placement on a page)

Code: Select all

IPXC_Image AImage = pDoc.AddImageFromFile("A.png");
it is returned as 72x72 pixels

When I use A.png as an Annotation Image loaded into a Collection, etc.:

Code: Select all

IAFS_File tmpFile = fsInst.DefaultFileSys.OpenFile(tmpName, openFileFlags);
it is also returned as 72x72 pixels.

3) However, if I use B.png in both scenarios,
when loaded as an IPXC_Image it is returned as 80x31 (the dpi is ignored)
but when loaded for an Annotation it is returned as 38x15 (the dpi is implemented)

So, my questions are:

A) Why does one method return the size without regard to dpi (IPXC_Image)
but the other method (Annotation) returns the size based on 72 dpi ?

B) How can I ensure that regardless of the "image loading method" that I use, I can get
consistent results without first knowing the image dpi?
For example, how can I ensure that both of the above sample images either adhere to
72dpi, or ignore the dpi ?

Thanks....
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Image loaded for Annotation is too small

Post by Sasha - Tracker Dev Team »

Hello Wayne,

This behavior occurs, because you have different measurement unit types - the IIXC_Page (like every raster) has pixel unit type. The DPI is used to convert pixels into the metrical units.
When you convert PNG into PDF, our converter takes the image DPI into an account and creates a content with corresponding size (and the size of the content is measured in points).
Thus 72 pixels with 72 DPI equal 1 inch (72/72) that equals 72 points for the first image.
As for the second image, 80 pixels with 150 DPI will equal 72*80/150 = 38.4 points.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
whoit
User
Posts: 269
Joined: Tue Jul 07, 2015 3:30 pm

Re: Image loaded for Annotation is too small

Post by whoit »

Hi Alex -

So the basic answer is that a raster file when used for Annotation is actually converted to a PDF format,
which then implements the original image DPI - Correct?
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Image loaded for Annotation is too small

Post by Sasha - Tracker Dev Team »

Hello Wayne,

Basically this is a short answer:
When you convert PNG into PDF, our converter takes the image DPI into an account and creates a content with corresponding size (and the size of the content is measured in points).
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply