Aspose does'nt display images(taken from unix box) while rendering Wordfile from html

Hi Team,

For our project we have below requirement:

We are passing an htmlInput(attached)file from our application and rendering
word file through aspose.
The Steps of rendering the word file is there in standalone code. Please refer.


Issue :::::::::::::::
When we run this code (as attached) and pass the image(saved
in windows environment) in html file. The Image is available in word document.

On the Other hand, when we pass the input html code and image src is taken
from unix box.

Word file generated with the same above code cannot handle image and shows a
cross sign.

Please suggest on this how can we get an image on wordfile generated from html which has image taken from unix box Appreciate for soon reply.

Attached are the inputhtml,Word file generated from Windows and the same
generated from Unix Box

Thanks

Sonam

Hi Team,

Any update on the above please.

Thanks
Sonam

Hi Sonam,

Thanks for your inquiry. The image path is ‘C:\Users\username\Desktop\home.jpeg’. Please make sure that image exists where you are executing the Aspose.Words code. Please note that Aspose.Words mimics the same behavior as MS Word does. Please open the same HTML in MS Word at the same system where you are using Aspose.Words and check the output.

Hi Tahir,

The issue, I am facing is that the image is easily rendered in word file when the html source contains image stored at windows location. That is:
The image stored at location:: C:\Users\username\Desktop\home.jpeg
is rendered on word file from html with aspose.
<img alt="" src=" C:\Users\username\Desktop\home.jpeg" /> - working

However,
The Image stored at unix server :: /temp/somefolder1/somefolder2/home.jpeg is not rendered on word file from with aspose.
<img alt="" src="/tmp/ somefolder1/somefolder2" /> - Not working

The UNIX path where image is stored is given correct in HTML src. This is
different behavior of aspose when image is in UNIX box.

You can try on your side as below:
In my standalone code given in first query
,if the image path for windows is replaced with image path in UNIX. The code won’t
work out.That is the image is not available on word file

Please try on your side. Kindly provide the solution what changes need to be
done on code.

Appreciate for a soon reply.Hope you understand my query.Revert for any doubts.

Thanks

Sonam

Hi Sonam,

Thanks for sharing the detail. I have tested the scenario and have managed to reproduce the same issue at my side. For the sake of correction, I have logged this problem in our issue tracking system as WORDSJAVA-907. I have linked this forum thread to the same issue and you will be notified via this forum thread once this issue is resolved. We apologize for your inconvenience.

I suggest you please use the file:// before image path as shown below to fix this issue. Hope this helps you.

Hi Tahir,

Thanks for logging the ticket.We have tried using the below option for temporary fix and its works fine.


However we are facing some other issue.
The Image is now getting rendered on word file.But is not getting rendered on PDF.We are using indesign for converting Word file to PDF.

Point to note here : Aspose created word document having image file does not render the image on pdf using Indesign.

However manually created word document having image file renders the image on PDF using the same Indesign code.

Attached are the files:
WordAspose – Word file craeted using Aspose code having image file
WordManual – Word file craeted manually code having image file.
PDF_Aspose – PDF generated from WordAspose using Indesign.
PDF_Manual – PDF generated from WordManual using Indesign.

Please assist on this.Appreciate for soon reply.

Thanks
Sonam

Hi Sonam,

Thanks for your inquiry.

Aspose.Words for Java depends upon the JAI package from Sun in order to process images. Most of our Java products depend upon the JAI package (Java Advanced Imaging) from Sun in order to process images. Please find the system requirements from here:
https://docs.aspose.com/words/java/system-requirements/

If you still face problem, please share your image here for testing purpose. I will investigate the issue on my side and provide you more information.

Hi Awais,

To clarify once more…image is rendering on WordFile but not on pdf when word is generated from aspose.

Please find attach the image.The image is in png format.Same issue occurs with jpeg and gif formats .

Thanks
Sonam

Hi Awais,
I have gone through the system requirements.And have added the below new jars.But the image is still not available on pdf.
jai_windows-i586
jai_imageio_windows-i586

The Image as I explained earlier is rendering on Word File but not on PDF.
Please assist on this.

Thanks
Sonam

Hi Sonam,

Thanks for your inquiry. Please use the the file:// before image path when you save the document to Docx and PDF.

I have tested the scenario at Ubuntu and have not found the shared issue. I have attached the input html and output Pdf with this post for your kind reference.

Hi Tahir,
I have tried the above option too.But still facing the same issue.Please assist.Image is not rendering on pdf.

Thanks
Sonam

Hi Sonam,

Thanks for your inquiry. Could you please use the attached in.html and convert it to Pdf using following code example and let us know if you still face the same issue? Please put the home.png file at the same location of in.html. The img tag in in.html is .

Document doc = new Document(MyDir + "in.html");
doc.save(MyDir + "Out.pdf");

Hi Tahir,

As suggested I have tried two options as below.


  1. Image is kept in same folder where input html file is kept and ,the img tag in html is :
    <img alt="AW" src="home.png" />

code is used as suggested i.e :

Document doc = new Document(MyDir + "in.html");
doc.save(MyDir + "Out.pdf");

Result :: Image is not appearing
on PDF.A cross sign appears.


  1. Image is kept in same folder where input html is kept and The img tag in html is :
    <img alt="AW" src="D:\\mydir1\\mydir2\\home.png" />

code is used as suggested i.e :

Document doc = new Document(MyDir + "in.html");
doc.save(MyDir + "Out.pdf");

Result :: Image is
appearing on PDF.


Please suggest this unusual behaviour.

Thanks
Sonam Arora

Hi Sonam,

Thanks for your feedback. I suggest you please upgrade to the latest version of Aspose.Words for Java 14.6.0 from here:
https://releases.aspose.com/words/java

Please share the following detail for further investigations.

  • What environment are you running on?
    • OS (Linux Version detail)
    • Architecture (32 / 64 bit)
    • Java version
  • Please supply us with the output Pdf document showing the undesired behavior

As soon as you get these pieces of information to us we’ll start our investigation into your issue.

Hi Tahir,
Even after upgrading to Aspose.Words for Java 14.6.0 .I am still facing the same issue.Image is not rendering on PDF when the img tag is as below.

Please find the below details :

  • What environment are you running on?
    • OS (Linux Version detail) – Windows7
    • Architecture (32 / 64 bit) – 64 bit
    • Java version – Java version 1.7
  • Please supply us with the output Pdf document showing the undesired behavior - Attached.

Thanks
Sonam

Hi Tahir,

In above two replies we are moving away from require issue.
The issue is explained below .Point to note here : we are taking the input html saving the word through aspose code and then rendering the pdf through Indesign and is explained below in details once again :


The Image is getting
rendered on word file.But is not getting rendered on PDF.We are using Indesign(Please note this) for converting Word file to PDF.

Point to note here : Aspose created word document having image file does not render the image on pdf using Indesign.

However manually created word document having image file renders the image on PDF using the same Indesign code.

Attached are the files:
WordAspose – Word file craeted using Aspose code having image file
WordManual – Word file craeted manually code having image file.
PDF_Aspose – PDF generated from WordAspose using Indesign.
PDF_Manual – PDF generated from WordManual using Indesign.

Please assist on this.

Thanks
Sonam

Hi Sonam,

Thanks for sharing the detail.

*sonam.arora:

Even after upgrading to Aspose.Words for Java 14.6.0 .I am still facing the same issue.Image is not rendering on PDF when the img tag is as below.

Please find the below details :
What environment are you running on?
OS (Linux Version detail) – Windows7
Architecture (32 / 64 bit) – 64 bit
Java version – Java version 1.7
Please supply us with the output Pdf document showing the undesired behavior - Attached.*

I have tested the scenario at Windows 7 (64 bit) and have not found the shared issue. Could you please convert the in.html to Pdf/Docx at some different system? There should be an issue with this html to Pdf conversion.

Document doc = new Document(MyDir + "in.html");
doc.save(MyDir + "Out.docx");
doc.save(MyDir + "Out.pdf");

*sonam.arora:

The issue is explained below .Point to note here : we are taking the input html saving the word through aspose code and then rendering the pdf through Indesign and is explained below in details once again :


The Image is getting rendered on word file.But is not getting rendered on PDF.We are using Indesign(Please note this) for converting Word file to PDF.

Point to note here : Aspose created word document having image file does not render the image on pdf using Indesign.*

Could you please share some more detail along with steps to reproduce this issue at our end? The shared PDF (PDF_Aspose.pdf) has not not generared using Aspose.Words.

Are you facing the same issue without using Indesign? Please share the detail about the usage of Indesign and Aspose.Words in your scenario. We will then provide you more detail about your query.

There is no issue while converting the shared input html to Pdf. Perhaps, you are missing something at your end.

Hi Tahir,
Thanks for the response.

I am afraid we are getting away from main issue.

For the first part in your last reply.I am not sure,why we are checking on rendering the Image on PDF ,the PDF we are directly saving through aspose through line of code as : :doc.save(MyDir + “Out.pdf”);
In our application we are first saving the word through aspose using line of code :: : :doc.save(MyDir + “Out.docx”); and then converting it into PDF through In design.The issue is the image is rendering on word file but not on pdf(PDF is generated through Indesign tool and word file is generated through aspose.)

Second part :
Steps are below ::::
Aspose saved word file :::

  1. Taking default Word
    Empty document from project workspace.

  2. Creating builder of this
    word file using aspose code :
    final com.aspose.words.Document asposeDoc = new
    com.aspose.words.Document(defaultWordFile);

    final DocumentBuilder builder = new DocumentBuilder(asposeDoc);

  3. Inserting htmlInput
    to this asposeDoc using below code.
    builder.insertHtml(Inputhtml);

  4. Saving
    builder.getdocument to designated path using below code :
    builder.getDocument().save(designatedPath);

  5. The word file is
    finally converted to PDF using Indesign tool(Kindly test this with your Indesign tool.)
    Note :: Issue is image is not rendering on PDF file.

Manually saved word file through microsoft word.

  1. Save the Microsoft Word document having image and data same as in attached file.
    2.Convert this MS word file to PDF through Indesign tool.
  2. Image is rendering on PDF.

Please carry out the above steps and convert aspose created word and Microsoft created word to PDF and check the why image is not rendering on PDF which we rendered from aspose created word file.

Attached are the below files ::

  1. WordManual :Microsoft created word file
    2.PDF_Manual : PDF got from WordManual through Indesign tool.
    3.WordAspose :aspose saved word file
    4.PDF_Aspose : PDF got from WordAspose through Indesing tool.
  2. Inputhtml :: HtmlInput file

You can use Indesign tool to check the PDF output for better clarification.
Please assist .Appreciate for soon reply.

Thanks
Sonam Arora

Hi Sonam,

Please accept my apologies for your inconvenience.

*sonam.arora:

In our application we are first saving the word through aspose using line of code :: : :doc.save(MyDir + “Out.docx”); and then converting it into PDF through In design.The issue is the image is rendering on word file but not on pdf(PDF is generated through Indesign tool and word file is generated through aspose.)


  1. The word file is finally converted to PDF using Indesign tool(Kindly test this with your Indesign tool.)
    Note :: Issue is image is not rendering on PDF file.

You can use Indesign tool to check the PDF output for better clarification.*

Thanks for sharing the detail. I will setup the Indesign tool at my end to convert Word document to Pdf.

Could you please share which version of Indesign tool you are using?

Hi Tahir,
Thanks for understanding the requirement.

We are using v4.1 for Indesign tool.Please check.

Thanks
Sonam Arora