Can't convert particular jpeg to PDF

Hello!
I use Aspose.PDF version 10.2.0.0 to convert jpg files into PDF the next way:
============================================================

Dim PdfGenerator As Aspose.Pdf.Generator.Pdf = New Aspose.Pdf.Generator.Pdf()

'Create a section in the Pdf object
Dim SectionOne As Aspose.Pdf.Generator.Section = PdfGenerator.Sections.Add()

'Create an image object in the section
Dim CurrentImage As Aspose.Pdf.Generator.Image = New Aspose.Pdf.Generator.Image(SectionOne)

'Add image object into the Paragraphs collection of the section
SectionOne.Paragraphs.Add(CurrentImage)

'Set the path of image file
CurrentImage.ImageInfo.File = fileName

'Set the type of image using ImageFileType enumeration
CurrentImage.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg

'Set image title
CurrentImage.ImageInfo.Title = String.Empty

'Save the Pdf
PdfGenerator.Save(pdfPath)

============================================================

But for specific jpg file (see attach) I get pdf with zero size and I can’t open it (it’s locked). After resaving this file using Paint the same code works fine.
Thanks in advance.

Hi Maksim,

Thanks for contacting support.

I have tested the scenario using Aspose.Pdf for .NET 17.2.0 and have managed to convert provided JPEG to PDF without any error. I have also attached the generated PDF document for your reference.

Please note it is recommended to use new generator(Aspose.Pdf) instead old generator(Aspose.Pdf.Generator). As new generator is more improved and efficient, it can be used for both creating a PDF document from scratch or manipulate/edit existing PDF document. Moreover, It will be obsolete in near future, so we are not fixing or enhancing old generator anymore.

Furthermore, It is recommended to migrate to new generator. For migration to latest version, please check documentation link for migrating from older version of Aspose.Pdf. There are no major changes, you can check API changes section for the purpose. Almost all the object names and functionalities are same except Pdf and Section object these are replaced with Document and Page object respectively.

We are sorry for the inconvenience caused.

Best Regards,

Hello Fahad.
New generator works like a charm. Thank you for your help!

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'; -webkit-text-stroke: #000000} p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'; -webkit-text-stroke: #000000; min-height: 14.0px} span.s1 {font-kerning: none}

Thanks for your feedback. It is good to know that suggested code worked for you.


Please keep using our API and feel free to contact us for any question or concern, we will be more than happy to extend our support.


Best Regards,