Solved

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

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

This article discusses the PaperPort 14 Scanner Connection Tool, which Nuance provides at no charge in order to fix scanning problems in Windows 8. Furthermore, users of PaperPort 14 in Windows 7 and Windows 10 have reported that the tool works in t…
This article provides the solution to a question (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28674207.html) posed here at Experts Exchange. The asker of the question has many JPG images in many folders, and all of t…
Microsoft Office Picture Manager is not included in Office 2013. This comes as quite a surprise to users upgrading from earlier versions of Office, such as 2007 and 2010, where Picture Manager was included as a standard application. This video expla…
This video Micro Tutorial is the second 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 a…

747 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

12 Experts available now in Live!

Get 1:1 Help Now