Problems using ImportxFdf method

Hello,

I am currently evaluating Aspose.Pdf.Kit for use at my company. It seems like it should do exactly what we want it to do, but I am having a few weird errors.

We are building an xfdf document dynamically in code and then I am writing it to a memory stream as follows:

MemoryStream strm = new MemoryStream();

StreamWriter Writer = new StreamWriter(strm);

Writer.AutoFlush = true;

Writer.Write(xfdf.ToString());

After doing this I store the stream in an image field in our database. I have had no trouble using the retrieved xfdf file and having it fill in the referenced pdf file when loading client side.

What I am trying to do is merge this into a PDF document in my server side code using the Aspose PDF kit. So first I create my form object:

Form form = new Form(PDFstrm,Mergedstrm);

and then I try to import the stream which contains my xfdf data like so:

form.ImportXfdf(strm);

However, when I do this I get an exception with the message "Insufficient Length". If I take the data from the xfdf I created and save it to a file and then open the file using a FileStream and try to read it in to the ImportXfdf method I will sometimes see the following error:

"Specified argument was out of the range of valid values"

But if I just try to open the xfdf in Adobe Acrobat it merges into the PDF form without any problems, so the xfdf seems to be well-formed.

Please offer any advice you might have to remedy this problem as I would really like to license this product if I can get it to work.

I have attached the PDF form which we are trying to fill as well as a sample xfdf file.

Thanks,

Anthony

Hi,

Thank you for considernig Aspose.

Can you please provide the pdf and xfdf files, so that we can test this issue.

Thanks.

Adeel Ahmad
Support Developer
Aspose Changsha Team
http://www.aspose.com/Wiki/default.aspx/Aspose.Corporate/ContactChangsha.html

I have attached the files…I tried to do that on my first post but it doesn’t seem to have worked. If the files do not attach to this post, please contact me with an email address to which I can send the files directly.

Hi,

I have tested the documents that you sent and was unable to reproduce the error. In my case I was able to get a correct result with out any errors. Can you please provide the full code that you are using so that I may be able to provide further guidance.

Thanks.

Adeel Ahmad
Support Developer
Aspose Changsha Team
http://www.aspose.com/Wiki/default.aspx/Aspose.Corporate/ContactChangsha.html

The code that I am using as it pertains to Aspose is just as I posted in my first post. The only difference between what you are doing in your sample code and what I am doing in my code is that I am using MemoryStreams instead of file streams for my xfdf, source pdf and output pdf.

Is it possible for you to send me the dll compiled in debug mode with the pdb file so that I can run it and get you the line number where I am getting the errors that I am mentioning? Perhaps that will help us understand where the error is occuring.

It is necessary that I use MemoryStreams instead of FileStreams so changing this would not be an option, but I don't think that this is the cause of the problem anyway, since both are derived from the generic stream class.

Hopefully we can solve this problem because we would very much like to use your product.

Thanks,

Anthony

Hi,

I tested with both MemoryStreams and FileStreams and didn’t get any error. Let me discuss this with the developers to see what other options do we have of testing this problem. By the way I was using v 2.3.3.0 of Aspose.Pdf.Kit.

Thanks.

Adeel Ahmad
Support Developer
Aspose Changsha Team
http://www.aspose.com/Wiki/default.aspx/Aspose.Corporate/ContactChangsha.html

Hi Adeel,

Can you please send me the code that you used to test these files when you were able to import the xfdf successfully...Thanks!

Anthony

Hi,

I tried the following two versions of code:

Aspose.Pdf.Kit.Form form = new Form("f1065sk1.pdf", "test.pdf");
System.IO.FileStream xmlInputStream = new FileStream("test.xfdf", FileMode.Open);
byte[] buff = new byte[xmlInputStream.Length];
xmlInputStream.Read(buff, 0, (int)xmlInputStream.Length);
MemoryStream ms = new MemoryStream(buff);
form.ImportXfdf(ms);
form.FlattenAllFields();
form.Save();
Aspose.Pdf.Kit.Form form = new Form("f1065sk1.pdf", "test.pdf");
System.IO.FileStream xmlInputStream = new FileStream("test.xfdf", FileMode.Open);
form.ImportXfdf(xmlInputStream);
form.FlattenAllFields();
form.Save();

Thanks.

Adeel Ahmad
Support Developer
Aspose Changsha Team
http://www.aspose.com/Wiki/default.aspx/Aspose.Corporate/ContactChangsha.html