Convert multiple mime types to PDF

Hi
I have a set of pages which can be of different mime types . One can be doc, one can be png and so on.
My requirement is to convert each page to PDF using respective aspose package and then combine all of them to a single PDF document.
Ex: page 1 is words and page 2 is bmp:
For page1:
Document doc = new Document(inputStream)
doc.save(“C:/temp/page1.pdf”)
For page2:
BmpImage bmpImage = new BmpImage(inputStream);
PdfOptions exportOptions = new PdfOptions();
exportOptions.setPdfDocumentInfo(new PdfDocumentInfo());
bmpImage.save(“C:/temp/converted.pdf”,exportOptions);

Now how do I combine both page1.pdf and converted.pdf pages to a single PDF document with 2 pages?

@sushma1509

Sure, you can merge both documents into one single PDF by using the code example given in the below article:

Hi @asad.ali

But page1.pdf is saved using Aspose words and converted.pdf is saved using Aspose.Imaging
I am not able to use
Document.save() from Aspose.pdf for these two documents.

Assume:
Aspose words WordsDoc = new Aspose words Doc();
WordsDoc.save(“C:/temp/docWords.pdf”)

Aspose Image ImageDoc= new Aspose Image Doc();
ImageDoc.save(“C:/temp/Image.pdf”)

AsposePDF PDFDoc= new AsposePDF Doc();
PDFDoc.getPages().add(WordsDoc.getPageInfo(0)); //Here there is an error because of type mismatch – Cannot add pageInfo object to Pages

@sushma1509

You need to initialize the PDF document using the saved file like below:

// above you are done with saving the PDF files from Word and Image
Aspose.Pdf.Document doc1 = new Aspose.Pdf.Document("docWords.pdf");
Aspose.Pdf.Document doc2 = new Aspose.Pdf.Document("Image.pdf");

Aspose.Pdf.Document finalDoc = new Aspose.Pdf.Document();
finalDoc.Pages.Add(doc1.Pages);
finalDoc.Pages.Add(doc2.Pages);
// You can keep adding pages like above
//  then save the final output
finalDoc.Save("Merged.pdf");