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

Free Support Forum - aspose.com

Combine 2 pdf files from URL

I am trying to grab 2 PDF files that are currently on my website, combine them into one PDF file that I can save.
I am finding a lot of examples on how to open an HTML page, but these are already PDF files

thanks for your help

Hi there,

Thanks for your inquiry. I am afraid Document() object support loading PDF file from file system or streams. So you need to download pdf files from url to file system or stream and concatenate the PDF files. Please find a sample code snippet for the purpose. Hopefully it will help you to accomplish the task.

System.Net.WebClient
wc = new System.Net.WebClient();<o:p></o:p>

// Open document

Document pdfDocument1 = new Document(new MemoryStream(wc.DownloadData("http://www.test.com/samples/Sample1.PDF")));

Document pdfDocument2 = new Document(new MemoryStream(wc.DownloadData("http://www.test.com/samples/Sample2.PDF")));

pdfDocument1.Pages.Add(pdfDocument2.Pages);

pdfDocument1.Save("test.pdf");

wc.Dispose();

Please feel free to contact us for any further assistance.

Best Regards,

thank you that worked.
one more question, how do you display the combined document in the browser

fsafadi:
one more question, how do you display the combined document in the browser
Hi Fadi,

In order to display resultant file, you may consider saving the resultant file in Stream object and then try passing the contents to Response instance.

In case you do not want to use above stated approach, you may consider using ViewerApp of our sister company named GroupDocs.