Solved

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

Posted on 2009-05-05
2
558 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

PDF files have been in the limelight due to its unmatched features.  Personal documents, emails, business reports and eBooks are all converted into PDF files owing to peerless features provided by it. Adding watermark to a PDF file is a method to se…
Inserting page numbers in Portable Document Files not only enhances manageability but also makes them look professional. With numbered pages, the file appears more organized and it becomes easier to search for a particular page. The size and the vol…
This video Micro Tutorial is the first in a two-part series that shows how to create and use custom scanning profiles in Nuance's PaperPort 14.5 (http://www.experts-exchange.com/articles/17490/). But the ability to create custom scanning profiles al…
In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

911 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

21 Experts available now in Live!

Get 1:1 Help Now