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

Free Support Forum - aspose.com

Convert JPEG stream to PDF stream efficiently


I need to convert JPEG strem to PDF stream without having all data stored on disk or memory. I want to build a web service that receiving JPEG stream and fluently sending PDF stream to the server. Do you have any ideas how to do it?


Hi Radim,

Thanks for your inquiry. You can easily convert an image form stream or file to PDF document and save PDF either to stream or file. Please check following code snippet for the purpose, it will help you to accomplish the task.

// Instantiate Document Object<o:p></o:p>

Document doc = new Document();

// Add a page to pages collection of document

Aspose.Pdf.Page page = doc.Pages.Add();

// Load the source image file to Stream object

FileStream fs = new FileStream("c:/logo.jpg", FileMode.Open, FileAccess.Read);

//byte[] tmpBytes = new byte[fs.Length];

//fs.Read(tmpBytes, 0, Convert.ToInt32(fs.Length));

//MemoryStream mystream = new MemoryStream(tmpBytes);

// Create an image object

Aspose.Pdf.Image image = new Aspose.Pdf.Image();

// Add the image into paragraphs collection of the section


// Set the image file stream

image.ImageStream = fs;

MemoryStream ms = new MemoryStream();

// Save resultant PDF file to stream


// Close memoryStream object



Please feel free to contact us for any further assistance.

Best Regards,