wxPdfDocument - convert pixels to millimeters

Talk here about issues with one of the components hosted at wxCode, or suggest features for it.
Post Reply
User avatar
cutecode
Super wx Problem Solver
Super wx Problem Solver
Posts: 425
Joined: Fri Dec 09, 2016 7:28 am
Contact:

wxPdfDocument - convert pixels to millimeters

Post by cutecode »

in function

Code: Select all

wxPdfDocument::Image 	( 	const wxString &  	file,
		double  	x,
		double  	y,
		double  	w = 0,
		double  	h = 0, 
x,y,w,h - are pixels, but a I want to draw an image using millimeters.

How to convert millimeters to pixels?
wx 3.1.6 win/mac/linux

regards,
Alexander Saprykin
https://v2.dental-soft.ru
utelle
Moderator
Moderator
Posts: 1125
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: wxPdfDocument - convert pixels to millimeters

Post by utelle »

cutecode wrote:in function

Code: Select all

wxPdfDocument::Image 	( 	const wxString &  	file,
		double  	x,
		double  	y,
		double  	w = 0,
		double  	h = 0, 
x,y,w,h - are pixels
No, that is simply not true. The position, height, and width of the image are given in user units, that is, the unit system selected on creating the wxPdfDocument class instance. The default unit system is millimeters, but centimeters, points or inches are also selectable.

Following a quote from the wxPdfDocument API documentation of the Image method:
wxPdfDocument API wrote: The dimensions can be specified in different ways:
  • explicit width and height (expressed in user unit)
  • one explicit dimension, the other being calculated automatically in order to keep the original proportions
  • no explicit dimension, in which case the image is put at 72 dpi
That is, you can specify the image dimensions (width and height) explicitly, or just width or height, or nothing (leaving it to wxPdfDocument to determine the image size).
cutecode wrote:but a I want to draw an image using millimeters.

How to convert millimeters to pixels?
Usually there is no need to convert image dimensions. Just use the width or height of the image in millimeters you want in the resulting PDF document, and wxPdfDocument will scale it accordingly. However, this only works if you use millimeters as the wxPdfDocument unit system.

Regards,

Ulrich
User avatar
cutecode
Super wx Problem Solver
Super wx Problem Solver
Posts: 425
Joined: Fri Dec 09, 2016 7:28 am
Contact:

Re: wxPdfDocument - convert pixels to millimeters

Post by cutecode »

thank you
wx 3.1.6 win/mac/linux

regards,
Alexander Saprykin
https://v2.dental-soft.ru
Post Reply