We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Process gets stuck while Converting PNG to PDF using C#

I am using Aspose.pdf to convert png to pdf format. But somehow one strange file is not working.
It is stuck at pdf.Save(PDFTargetFilePath,SaveFormat.Pdf); line .Its not moving forward from here. vasco733.png (22.7 KB)

Also i am attaching source code here.
public static class PDFConverterTest
{
public static void ConvertPNGTOPDF(string PNGImageFilePath,string PDFTargetFilePath)
{
Aspose.Pdf.Document pdf = new Aspose.Pdf.Document();
Bitmap bitmap = new Bitmap(PNGImageFilePath);
int width = bitmap.Width;
int height = bitmap.Height;
string tmpJpg = GetTempFileName();
bitmap.Save(tmpJpg, ImageFormat.Png);
bitmap.Dispose();
//Create a section in the Pdf object
Page sec2 = pdf.Pages.Add();
//Create an image object in the section
Aspose.Pdf.Image image2 = new Aspose.Pdf.Image();
//Add image object into the Paragraphs collection of the section
sec2.Paragraphs.Add(image2);
//Set the path of image file
image2.File = tmpJpg;
sec2.PageInfo.Width = width + 2.04f;
sec2.PageInfo.Height = height + 2.04f;
pdf.Save(PDFTargetFilePath,SaveFormat.Pdf);
}
static string GetTempFileName()
{
string Temp = “”;
do
{
Temp = Path.GetTempPath() + Path.GetRandomFileName();
} while (File.Exists(Temp));
return Temp;
}
}

@venkat2222

We have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as PDFNET-51262. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

Thank you . Will be waiting for the fix.