?
Solved

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

Posted on 2009-05-05
2
Medium Priority
?
571 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 2000 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

PaperPort (http://www.nuance.com/for-individuals/by-product/paperport/index.htm) is among the most important applications that I run on my Windows computers. I use it every day, for nearly all of my document and photo scanning, as well as most of my…
PaperPort has a feature called the "Send To Bar". It provides a convenient, drag-and-drop interface for using other installed software, such as Microsoft Office. However, this article shows that the latest Office 2016 apps (installed with an Office …
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 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…

770 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