InsertImage generates X into PDF at Wildfly using Java

Hi all,
I have a strange problem.
I select an image from DB, which is base64 encoded string, then I insert it decodd into document
builder.insertImage(Base64.decodeBase64((String) e.getFieldValue()))

Everything works like a charm, but only when I test agains my local wildfly.
If the app is deployed on remote Wildfly, it does not work anymore. I get an X instead of the picture.

I use aspose.words 15.1.0 with JDK8
Do you have any suggestions ?

Regards
Matej

@narciskom

Please make sure that your application has full access rights where you are reading and writing Base64 image. We suggest you please use the latest version of Aspose.Words for Java 20.5.

Hi,

I was able to solve the problem.

Problem was I generate a relative path on the server into img src and aspose didnt find it then.
img src="…/…/wildfly/standalone/tmp/Aspose.Words.6e045b8c-3a54-4ff0-9dd4909c12264b33.001.png" width=“150” height=“76” alt=""
When I changed it to absolute, it works.

thanks

Regards
Matej

@narciskom

It is nice to hear from you that your problem has been solved. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.

Hi Tahir,

I have to reopen the issue. On linux server is does not work, and Im out of ideas, becuase everything looks fine to me.

I have 2 aspose calls:

  • first call loads the image from DB and aspose generates HTML

  • in this html there is absolute path to the image generated by aspose

  • this image is completelly fine, it is in FS, it is valid image

  • the parent dir has 777 rights, the image itself 755

  • second call should take this HTML and generate a PDF, but in this PDF I get only the famous X instead of the image

I tried also to play with IResourceLoadingCallback, IResourceSavingCallback and also IWarningCallback but I cannot see where the problem is. In the warnings there is nothing regarding this problem.

Could you please tell me what can I do more ? How can I debug this issue ?

thanks

Best regard
Matej

@narciskom

In your case, we suggest you please save the HTML to disk from the database and import it into Aspose.Words’ DOM. Save the document to DOCX format and share if you face this issue in it.

Please also open the HTML in browser to check the image’s visibility. Most probably, this issue is related to incorrect image’s path.

Hi Tahir,

I cannot take the HTML and test in browser. The image has a absolute path on the server FS, not a web URL, like this
img src="/abs/path/to/dir/…/…/wildfly/standalone/tmp/Aspose.Words.253a9c6e-c5fc-4b01-b940-50ea1b9f43f2.001.png" width=“150” height=“76”

And the path is for sure good, I logged it, copied it from the log and did
file /abs/path/to/dir/…/…/wildfly/standalone/tmp/Aspose.Words.253a9c6e-c5fc-4b01-b940-50ea1b9f43f2.001.png
and the result was PNG image.

Then I also downloaded it, and opened on my client machine. It was OK

Regards
Matej

@narciskom

To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document.
  • Your input image and HTML.
  • Please attach the output PDF/Word file that shows the undesired behavior.
  • Please create a simple Java 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.

PS: To attach these resources, please zip and upload them.