Aspose.words - DocumentBuilder.insertHTML does not paint the image

Last post 11-10-2011, 2:28 AM by awais.hafeez. 5 replies.
Sort Posts: Previous Next
  •  10-24-2011, 1:21 AM 337560

    Aspose.words - DocumentBuilder.insertHTML does not paint the image Java

    Attachment: Present (inaccessible)
    Hi,

    I have this issue with DocumentBuilder.insertHTML() api.
    When i try to insert a HTML containing the image. it does not paint the Image instead gives a cross sign.

    Here's a image on this server -
    https://plm.sungard.com/ImageRenderer?ImageID=3003121

    If you hit this on the web url, you will get the image. However, when you try inserting this through Aspose.words, it wont give the image. I tried writing this code. It does not work.

    File w_file = new File("C:/Documents and Settings/akhan/Desktop/Print.doc");
    DocumentBuilder w_bldr = new DocumentBuilder();
    Document w_doc = w_bldr.getDocument();
    String w_txt = "<p><img src=\"https://plm.sungard.com/ImageRenderer?ImageID=3003121\" alt=\"\" width=\"178\" height=\"129\" /></p>";

    w_bldr.insertHtml(w_txt);
    w_doc.save("C:/Documents and Settings/akhan/Desktop/Print.doc");


    Please help me out with this. I am also attaching the word that I get

    Regards,
    Aslam




     
  •  10-24-2011, 2:10 AM 337565 in reply to 337560

    Re: Aspose.words - DocumentBuilder.insertHTML does not paint the image

    Hi Aslam,

    Thanks for your inquiry.

    While using your code and the latest version of Aspose.Words i.e. 10.5.0, I was unable to reproduce this issue on my side. However, I would like to suggest you the following link for downloading and using the latest version of Aspose.Words:


    Moreover, to insert a picture inside Word document via HTML, please see the following code snippet that worked for me:

    Document doc = new Document();
    DocumentBuilder builder = new DocumentBuilder(doc);

    // approach 1
    string html = @"<p><img src='https://plm.sungard.com/ImageRenderer?ImageID=3003121' alt='test image' width='178' height='129' /></p>";
    builder.InsertHtml(html);

    // approach 2       
    builder.InsertImage("https://plm.sungard.com/ImageRenderer?ImageID=3003121", 178, 129);

    doc.Save(@"c:\test\imageInDoc.doc"); 

    I hope, this will help.

    Best Regards,

    Awais Hafeez
    Support Developer
    Aspose Sialkot Team
    Aspose - Your File Format Experts

    Keep in touch! We're on Twitter and Facebook
     
  •  10-25-2011, 2:17 AM 337873 in reply to 337565

    Re: Aspose.words - DocumentBuilder.insertHTML does not paint the image

    Hi Awais,

    I tried the insertImage thing it gave the following error.

    Exception in thread "main" java.net.ConnectException: Connection timed out: connect
        at java.net.TwoStacksPlainSocketImpl.socketConnect(Native Method)
        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:337)
        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:198)
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:180)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:157)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391)
        at java.net.Socket.connect(Socket.java:579)
        at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:607)
        at sun.security.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:160)
        at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:388)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:483)
        at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:278)
        at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:335)
        at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191)
        at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:928)
        at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1296)
        at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
        at java.net.URL.openStream(URL.java:1035)
        at asposewobfuscated.of.aI(PalSystem.java:88)
        at com.aspose.words.DocumentBuilder.insertImage(DocumentBuilder.java:1186)
        at com.aspose.words.DocumentBuilder.insertImage(DocumentBuilder.java:1092)
        at com.tufan.digite.utils.Test.main(Test.java:20)


    Regards,
    Aslam

     
  •  10-25-2011, 11:18 AM 338016 in reply to 337873

    Re: Aspose.words - DocumentBuilder.insertHTML does not paint the image

    Hi Aslam,

     

    Thank you for additional information. As I can see from stack trace the issue is not related to Aspose.Words. There is something with connection to the site where the image is. Maybe your firewall blocks the request. But anyways there is no problem in Aspose.Words here.

     

    Best regards,


    Alexey Noskov
    Developer/Technical Support
    Aspose Auckland Team
     
  •  11-10-2011, 1:02 AM 341216 in reply to 337565

    Re: Aspose.words - DocumentBuilder.insertHTML does not paint the image .NET

    Hi,

    Thanks for your post. I am facing same issue. In localhost aspose is able to write image on docx file. But when i deploy the application on IIS. it is making cross sign in place of image.Kindly advise some possible solutions. Thanks

    Filed under: documentbuilder;IIS;Image
     
  •  11-10-2011, 2:28 AM 341270 in reply to 341216

    Re: Aspose.words - DocumentBuilder.insertHTML does not paint the image

    Hi,

    Thanks for your inquiry. Apparently, it seems that when the website is deployed to IIS, the path to the image is not resolving correctly. Please try using HttpRequest.MapPath Method to convert virtual paths to absolute ones. 

    Moreover, if the issue is still occurring, could you please share the code you are getting problems with here for testing. I will investigate the issue on my side and provide you more information.

    Best Regards,

    Awais Hafeez
    Support Developer
    Aspose Sialkot Team
    Aspose - Your File Format Experts

    Keep in touch! We're on Twitter and Facebook
     
View as RSS news feed in XML