Hello .. Good evening!
I am using the following code to convert images to pdf:
Dim doc As New PdfDocument()
Dim section As PdfSection = doc.Sections.Add
Dim page As PdfPageBase = doc.Pages.Add
Dim image As PdfImage = PdfImage.FromFile(inputDoc)
Dim widthFitRate As Single = image.PhysicalDimension.Width / page.Canvas.ClientSize.Width
Dim heightFitRate As Single = image.PhysicalDimension.Height / page.Canvas.ClientSize.Height
Dim fitRate As Single = Math.Max(widthFitRate, heightFitRate)
Dim fitWidth As Single = image.PhysicalDimension.Width / fitRate
Dim fitHeight As Single = image.PhysicalDimension.Height / fitRate
page.Canvas.DrawImage(image, 30, 30, fitWidth, fitHeight)
doc.SaveToFile(TempDir & "\" & IO.Path.GetFileNameWithoutExtension(inputDoc) & ".pdf")
doc.Close()
However, it is generating a pdf with the original image in the center of the page.
What modification is necessary to generate a pdf page with the same measurements (width and height) as the original image?
Thank you in advance!