Free Support Forum - aspose.com

Aspose PDF throwing a StackOverflow Exception when converting a Word document

Hi,

Currently using:
Aspose Words 7.0.0.0
Aspose PDF 4.1.0.0
Aspose Pdf.Kit 3.7.0.0

Whenever I try converting the attached word document to pdf using the following method:

wordDocument.Save(memStream, Aspose.Words.SaveFormat.AsposePdf);
pdf = new Aspose.Pdf.Pdf();
pdf.BindXML(memStream, null);
pdf.IsImagesInXmlDeleteNeeded = true;

pdf.Save(memStream);

It throws a stackoverflow exception. I have attached the Word file along with the intermediary .xml file that gets generated during PDF conversion.

Thanks.

Hello John,

I have tested the issue and I’m able to reproduce the same problem. I have logged it in our issue tracking system as PDFNET-11411 . We will investigate this issue in detail and will keep you updated on the status of a correction. We apologize for your inconvenience.

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />As a workaround, I would suggest you to use the Direct-to-PDF save method of Aspose.Words, as during my test, I've successfully been able to generate the PDF document. For your reference, I've attached the resultant document.

We cannot use the DirectToPdf method as it does not have full support for Asian fonts and causes numerous rendering issues with our outputs. Please let us know any information about this issue that you can. We have a release coming up in a couple of weeks and need to identify what is causing this to happen. Is there something wrnog with the document we sent in? or some sort of work-around?

Thanks!

Hello John,

The issue is occurring over Aspose.Pdf end and as soon as we've made some progress regarding the resolution of this problem, we would be pleased to update you with the status of resolution.

Your comprehension is greatly appreciated in this regard.

After some further investigation we found that the client document has some malformed Html in it:

1. The valign attribute on the Field/Value table is malformed and split into two attribute ‘va’ and ‘lign’, however, Aspose probably just ignores this as they do any other unrecognized attribute.

2. There is the text ‘xxxx’ before the table tag just after the
malformed valign attributes and it is this text that seems to cause the
problem because once this text is removed the document publishes
successfully. Browsers generally add an implicit

around hanging text like this so that the html doesn’t violate the Html standard, which is why in a web browser the html looked ok and didn’t throw any errors.

so … xxxx <table …> …

Once the html is fixed to either remove the ‘xxxx’ or surround it in a
everything works fine. So, this issue can be considered ok on our end since its bad data going into Aspose. However, i tested with a previous version of your dll and this problem didn’t occur even with malformed html, so you may still want to leave the issue open on your end since it could be encountered by other clients.

We no longer require assistance for this issue, thanks for all your help!

Thanks!

Hello,

We would like to reopen this issue because, after further investigation, we have identified what is causing the issue. Aspose.Pdf is throwing the StackOverflowException because of nested tables in the Html. Please see the attached html file. When this is injected into a one-cell Word table via InsertHtml we are seeing the problem.

The problem starts on line 47 with the table definition. When the table/tbody/tr/td tags are all removed, and their corresponding close tags as well, converting to Pdf works. With those tags in there it does not work. I’ve attached the html that is injected into the Word document, the resulting Word document that was built, as well as the Aspose.Pdf.xml file that is generated when we’re trying to convert the Word document to Pdf.

Thanks!

Hi,

The issue seems to be resolved in the hotfix shared over this link. I've tested the scenario using this hotfix and I'm unable to notice the problem. Please try using it and in case you still face any problem, feel free to contact.

I've also attached the resultant PDF document that I've generated.

The hotfix dll you attached works! Thanks so much for your help with this!