Solved

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

Posted on 2009-05-05
2
567 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

PaperPort is a popular document imaging/management product from Nuance Communications (http://www.nuance.com/). It is in widespread use by both individuals (http://www.nuance.com/for-individuals/by-product/paperport/index.htm) and businesses (http:/…
PaperPort 14.5 Patch 1 update is often not detected or downloaded automatically. This article provides direct download links to solve the problem for retail (non-bundled) versions of the Standard and Professional editions, as well as the Professiona…
This video is the second in a two-part series that discusses PaperPort's "Send To Bar" feature . The first video tutorial (http://www.experts-exchange.com/VP_207.html) explains the purpose of the Send To Bar, how to use it, and how to hide unwanted …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

695 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