Graphic image in document is getting deleted after update properties

Hello Team,

We are using Aspose.Word Java version 20.12.

When we use the graphical image in the document and perform update properties. Image is getting removed.Logo_Getting_Disappeared.JPG (7.0 KB)

But if we make the graphical image to convert to shapes, then it works.Graphical_Image_Disappears.JPG (32.3 KB)

@vspkr,

Please ZIP and attach the following resources here for testing:

  • Your simplified input Word document you are getting this problem with
  • Aspose.Words version 21.3 generated output file showing the undesired behavior
  • A standalone simple Java application (source code without compilation errors) that helps us to reproduce your current problem on our end and attach it here for testing. Please do not include Aspose.Words JAR files in it to reduce the file size.

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

Source_Code_and_Sample_Doc.zip (106.1 KB)

Attached the source code and sample document which gives the error. Even with 21.3 Jar file it is failing. Please help us in resolving this issue.
Current version - 20.12.

Do we have any workaround to lock the graphic image in code, please share those details as well if any.

@vspkr,

I am afraid, we were unable to execute your code on our end. The Java code you provided is causing a few compile time errors on our end. For example, we are unable to resolve following lines:

import matrix.db.Context;
import matrix.db.JPO;
// and associated method calls
JPO.unpackArgs
com.matrixone.apps.domain.util.MqlUtil.mqlCommand ...
matrix.db.JPO.invoke ... etc

We request you to please simplify your code and attach a new code (minimal version) that still reproduces the same problem along with the Aspose.Words generated output file showing the undesired behavior.

AsposePoc.zip (1.0 KB)

Code which i sent earlier was integrated with our API’s. Please refer the sample code which removes all dependencies.

@vspkr,

After an initial test with the licensed latest (21.3) version of Aspose.Words for Java, I was unable to reproduce this issue on my end. Please see the following output DOCX and PDF files which were generated on my end:

Code used to produce above DOCX and PDF files is as follows:

Document doc = new Document("C:\\temp\\Source_Code_and_Sample_Doc\\Graphic_Template.docx");

boolean blnIsTocLocked = false;
CustomDocumentProperties properties = doc.getCustomDocumentProperties();
FieldToc toc = new FieldToc();
for (Field field : doc.getRange().getFields()) {
    if (field.getType() == FieldType.FIELD_TOC) {
        toc = (FieldToc) field;
        toc.isLocked(true);
        blnIsTocLocked = true;
        break;
    }
}

for (DocumentProperty prop : properties) {

    if (prop.getName().equalsIgnoreCase("MXType")) {

        prop.setValue("New_Type");


    } else if (prop.getName().equalsIgnoreCase("MXName")) {
        prop.setValue("NewName");

    } else if (prop.getName().equalsIgnoreCase("MXRevision")) {
        prop.setValue("NewRev");

    } else if (prop.getName().equalsIgnoreCase("MXCurrent")) {
        prop.setValue("New_State");

    } else if (prop.getName().equalsIgnoreCase("MXDescription")) {
        prop.setValue("New_Description");

    } else if (prop.getName().equalsIgnoreCase("MXOriginator")) {
        prop.setValue("New_Owner");

    } else if (prop.getName().equalsIgnoreCase("MXPolicy")) {
        prop.setValue("New_Policy");
    } else if (prop.getName().equalsIgnoreCase("MXActual_state_Release")) {
        prop.setValue("New_Release");
    }

}

doc.updateFields();
if (blnIsTocLocked) {
    toc.isLocked(false);
}

doc.save("C:\\Temp\\Source_Code_and_Sample_Doc\\awjava-21.3.docx");
doc.save("C:\\Temp\\Source_Code_and_Sample_Doc\\awjava-21.3.pdf");

So, we suggest you to please upgrade to the latest 21.3 version of Aspose.Words for Java.

Hi Hafeez,

This is reproducible even with latest version in our Prod environment server, we are using 1.8.171 Java and REHL 7.2

Is there any server specific env variable needs to be set?

Any specific settings needs to be taken care?

Regards

@vspkr,

We will prepare the required platform to simulate the environment as that of yours. As soon as everything is setup, we will test your scenario and post the results here for your kind reference.

@vspkr,

I am afraid, I am still unable to reproduce this problem on Linux based OS on my end. Can you please run the code from my previous post on the problematic machine and share the output DOCX and PDF files here for our reference?

Hi,

we again re-deployed all the jar file and cleared all caches yesterday and it started working. Thanks for your support!

@vspkr,

It is great that you were able to resolve this issue on your end. Please let us know any time you may have any further queries in future.