Convert JPEG stream to PDF stream efficiently

Hi,


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?

Thanks

Hi Radim,

Thanks for your inquiry. You can easily [convert an image form stream or file to PDF document] (Image to PDF | Aspose.PDF for .NET API Reference) and save PDF either to stream or file. Please check the following code snippet for the purpose; it will help you to accomplish the task.

// Instantiate Document Object
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);

// Create an image object
Aspose.Pdf.Image image = new Aspose.Pdf.Image();// Add the image into paragraphs collection of the section
page.Paragraphs.Add(image);

// Set the image file stream
image.ImageStream = fs;

MemoryStream ms = new MemoryStream();

// Save resultant PDF file to stream
doc.Save(ms);

// Close memoryStream object
fs.Close()

Please feel free to contact us for any further assistance.

Best Regards,