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

Free Support Forum - aspose.com

Trailer object is null.: v4.9.0.0

Greetings - I'm currently evaluating Aspose.Pdf.Kit for .Net to use as a solution for filling and concatenating Acrobat forms. I downloaded v4.9.0.0 and was able to setup a simple proof of concept project with no problems on my laptop.

After my initial success, I installed Aspose.Pdf.Kit on my development virtual machine and started working with it in the project I want to use it with. Unfortunately, I'm now getting the following error:

Trailer object is null.: v4.9.0.0

Stack trace:

at xeb116a323308e2f7.x7759a935a2782a02.rebuildXref()
at xeb116a323308e2f7.x7759a935a2782a02.readPdf()
at xeb116a323308e2f7.x7759a935a2782a02..ctor(Stream is_Renamed, SByte[] ownerPassword)
at xeb116a323308e2f7.x7759a935a2782a02..ctor(Stream is_Renamed)
at Aspose.Pdf.Kit.Form.xedff4d4fd296f454()
at Aspose.Pdf.Kit.Form..ctor(Stream srcStream, Stream destStream)
(my code excluded from stack trace)

There doesn't appear to be any problems with the PDF form I'm trying to load. I've copied it back to my laptop and am able to use it with Aspose.Pdf.Kit in my proof of concept application.

Any insight would be much appreciated.

Thank you,


Hello Chris,

Thanks for using our products.

Can you please share the code snippet and the source PDF document which is causing an issue, so that we can test the scenario at our end.

We apologize for your inconvenience.

Our PDF is attached. Below is the code I'm using:

public Stream GenerateReport(Stream sourceTemplate, IList<IDictionary> reportPages)
Settings.Strategy = FileProcessingStrategy.OptimizeMemoryUsage;

IList pages = new List();

reportPages.ToList().ForEach(page =>
MemoryStream currentPageOutput = new MemoryStream();
Form form = new Form(sourceTemplate, currentPageOutput); // Exception is raised here
sourceTemplate.Position = 0;

page.ToList().ForEach(field =>
form.FillField(field.Key, field.Value);




Stream outputStream = new MemoryStream();
PdfFileEditor editor = new PdfFileEditor();
editor.Concatenate(pages.ToArray(), outputStream);

return outputStream;

Thank you for your prompt response,


Hello Chris,

Thanks for sharing the resources.

As far as I can see you are using some list object to retrieve the form field name and fill the information accordingly i.e. form.FillField(field.Key, field.Value); For testing purpose, I have tried filling data in one of the field named risk-line10 and have called form.FlattenAllFields(); method and I am getting an error message "Aspose.Pdf.Kit.PdfKitErrorCodeException". For the sake of correction, I have logged this problem as PDFKITNET-20728 in our issue tracking system. We will further look into the details of this problem and will keep you updated on the status of correction.

Regarding Trailer Object is null issue, can you please share some more details/code sample that can help us in reproducing this problem.

We apologize for your inconvenience.

Hi Nayyer -

In our solution, we have a resource assembly, which is just a class library containing embedded resources and a static class that exposes these resources as properties. In the case of the PDF, the PDF file I attached to my earlier post is an embedded resource in this assembly and exposed by a static property. That stream is then passed in to the method I included in my earlier post.

In an effort to eliminate the possibility that storing the PDF as an embedded resource was causing the problem, I tried changing my code to read the PDF directly from disk via FileStream, however I still had the same error.

If there's anything else you'd like to know, please let me know.

Thanks again for your prompt attention!


Hello again -

Good news, I believe our problem is solved. It turns out that the source PDF had an edit password on it. I got an updated version of the PDF that contains no password and I'm not able to successfully fill the PDF form with no exceptions.

It would be ideal if you guys could change your component so that in such a situation, the exception message indicates that the problem is password related, rather than the current "trailer object is null" message.

Thanks for your help!


Hello Chris,

Thanks for the suggestion and sorry for getting back to you late.

Yes you are correct and I agree with your point that whenever an issue occurs, an appropriate error message with complete problem description should be displayed. We can change the error description but as I have shared earlier, during my testing, I was unable to notice Trailer Object is null issue. Can you please share some sample project that can help us in reproducing this problem.

Nevertheless In my earlier try, I was able to open the PDF document and update it even I have not supplied the password to edit the document. Can you please check at your end that the PDF document that you have shared in this forum thread is password enabled ?