Free Support Forum - aspose.com

An unhandled exception of type 'System.StackOverflowException' occurred in Aspose.Pdf.dll

Hi,

I am trying to convert a Word document to PDF using Aspose.Pdf for .NET and I got the following error.


An unhandled exception of type 'System.StackOverflowException' occurred in Aspose.Pdf.dll

I am using the example code from this link http://www.aspose.com/documentation/.net-components/aspose.pdf-for-.net/converting-word-documents-to-pdf.html

Thanks...

Sanjay Kumar

Ph: 732-694-3170


This message was posted using Email2Forum by salman.sarfraz. (attachment)

Hello Sanjay,

Thanks for considering Aspose.

Please share the resource word document so that we can test the scenario at our end.

We apologize for your inconvenience.

Attached find the document I am using.

Hello Sanjay,

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-12706. 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" />

Hello Sanjay,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your patience.

After spending sometime over the issue PDFNET-12706 which was reported earlier, we've come to the conclusion that the format of input Word is somehow weird. When the Word contents are transformed into an XML file, notice the element in the header. It has only single empty line with LineSpacing 686 pound. So, this text would occupy the whole page. Just as the double line border does (It is the text's border). In normal process, texts in main body should start after the text. However, MS Word, seems to ignores header contents and treat them as floating objects.

Further investigation showed that if we set the PageMarginTop to nonnegative value(e.g 0), everything seems right. I think this should be the magic. As in your original document, PageMarginTop="-54", and it should mean something unknown to us because Word is not an open format. We can't support it in short time.

As a workaround, please remove the Header and set Page border. I have also attached the modified Word document and the resultant pdf file for your reference, please take a look.

Please try using the latest HotFix for Aspose.Pdf for .NET 4.1.1 that can be accessed from this link.

<?xml version="1.0" encoding="UTF-8"?>

<Pdf xml:space="preserve" TabStopPosition="36" IsCoreFontUsed="false" IsPageNumberForDocument="true" Author="Exxon" Title="Rancho/EPC Genoa Jct." Producer="Exxon" Subject="Points to Baytown and Webster" xmlns="Aspose.Pdf">

<Section PageWidth="612" PageHeight="792" PageMarginTop="-54" PageMarginBottom="36" PageMarginLeft="50.4" PageMarginRight="57.6" IsNewPage="true">

<Header DistanceFromEdge="36">

<Text MarginLeft="4.5" IsSpaced="true" LineSpacing="686">

<TextBorder>

<Box BorderStyle="Double" LineWidth="1.5" />

</TextBorder>

<TabStops>

<TabStop Position="216" AlignmentType="Center" />

<TabStop Position="432" AlignmentType="Right" />

</TabStops>

<Segment FontName="CG Times" FontSize="10"> </Segment>

</Text>

</Header>

Hello Sanjay,

Thanks for your patience.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

The conventional method of using Aspose.Words and Aspose.Pdf to convert word files into PDF format is now obsolete. Please try using Direct-to-PDF save method of Aspose.Words and as we have stated earlier, the issue PDFNET-12706 seems to be related to Aspose.Words.

For your convenience, I am moving this thread to Aspose.Words forum where I believe our team of experts taking care of that product would be in better position to assist you in this regard. In case you have any further query, please feel free to contact. We apologize for the delay and inconvenience.

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. Please try using the latest version of Aspose.Words and direct-to-PDF method as described here:

http://www.aspose.com/documentation/.net-components/aspose.words-for-.net/howto-convert-a-document-to-pdf.html

You can download the latest version from here:

http://www.aspose.com/community/files/51/.net-components/aspose.words-for-.net/category1188.aspx

Best regards,