We have noticed issue when concatenating pdf files using Aspose.PDF version 24.7.0.0. This problem has been identified on our machines as well as in our clients’ production environments.
When calling Concatenate(Stream[] inputStream, Stream outputStream) for any file and the
Biocirc høringssvar til kommuneplan 2025 - original.pdf we get the following exception:
Exception occurred. Details: System.NullReferenceException: Object reference not set to an instance of an object. at Aspose.Pdf.Facades.PdfFileEditor.#=z45WyG7iz4Uwe(Document #=zfS$Zt1Q=, Document #=zS7x67v0=, #=zs4wCgDGbOmDHFi90YVdBXIj_IXqW #=zEx0jVQ8Yxduy, #=zH7rwp_Ou2rCYqZvt4U_Ld3bJwz2Upc_v6w== #=znaB425O1UqQe) at Aspose.Pdf.Facades.PdfFileEditor.#=zJXLRSAiGXko7(Document[] #=zODXQChw=, Document& #=zS7x67v0=) at Aspose.Pdf.Facades.PdfFileEditor.Concatenate(Stream[] inputStream, Stream outputStream)
I am attaching sample code and documents to reproduce the issue.
Could you help us resolve this issue?
Thanks in advance,
Marcin Attachments.zip (5.6 MB)
It seems you are encountering a NullReferenceException when trying to concatenate PDF files using Aspose.PDF version 24.7.0.0. This issue has been reported by other users as well, and it may be related to the specific PDF files you are working with or the version of the library.
Here are some steps you can take to troubleshoot and potentially resolve the issue:
Update Aspose.PDF: If possible, consider updating to a newer version of Aspose.PDF. There have been fixes related to PDF concatenation in later versions, and upgrading might resolve the issue you are facing.
Check PDF File Integrity: Ensure that the PDF files you are trying to concatenate are not corrupted. You can try opening them individually to verify their integrity.
Use Sample Code: Here is a sample code snippet that demonstrates how to concatenate PDF files using streams. Make sure your implementation aligns with this example:
using System.IO;
using Aspose.Pdf.Facades;
public class ConcatenatePDFs
{
public static void Run()
{
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
// Output stream
using (FileStream outputStream = new FileStream("output.pdf", FileMode.Create))
{
// Array of input streams
using (FileStream inputStream1 = new FileStream("input1.pdf", FileMode.Open),
inputStream2 = new FileStream("input2.pdf", FileMode.Open))
{
// Concatenate files
pdfEditor.Concatenate(new Stream[] { inputStream1, inputStream2 }, outputStream);
}
}
}
}
Error Handling: Implement error handling in your code to catch exceptions and log detailed information about the files being processed. This can help identify if a specific file is causing the issue.
Review Similar Issues: You may want to check other forum posts related to PDF concatenation issues. Users have reported similar problems, and solutions or workarounds may have been shared.
If the problem persists after trying these steps, please provide additional details about the specific PDF files you are using, and any other relevant information that could help diagnose the issue further.
Our implementation aligns with the sample code provided. I have also tested with the sample code and our files and issue is occurring. If it has been fixed in newer versions, please provide in which it the fix has been implemented.
We tested using 25.2 version of the API and could not replicate the issue. Would you please try using it and let us know if you face any issues? output.pdf (5.9 MB)
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.