Dear Sirs,
I have to implement the printing of labels in a certain size. For that I have to create a new, empty pdf file and place an image in it. PDF creation and image placing is not the problem, problem is sizing the pdf file.
Label size is 10 x 15 cm.
Image size is 9 x 14
I convert the sizes to pixel and generate a new page with this sizes:
PdfDocument doc = new PdfDocument();
PdfUnitConvertor converter = new PdfUnitConvertor();
float width = converter.ConvertUnits(10, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Pixel);
float height = converter.ConvertUnits(15, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Pixel);
PdfPageBase page = doc.Pages.Add(new SizeF(width, height), new PdfMargins(0));
At least a add the label image with smaller sizes for width and height and save the file.
page.Canvas.DrawImage(label, xmargin, ymargin, iwidth, iheight);
The image is placed fine but the pdf file has a size of 13,3 x 20 cm and not the given 10 x 15.
So it seems to be not the correct way for sizing the pdf file.
Thanks for any support and best regards
Arne