Converting a JPG to a PDF causes an exchange in photo width and height

Hi Aspose team,

We are using Aspose.pdf 19.2 and after we convert a JPG to PDF, the conversion is exchanging the width and height settings.

Here’s the JPG
original.JPG (2.4 MB)

Here’s the befre conversion (the original image) and after(the image in pdf file)
image.jpg (214.6 KB)

Here’s our code and demo. You can reproduce this problem using our demo.
https://drive.google.com/open?id=1LscK-13YYEBoQRR2xgt67JqaAdYg4-wj

Notes, it needs to input the license to the Class1.cs and Resource1.resx to run it. And we didn’t see this problem in Aspose.pdf 9.0.0.0

Please let me know if you have any problem.

@Glority_Developer

Thank you for contacting support.

Please use following code snippet to convert an image into PDF and set PDF Page size according to image dimensions.

String path = dataDir + "original.JPG";
System.Drawing.Image srcImage = System.Drawing.Image.FromFile(path);
int h = srcImage.Height;
int w = srcImage.Width;
Document doc = new Document();
Page page = doc.Pages.Add();
Aspose.Pdf.Image image = new Aspose.Pdf.Image();
image.File = (path);
page.PageInfo.Height = (h);
page.PageInfo.Width = (w);
page.PageInfo.Margin.Bottom = (0);
page.PageInfo.Margin.Top = (0);
page.PageInfo.Margin.Right = (0);
page.PageInfo.Margin.Left = (0);
page.Paragraphs.Add(image);
doc.Save(dataDir + "ImagetoPDF_19.2.pdf");

Generated PDF document has been attached for your kind reference. ImagetoPDF_19.2.pdf. Please feel free to contact us if you need any further assistance.

Hi,

If I use the code above. When I try to convert .emf and .emf file to PDF, it will fail.
And please look at the 111.png, it’s centered. But when I convert it to PDF, it is displayed in the top left corner of the PDF file.
And When I convert the P2202754.JPG, the result on pdf gets its original white background inverted to black.

Here’re the test files.
https://drive.google.com/file/d/1inQ8DAjyCzDsa_g6ANitXixXwgtZfH53/view?usp=sharing

@Glority_Developer

Thank you for elaborating it further.

We have converted attached files to PDF documents. EMF file is converted fine while WMF file is converted as a blank page. A ticket with ID PDFNET-46273 has been logged in our issue management system for further investigations.

9068096883_283cba4f47_b_19.4.pdf

For 111.png file, the PDF generated by Aspose.PDF for .NET is identical to the PDF generated by Adobe Acrobat.

111_19.4.pdf
111_Acrobat.pdf

For P2202754.JPG, the PDF looks same as the image. Would you please share generated file and a screenshot highlighting the issue.

P2202754_19.4.pdf

Before sharing your kind feedback, please ensure using Aspose.PDF for .NET 19.4 in your environment.