Problem converting to pdf

Hi,

I attached a word document that is being transformed into a pdf. Works almost perfectly with version Aspose.Word 2.4.1.0 and Aspose.Pdf 2.4.2.0

please check the pdf document and notice that at many places, the text is in bold where it shouldn’t and at many places, there is no space between words where it should! At some place, words overlap too. Check page 3, second paragraph for some example of what I mean.

Why is that? It’s really important and I would appreciate a quick response on the above while what’s below is less important for now!

Also, yesterday, I tried to migrate to version 3 of Aspose.Word, but no luck, the document won’t even save as xml for Aspose.Pdf.

Thank you for your support, keep up the great work!

Hi,

First, thanks for your positive words.

I’ve attached the resulting PDF made with Aspose.Word 3.0. As you can see, the issues seem to disappear. So please give a detailed explanation of the problem with migrating to v3: post the code you are using for the conversion, describe what exceptions are thrown (if any) and so on. Using the latest version of the component would allow you to avoid many issues including one being discussed thus we are interested to help you to migrate, too.

Well,…

I just updated again to 3.0 (Word) and 2.4.2 (Pdf) and still not working!

The error comes from this line of code:
doc.Save(xmlFileName, Aspose.Word.SaveFormat.FormatAsposePdf);

and here is the error:

Server Error in ‘/INTRANET’ Application.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:


An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.] Aspose.Word.Inline.?(Object ?) Aspose.Word.Font.?(Object ?) Aspose.Word.Font.get_Size() Aspose.Word.Paragraph.?() ?.?.?(Paragraph ?) ?.?.?(Paragraph ?) ?.?.VisitParagraphStart(Paragraph para) Aspose.Word.Paragraph.Accept(DocumentVisitor visitor) Aspose.Word.CompositeNode.?(DocumentVisitor ?) Aspose.Word.HeaderFooter.Accept(DocumentVisitor visitor) ?.?.?(HeaderFooterType ?) ?.?.?(Section ?) ?.?.?(Document ?, Stream ?, String ?) Aspose.Word.Document.?(Stream ?, String ?, SaveFormat ?) Aspose.Word.Document.Save(String fileName, SaveFormat fileFormat) INTRANET.consulterAudition.CreatePdfDoc(Document doc, String fileName) +110 INTRANET.consulterAudition.SaveAsPdf(String code, String auditionid) +16078 INTRANET.consulterAudition.Page_Load(Object sender, EventArgs e) +101 System.Web.UI.Control.OnLoad(EventArgs e) System.Web.UI.Control.LoadRecursive() System.Web.UI.Page.ProcessRequestMain()

The only thing I changed when using v3 is the AppendDoc function

private void AppendDoc(Aspose.Word.Document dstDoc, Aspose.Word.Document srcDoc)
{
    for (int i = 0; i < srcDoc.Sections.Count; i++)
    {
        Aspose.Word.Section sourceSection = srcDoc.Sections;
        Aspose.Word.Section newSection = (Aspose.Word.Section)dstDoc.ImportNode(sourceSection, true);
        dstDoc.Sections.Add(newSection);
    }
    while (srcDoc.Sections.Count > 0)
    {
        Aspose.Word.Section section = srcDoc.Sections[0];
        // The section must first be removed before it can be inserted into a document.
        srcDoc.Sections.RemoveAt(0);
        dstDoc.Sections.Add(section);
    }
}

before, I used what’s commented out…

This is the word document that fails.

I saved it (with aspose.word) as a word document.

Then opened it from aspose.word to save it as xml for pdf and it fails.

docFinal.Save(@"c:\ProgPrevention.doc");
CreatePdfDoc2();
private void CreatePdfDoc2()
{
    Aspose.Word.License license = new Aspose.Word.License(); 
    license.SetLicense(@"c:\Aspose.Custom.lic");
    Aspose.Word.Document doc = new     Aspose.Word.Document(@"c:\ProgPrevention.doc");
    doc.Save(@"c:\test.xml", Aspose.Word.SaveFormat.FormatAsposePdf);
}

Any update with this??

Thanks!

Thank you, we are looking into the issue.

alright, I’m waiting for this

Let me know asap! Thanks

The issue is definitely related to font styles. If you clear font formatting of the document, the issue disappears. Now I’m trying to figure what style causes the problem. Also, I think we will fix the issue asap.

how can I clear it until you fix it ?

After further investigation it proved that the styles are okay but the issue was caused by difference of font size of {PAGE}, {NUMPAGES}, and the text of the paras that contain these fields. Sounds strange, however, making footer font size similar everywhere helps. Please see attached.

Hi,

I just fixed the font size of page and numpages to be the same. In fact, the whole footer is now the same font / fontsize and still get the same error.

I attached the new generated word doc.

Thanks and I’m looking foward to hear from you!

In this version of the document the hyperlinks whose formatting was similar to the paras’ one caused the error. So in the meantime (until the hotfix is out) I’ve cleared the hyperlink formatting. Please see attached and report if it works.

where are the hyperlinks?

I didn’t see any!

When do you think the hot fix will be release?

Ok, found it!

1- how do you turh the formatting off?
2- how do you find that the error is at that precise place? is it possible for me to find those kind of error? this would be helpful until the fix is release!

Thanks !

There are several hyperlinks www.csst.qc.ca contained in the document.

So have you got it working? I think we will release the hotfix in a few days.

Will have to wait 'til tomorrow to know if it works… don’t have the stuff to try it at home!

  1. I cleared the formatting of the whole paras using the MS Word Formatting toolbar (Clear Format command) and then made it Arial 10pt centered again.

  2. That’s why it took a while. The problem is that error is being occured in one place of the code but can be caused by different things in the document, so I’m afraid such the places could be too custom to find them. The hotfix is the real solution and we’ll try to release it asap.

    It surely works for me with Aspose.Word 3.0.1, I’ve double checked it.

Hi,

I cleared the formatting of www.csst.com then set it back to Arial 10, but when I mouseover it, it still says press CTRL+ click to follow link

and the document still erroring out as previously stated

Have you tested the attachment? It definitely works.

Anyway I guess you should just wait for the hotfix, it will be out early next week. This will resolve the issue at one stroke.