Free Support Forum - aspose.com

Upgrading Aspose version, generated letter now shows "Error! Bookmark not defined." instead of recipient name and address

We are testing out upgrading Aspose.Words from 15.5.0 to 18.5 using a trial version and a temporary license. We are using a particular letter template to test with, which displays the recipient name and address with 15.5.0. But with 18.5, instead it displays Error! Bookmark not defined.

The portion of the letter template in question is simply:
{ ADDRESS }

If I right-click it and select Toggle Field Codes, it changes to:
«LetterRecipientFullName»
«LetterRecipientAddress»

Can we please get some assistance with this issue? Is there an explanation for this error? Do you need any more information?

We have already encountered another backward compatibility issue, with a line break before a TableEnd merge field causing an error only with 18.5. Is there a way to learn what other ways the new Aspose version is not backward compatible? Is there a comprehensive resource we could reference?

@amitnik,

Thanks for your inquiry. To ensure a timely and accurate response, please ZIP and attach the following resources here for testing:

  • Your sample input Word document
  • Aspose.Words 18.5 generated output DOCX file showing the undesired behavior
  • Aspose.Words 15.5 generated output DOCX file showing the correct output
  • Please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

AsposeTest.zip (125.9 KB)

We use Aspose for generating PDF documents, so that’s what I can show you. I don’t know how to go about providing a standalone application. But I’ve done some painstaking investigation, and pinpointed the issue down to the inclusion of hard line-breaks/paragraph breaks between merge fields within Quote or If statements within a variable declaration. Hopefully this is enough to make the problem clear. Using soft line breaks/vertical tabs seems to get around this, but the issue is that this does not occur in 15.5, and this lack of backward compatibility creates a significant impediment to going through with the upgrade.

Again I ask if there is a resource for learning what ways the new Aspose version is not backward compatible. We wouldn’t want to be blindsided by any other issues.

@amitnik,

I am afraid, we do not see above error in PDF when running the following code (see awjava-18.5.pdf (58.7 KB)):

Document doc = new Document("D:\\temp\\AsposeTestTemplate.docx");

doc.getMailMerge().execute(new String[] { "LetterRecipientFirstName",
                "LetterRecipientAddressLine1", "LetterRecipientAddressLine2", "LetterRecipientCity", "LetterRecipientStateProvince", "LetterRecipientZipPostalCode" },
        new Object[] { "PROXYfd*",
                "AddressLine1", "AddressLine2", "City", "Province", "Postal Code"});

doc.save("D:\\Temp\\awjava-18.5.pdf");

Are you using some different code? Please test it on your end and let us know what should we add to above code to be able to reproduce this problem on our end?

Try this code, which follows the relevant parts of our workflow. I’ve noted two problem lines:

Document templateDocument = new Document("D:\\temp\\AsposeTestTemplate.docx");

// process field tags (hardcoded for this example - note that using braces in the tag values doesn't seem to make difference)
MailMerge mailMerge = templateDocument.getMailMerge();
mailMerge.execute(new String[] { "LetterRecipientFirstName", "LetterRecipientFullName", "SentDate",
                        "LetterRecipientAddressLine1", "LetterRecipientAddressLine2", "LetterRecipientCity", 
                        "LetterRecipientStateProvince", "LetterRecipientZipPostalCode" },
                new Object[] { "{First Name}", "{Full Name}", "{Sent Date}",
                        "{AddressLine1}", "{AddressLine2}", "{City}", "{Province}", "{Postal Code}"});

// Comes in as a parameter, but empty for this template
Map<String, byte[]> imageMap = new HashMap<>();

// process images
mailMerge.setFieldMergingCallback(new AsposeImageFieldMergingCallback(imageMap));
mailMerge.execute(new String[]{}, new Object[]{}); // <-- Problem Line 1

// This is to ensure standard image tags show up in template preview in Admin
templateDocument.updateFields(); // <-- Problem Line 2

templateDocument.save("D:\\Temp\\awjava-18.5.pdf");

Commenting out both problem lines causes everything in the generated PDF to display without error, though some combinations have extra spacing between lines that version 15.5 didn’t produce:
Aspose18TestTemplatePreviewResult_ProblemLinesCommentedOut.pdf (50.9 KB)

Hopefully this is enough for you to reproduce the issue.

@amitnik,

Empty mail merge (mailMerge.execute(new String[]{}, new Object[]{})) internally calls Document.updateFields method. You can remove this line.

So, calling Document.updateFields only (problem Line 2) after executing the main mail merge causes this issue (Error! Bookmark not defined.) in 18.5.

So, the following simplified code works with 15.5 but not with 18.5:

Document doc = new Document("D:\\temp\\AsposeTest\\AsposeTestTemplate.docx");

doc.getMailMerge().execute(new String[]{"LetterRecipientFirstName", "LetterRecipientFullName", "SentDate",
                "LetterRecipientAddressLine1", "LetterRecipientAddressLine2", "LetterRecipientCity",
                "LetterRecipientStateProvince", "LetterRecipientZipPostalCode"},
        new Object[]{"{First Name}", "{Full Name}", "{Sent Date}",
                "{AddressLine1}", "{AddressLine2}", "{City}", "{Province}", "{Postal Code}"});

doc.updateFields(); // <-- Problem Line 2

doc.save("D:\\Temp\\AsposeTest\\awjava-15.12.docx");
doc.save("D:\\Temp\\AsposeTest\\awjava-15.12.pdf");

For the sake of correction, we have logged this problem in our issue tracking system. The ID of this issue is WORDSNET-16904. We will further look into the details of this problem and will keep you updated on the status of correction. We apologize for your inconvenience.

Thank you. I’m not able to view the issue in your tracking system, but please also try to address the issue regarding extra spacing between lines that 18.5 has that didn’t occur in 15.5.

@amitnik,

Sure, we have updated the issue description accordingly and will inform you via this thread as soon as both these problems (Bookmark not defined and Vertical Spacing issue) are resolved.

The issues you have found earlier (filed as WORDSNET-16904) have been fixed in this Aspose.Words for .NET 18.8 update and this Aspose.Words for Java 18.8 update.