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)
Hello,
We have updated our solution to use Aspose.PDF 25.3 version, however the error still occurs. I did some testing and it looks like setting CopyLogicalStructure to True is what causes the error. Here is the full snippet:
string[] filePaths;
var dir = @"C:\PdfMerge\e93fc811-56c1-4044-bbec-791557255424";
filePaths = Directory.GetFiles(dir);
var outputFile = Path.Combine(dir, "output.pdf");
var pdfFileEditor = new PdfFileEditor()
{
MergeDuplicateLayers = false,
CopyOutlines = true,
CopyLogicalStructure = true,
};
pdfFileEditor.Concatenate(filePaths, outputFile);
Is it happening with the same files that you have shared previously? Did you try with 24.4 version as well? Please share the requested information. We will further proceed to assist you accordingly.
Below is the output that we generated in our environment using 25.4 version of the API and we could not notice any issues during testing: output.pdf (5.9 MB)
Can you please try with 25.4 version and let us know if issue still persists.
Hi,
I have checked both 25.4 and 25.5 versions of Aspose.PDF targeting .NET Standard 2.0 and on both I can reproduce the error. As I mentioned in my previous post the error only occurs when option CopyLogicalStructure is set to True.
Are you using the API under Linux like environment? Have you tried changing the framework version? Please share your environment details like OS Name and Version as well as application type so that we can further proceed accordingly.
No, I am using Windows Server 2019. My app is a Sharepoint based solution which targets .NET Framework 4.8. I have not tried changing framework version since it cannot be done that easily. Let me know if you need any more clarifications.
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): PDFNET-59934
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
Hi,
Just to let you know, we are a customer with paid license which if I understand should increase the priority of this ticket. Our license has been issued to: itservices@netcompany.com.
Please note that issues in free support model are prioritized on a first come first serve basis. On the other hand, paid support (need to subscribe for separately) gives you capability to prioritize your issues to the highest priority and such issues have precedence over the issues reported under free support model.
We will surely schedule your issue as per the policy and once we make some updates about its resolution, we will inform you via this forum thread. Please be patient and spare us some time.
We are sorry for the inconvenience.
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.
Enables storage, such as cookies, related to analytics.
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.