In my application I need to create a pdf generating images at runtime.
I have a component that draws on canvas, what is the best way to draw my image on pdf?
How can I set the canvas size in order to have the best results? Are pdf pagewidth and pageheight comparable to canvas width and height?
mydrawer is my custom drawer, img is a TTMSFNCBitmap, cellwidth and cellheight the size of my image on pdf. setting drawer.Height:= cellheight; and drawer.Width:= cellwidth; I set the mydrawer canvas dimensions.
Saving images can create significant amount of resources. Until the PDF is saved, the image is stored in a JPEG format. The code is correct, the pagewidth/pageheight are in pixels, you can compare the PageWidth/PageHeight with the Canvas Width and Height. You can use functions such as MillimeterToPixel and PixelToMillimeter to have more accurate drawing coordinates.
The PDF canvas is in pixels, and is set to be a default A4 format, which is 210 mm × 297 mm
If you want to create a grid-like structure on an A4 you can use these dimensions. You can also change the dimensions of the PDF by setting the PageSize to custom and set the PageWidth / PageHeight properties.
Drawing images / graphics is always in pixels, but it depends on the size you need to draw them in millimeters. Please provide more details, or a specific sample on what you want to achieve exactly.