Combine pdf functionality using Apryse SDK

Product: 11.05

Product Version: pdftron

Please give a brief summary of your issue: I want to implement combine functionality using pdftron in c#.
(Think of this as an email subject)

I want to implement combine functionality using pdftron in c#. So I’m able to implement that functionality but the issue is I have to download the file first then pass the local path to PDFDoc. Is there any way I can overpass the download functionality and directly open the document through url.

I’m able to open the document through url in webviewer but in Apryse SDK.
Here is my code for the reference:

string file1Path = “doc1.pdf”;
string file2Path = “doc2.pdf”;

// Download the PDFs locally
using (WebClient client = new WebClient())
{
client.DownloadFile(“https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf”, file1Path);
client.DownloadFile(“https://www.orimi.com/pdf-test.pdf”, file2Path);
}
using (PDFDoc outputDoc = new PDFDoc())
{
// Load input PDF files
using (PDFDoc doc1 = new PDFDoc(file1Path))
using (PDFDoc doc2 = new PDFDoc(file2Path))
{
// Lock the document before editing
doc1.InitSecurityHandler();
doc2.InitSecurityHandler();

     // Append pages from doc1
     outputDoc.InsertPages(0, doc1, 1, doc1.GetPageCount(), PDFDoc.InsertFlag.e_none);
     // Append pages from doc2
     outputDoc.InsertPages(outputDoc.GetPageCount() + 1, doc2, 1, doc2.GetPageCount(), PDFDoc.InsertFlag.e_none);

     // Save the output
     outputDoc.Save("CombinedOutput.pdf", SDFDoc.SaveOptions.e_linearized);

     Console.WriteLine("PDFs combined successfully to 'CombinedOutput.pdf'");
 }

}

1 Like

Hello, I’m AiRon, an automated tech support bot :robot:
While you wait for one of our customer support representatives, I can help you with your question.


It seems you want to combine PDF files using Apryse SDK without having to download them locally first. While the WebViewer can handle URLs directly, the Apryse SDK for .NET typically works with file paths or streams. However, you can achieve this by using a stream to load the PDF directly from a URL.

Some things you can try:

  • Use WebClient or HttpClient to download the PDF as a stream.

  • Pass the stream to PDFDoc using a MemoryStream.

  • Ensure you handle the security handlers properly when working with streams.

  • Combine the documents as you would with file paths.



Here are some resources that might help you:


Hopefully, this helps you solve your problem while you wait for a human to get back to you.

1 Like

Could you clarify your use case with this? As it is, the toolkit can perform combine commands on files in buffers. As such, you can download the files locally to memory stream instead of locations on disk, perform the combine in place, then re-upload the combined stream. Here’s our documentation for the PDFDoc() constructor overload which accepts a stream.

1 Like