Solved

How to convert PDF positions in points into Jpeg positions in pixels ?

Posted on 2009-05-05
2
560 Views
Last Modified: 2012-05-06
Hello,
let me explain by an example:
1) We have a PDF page which dimensions is 500,9 pt WIDTH by 715,6 pt HEIGHT
I have a lot of 'words' which i know the exact position in points (X,Y couple) within this page.

2) The target image is a JPEG which dimensions is 420 pixels WIDTH by 600 pixels HEIGHT.
This image ha been calculated from the PDF page, and is in 150dpi (I am not sure it matters).

3) I need to position correctly the words in the target JPEG image.
So I need to convert the (X,Y couple in points from the PDF) to the equivalent (X,Y couple in pixels in the JPEG image).

I know that the HEIGHT in the PDF is calculated from the bottom of the page.

If anyone has a magic formula, or explanations of how I should process to correctly position the 'words' in the target Jpeg, I would greatly appreciate.

Thanks in advance for your detailed answers
Best regards
Vincent
0
Comment
Question by:WARTELLE
2 Comments
 
LVL 44

Accepted Solution

by:
Karl Heinz Kremer earned 500 total points
ID: 24313299
I don't have a magic formula, but I can (try to) explain how it works:

One point is 1/72 of an inch. Your image has 150dpi, so every pixel is 1/150 of an inch. So in order to go from a position in the PDF space to a coordinate in your JPEG, you would do something like this:
Let's assume you have a position that is 100pt from the left edge, and 50pt up: (100/50)
pos_jpeg = pos_pt*150/72

So, we have for the x position in your JPEG 100*150/72 = 208.333, and for the y position 50*150/72 = 104.1667

Depending on how you work with your image, you may want to count the pixels from the top or the bottom, so you may have to subtract your y position from the total number of lines in you JPEG.

Does this make sense?


0
 

Author Comment

by:WARTELLE
ID: 24374249
I have finally found the remaining problem i had to face out.

In fact the points coordinates were computed taking into account the CropBox and not the MediaBox.
That means that the page dimensions (in points) shown in Acrobat cannot be used.

If you make your computation with the values given by the tool I used, I had to calculate the 'real' position according to the MediaBox, so substracting the delta between CropBox and MediaBox.

After that, your translation formula is correct.
Thanks very much for your help
Best regards
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I. Introduction In a previous article (http://www.experts-exchange.com/Web_Development/Document_Imaging/A_6537-PaperPort-Upgrade-How-to-download-and-install-updated-versions-of-PaperPort-11-and-12.html) (now deprecated), I discussed how to upgrad…
This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
This video is the first in a two-part series that discusses PaperPort's "Send To Bar" feature . This first video tutorial explains the purpose of the Send To Bar, how to use it, and how to hide unwanted items that are automatically created on it whe…
In this second video of the Xpdf series, we discuss and demonstrate the PDFimages utility, which, in a single command, is able to extract all the images from a PDF file and save each one in a separate image file (PBM, PPM, or JPG). Download and inst…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now