Concatinate multiple PDF files into one file

Hi There,
We have a licensed Aspose product .

I was working on a new enhancement where i need to concatinate multiple pdf files into one file .

here the work flow may contain just one pdf file or multiple file , is there a dynamic way irrespective of the uploaded documents count where i can merge them in to one pdf file .

I would really appreciate your help , a code sample would be awesome .

I saw few samples online but they are not dynamic .

Thanks
Anil

Hi Anil,


Thanks for contacting support.

The Document class can be used to concatenate PDF files and once you have merged certain number of files, you can save the output in Stream instance and when you have some more documents to concatenate, you can instantiate Document object through same Stream instance and concatenate new files with already merged output. For more information, please visit Concatenate PDF Files

In case you still face any issue or you have any further query, please feel free to contact.

Hi Anil,


Thanks for your inquiry. You can create a list of your uploaded documents and concatenate them dynamically. Please check following sample code snippet, you can change it accordingly. Hopefully it will help you to accomplish.

Document targetDoc = new Document();<o:p></o:p>

Document inputDoc;

List<String> inputDocs = new List<String>();

inputDocs.Add("E:/data/s2.pdf");

inputDocs.Add("E:/data/HelloWorld.pdf");

for (int i = 0; i < inputDocs.Count; i++)

{

inputDoc = new Document(inputDocs[i]);

// Add the pages of the source documents to the target document

targetDoc.Pages.Add(inputDoc.Pages);

}

targetDoc.Save(myDir + "merged.pdf");


Please feel free to contact us for any further assistance.

Best Regards,

Thanks Tilal , you rock !!

That’s what I was looking for .

HI Tilal,
I made good progress with your help, now i have few more hurdles ahead of me , hope you can help me overcome it .

I have a new work flow to convert below mentioned file formats to pdf format , can you please help me with converting these formats to pdf formats , a code sample would be awesome .

file formats for conversion

  1. .msg
  2. .jpeg
  3. .txt
  4. .bmp

which Aspose library should i refer to read all the above mentioned format before converting ?

Thanks in advance
Anil

Hi Anil,


Thanks for your feedback. It is good to know that suggested solution worked for you.

Please check following details to convert your required file formats to PDF.

MSG

You can convert Email to PDF will collaboration of Aspose.Email and Aspose.Words, please check following documentation link for details.



JPEG/BMP

You can convert images to PDF using Aspose.Pdf, please check following documentation link for details.


TXT

You can convert Text file to PDF using Aspose.Pdf, please check following documentation link for details.


Please feel free to contact us for any further assistance.

Best Regards,

Thanks Tilal,
those were really helpful , but i am not letting you go before i ask one last thing .

I am left with one last file format for converting it to pdf file .

can you please help me with converting the excel files to pdf , code sample would be nice.

Thanks in advance
Anil

Hi Anil,


Thanks for your inquriy. For excel files to PDF conversion you need to use Aspose.Cells for .NET. Please check following documentation link for details and code snippet, it will help you to accomplish the task.


Please feel free to contact us for any further assistance.

Best Regards,

Thanks Tilal,
I got all the things i came looking for , it was pleasure interacting with you .

will definately get in touch with you if i need any help in future.

keep up the good work .

Thank
Anil

Hi Anil,


Thanks for your feedback. It is good to know that you received all the information you required.

Please keep using our APIs and feel free to contact us for any further assistance, we will be more than happy to extend our support.

Best Regards,

targetDoc.Pages is not showing.

@saurabhicr

Please explain a bit more about the issue by sharing the API version that you are using along with the sample code snippet so that we can further look into this matter and share our feedback with you.