Convert Different file formats input streams to PDF and merge them all

Hi Team,


I have a requirement where I have to convert PDF/Excel/Word INPUT STREAMS to pdf INPUT Stream and merge both the input streams.

As per the security norms I cannot save the files or convert the input stream into a file and save.

Can you please suggest a work around for this ?

Thanks in advance.

Regards
Jyothi

Hi Jyothi,

Thanks for your inquiry. Aspose APIs support to load documents from streams and save to streams as well. So you can save PDF output from Aspose.Cells and Aspose.Words to stream, and later can concatenate multiple PDF streams into a single stream. Please check following documentation link for concatenation PDF streams.

Please feel free to contact us for any further assistance.

Best Regards,

Hi Ahmad,


Thank You for the response.

But am afraid I didn’t put my question right.

We have a document stream say DocMemoryStream which should be directly converted into PDF stream say PdfMemoryStream.I cannot save any document or read any document in this process.

Can you please advise on the above as soon as possible its been a show stopper for me for long.
It would be great if you give me code sample as well.
Thanks in advance.

Regards,
Jyothi.




Hi Jyothi,


Thanks for your feedback. As per your requirement you can convert DOC document as stream into PDF as stream as following. You can use respective constructors of Aspose.Cells for loading Excel document from stream and convert it into PDF as stream.

// Load the document from disk.<o:p></o:p>

Aspose.Words.Document doc = new Aspose.Words.Document(DocMemoryStream);

MemoryStream pdfMemoryStream = new MemoryStream();

// Save the document in PDF format.

doc.Save(pdfMemoryStream,Aspose.Words.SaveFormat.Pdf);

Please feel free to contact us for any further assistance.


Best Regards,

Thank You !!

Its done:)

Hi Jyothi,


Thanks for your feedback. It is good to know that you have managed to accomplish your requirement.

Please keep using our API and feel free to contact us for any further assistance, we will be glad to extend our support.

Best Regards,

Hi ahmad

The code snippet is not working for me while saving the document as pdfmemorystream.
import com.aspose.pdf.internal.imaging.system.io.MemoryStream;
Document doc = null;
MemoryStream pdfMemoryStream = new MemoryStream();
System.out.println("aspose operations ");
switch (extension) {
case “docx”:
System.out.println("in doc case : ");
try {
doc = new Document(docStream);

			PdfSaveOptions options = new PdfSaveOptions();
			options.setCompliance(PdfCompliance.PDF_A_1_B);
			//doc.save(newPath,options);
			doc.save(pdfMemoryStream, SaveFormat.PDF);
			
		} catch (Exception e) {
			System.err.println(e);
		}

Please help …

@ssamidis

It seems like you are trying to load a .doc/.docx file in Document(). Please note that Aspose.PDF does not support Word to PDF conversion. You can however convert a PDF into DOC/DOCX using the API. Please let us know in case we have missed something and share your sample source file with us. We will further proceed to assist you accordingly.