Free Support Forum -

Convert JPG to PDF produces unreadable PDF

If I use documented Aspose.PDF Image Approach produced pdf is unreadable in Adobe Reader.
If I use documented Aspose.PDF XImage Approach produced pdf is readable in Adobe Reader.

Input jpeg is 8pp color space - maybye i must make some undocumented settings?
source jpeg in attachment.
strom-bw-8bit-ConvertImage.jpg (127.1 KB)


Thanks for contacting support.

We were able to notice that resultant PDF document was not readable by Adobe Reader when we added image inside it using following code snippet:

Document doc = new Document();
Page page = doc.Pages.Add();
FileStream fs = new FileStream(dataDir + "strom-bw-8bit-ConvertImage.jpg", FileMode.Open, FileAccess.Read);
byte[] tmpBytes = new byte[fs.Length];
fs.Read(tmpBytes, 0, int.Parse(fs.Length.ToString()));

MemoryStream mystream = new MemoryStream(tmpBytes);
Bitmap b = new Bitmap(mystream);
page.PageInfo.Margin.Bottom = 0;
page.PageInfo.Margin.Top = 0;
page.PageInfo.Margin.Left = 0;
page.PageInfo.Margin.Right = 0;

page.CropBox = new Aspose.Pdf.Rectangle(0, 0, b.Width, b.Height);
// Create an image object
Aspose.Pdf.Image image1 = new Aspose.Pdf.Image();
image1.ImageStream = mystream;
dataDir = dataDir + "ImageToPDF_out.pdf";

We have logged this issue as PDFNET-44524 in our issue tracking system. We will further investigate the issue in details and keep you posted with the status of its correction. Please be patient and spare us little time.

We are sorry for the inconvenience.