PDF pixel calculation in modelspace

PDF pixel calculation in modelspace

Satish_Rajdev
Advocate Advocate
990 Views
2 Replies
Message 1 of 3

PDF pixel calculation in modelspace

Satish_Rajdev
Advocate
Advocate

Hello,

 

I’ve created a program which exports PDF (A3 paper size) from modelspace of a drawing which has 1 line object. My next task is I want to get pixels(of PDF) of start point of line object, Is there a way to calculate pixels for A3 paper size in modelspace?

 

Thanks you!

 

Regard,

Satish

Best Regards,
Satish Rajdev


REY Technologies | Linked IN | YouTube Channel


 

0 Likes
Accepted solutions (1)
991 Views
2 Replies
Replies (2)
Message 2 of 3

roland.r71
Collaborator
Collaborator
Accepted solution

@Satish_Rajdev wrote:

Hello,

 

I’ve created a program which exports PDF (A3 paper size) from modelspace of a drawing which has 1 line object. My next task is I want to get pixels(of PDF) of start point of line object, Is there a way to calculate pixels for A3 paper size in modelspace?

 

Thanks you!

 

Regard,

Satish



Pixels?

If you mean "dots"... it >might< be possible, but not so easy (& don't ask about accuracy)

First of all, you need the Plot scale & DPI (Dots Per Inch) setting used for plotting the PDF.

 

Lets say you use "1 inch = 1 unit" (a line of 10 units = 10 inch)

& a DPI of 300 (300 dots per Inch)

& your start point is 2 drawing units from the left border

 

Thats: 2x300=600 dots from the left "edge".

However, you might be dealing with a "non-printable area" (white border on papers edge, you can not print on), so you need to add the distance to it. (usually like 5 mm, or 0.2 inch (= 600+60)

You might be using a plot offset too, so you will need to add that as well.

 

As printing is NOT accurate to the mm (is ~12 dots each with 300DPI), the calculated distance is only a rough approximation.

Message 3 of 3

Satish_Rajdev
Advocate
Advocate

Thank you so much Roland for this great explanation and it has helped to solve my problem which was pending from last 2 week.

 

I wasn’t aware of Autocad Unit and DPI relation and that’s where I was getting stuck. And your post made it clear then. I’m not using non-printable area and all offsets are 0 of plot – so my pixels are matching exactly with PDF now.

 

Adding AutoCAD unit to pixel conversion function here as it may help somebody in future.

 

(defun unit2pixel (unit scale dpi)
(* (/ (/ unit scale) 25.4) dpi)
)

Thank you again!

 

Best Regards,
Satish Rajdev


REY Technologies | Linked IN | YouTube Channel


 

0 Likes