Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Fri Jan 31, 2014 2:01 pm

Hi,
I have use spire doc for Converting Html to image.

i am using below code

Code: Select all
 Document document = new Document();
        document.LoadFromFile(@"E:\data.html", FileFormat.Html, XHTMLValidationType.None);


        Image image = document.SaveToImages(0, ImageType.Bitmap);



When i am load document i am getting error "Illegal characters in path."

My path is correct,I thought my html has some invalid characters,
I am attaching text file with my html code, please look and let me know, where i am doing wrong..





please help



this is my html .
Code: Select all
<!DOCTYPE html><html xmlns='http://www.w3.org/1999/xhtml' style class=' js no-touch svg inlinesvg svgclippaths no-ie8compat csstransforms csstransforms3d csstransitions'><head><link rel='stylesheet' href='http://localhost/RedLine/css/DesignStyle.css'/><style>#designarea, .designmainareaall, #workarea {background:none !important;}.ui-resizable-handle {display:none;} body{padding-top:50px;}</style></head><body><section id='designhtml' class='main'>
    <form>
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJNjkxNDUwNDk5ZGTQ/wnFDqIgR0OqKKCP1QXdfQ/n1TCJgcd9qNG6Y3yc9Q==">
</div>
       
        <div id="printarea">
            <div>
                <div id="designinfo" style="margin-left: 45px;margin-bottom: 5px;font-weight: bold;">
                   
                </div>
                <div class="row" id="designarea">
                    <div class="span8" id="designrightarea">
                        <div class="designmainarea">
                            <div class="designmainareaall">
                                <div id="workarea" style="background: #bfbfbf; position: relative; height: 550px; overflow: visible;">
                                                                       
                                   
                                                                       
                                    <div id="workarea_inner" style="left: 21px; top: 0; width: 1200px; height: 530px; position: relative; overflow: visible;">
                                        <div class="gridlinearea" style="width: 384px; height: 75px; background-size: 36px 36px, 36px  36px, 6px  6px, 6px  6px; top: 105px; left: 106px; position: relative;"></div>
                                    <div id="product1" class="product" style="top: 107px; left: 106px; z-index: 1;"><div class="resize_area" style="-webkit-transform: rotate(0deg);"><img src="http://localhost/RedLine/images/ProductImages/bfy_1aa_1LEAF/843571ed-ae19-4dde-ba49-726016be60bf.jpg?abc=0.9743638646323234" resw="true" resh="true" prc="t1" d="10.25" resd="true" alt="" style="height: 90px; width: 60px;"><div class="hdims">10.00</div><div class="vdims" style="top: -68px; left: -38px;">15.00</div><div class="ui-rotatable-handle ui-draggable"></div></div></div><div id="product2" class="product" style="top: 108px; left: 212px; z-index: 2;"><div class="resize_area" style="-webkit-transform: rotate(0deg);"><img src="http://localhost/RedLine/images/ProductImages/bfy_1aa_1LEAF/11da108a-0254-40fe-830f-e2a814bc84ba.png?abc=0.36420341534540057" resw="true" resh="true" prc="Example" d="13.86" resd="true" alt="" style="height: 72px; width: 72px;"><div class="hdims">12.00</div><div class="vdims" style="top: -59px; left: -44px;">12.00</div><div class="ui-rotatable-handle ui-draggable"></div></div></div><div id="product3" class="product" style="top: 105px; left: 322px; z-index: 3;"><div class="resize_area" style="-webkit-transform: rotate(0deg);"><img src="http://localhost/RedLine/images/ProductImages/bfy_1aa_1LEAF/7fd022b6-3602-48d8-b08c-b121c0910fae.png?abc=0.7803066312335432" resw="true" resh="true" prc="t45" d="12.52" resd="true" alt="" style="height: 90px; width: 60px;"><div class="hdims">10.00</div><div class="vdims" style="top: -68px; left: -38px;">15.00</div><div class="ui-rotatable-handle ui-draggable"></div></div></div><div id="product4" class="product" style="top: 108px; left: 430px; z-index: 4;"><div class="resize_area" style="-webkit-transform: rotate(0deg);"><img src="http://localhost/RedLine/images/ProductImages/bfy_1aa_1LEAF/4508e827-25cf-4ebd-8eb5-bb6f5fbc230e.png?abc=0.0092893335968256" resw="true" resh="true" prc="trep548" d="13.65" resd="true" alt="" style="height: 90px; width: 60px;"><div class="hdims">10.00</div><div class="vdims" style="top: -68px; left: -38px;">15.00</div><div class="ui-rotatable-handle ui-draggable"></div></div></div></div>
                                </div>

                            </div>
                        </div>
                    </div>
                    <div class="clr"></div>
                </div>
            </div>
           
            <div id="dialog_resize" title="Resize" style="display: none;">
                <div>
                    Width :<input type="text" id="txtwidth" class="numeric" style="margin-left: 10px;">
                </div>
                <div style="padding-top: 5px;">
                    Height :<input type="text" id="txtheight" class="numeric" style="margin-left: 6px;" />
                </div>
            </div>
        </div>

    </form>


<div id="loading-indicator-form1-overlay" class="loading-indicator-overlay" style="width: 1366px; height: 551px; left: 0px; position: absolute; top: 5px; z-index: 5000;"></div><div id="loading-indicator-form1" class="loading-indicator" style="position: absolute; z-index: 5001; left: 633px; top: 205.5px;"></div></section></body></html>

nehal4monto
 
Posts: 1
Joined: Tue Jan 21, 2014 6:37 am

Mon Feb 03, 2014 6:15 am

Hi,

I have done some test with your HTML code. Because of lack of image files and css file, I made them in my computer and put them in a web app with port 52430. And then I corrected the port of the url of all external resource in your html file.
I run you code with with Spire.Doc Pack Version:5.0 (version fo dll 5.0.12.3020 in my computer, you can get Spire.Doc v5.0 from http://www.e-iceblue.com/Download/downl ... t-now.html), it works fine.

I suggest you run your code with my files in your computer to help us fine the key cause. If you still have this problem, would you please provide us the below detailed information, which may help us to reproduce your issue and offer the solution to you quickly.

1. Dll file list (name + version), for example:
Spire.Doc.dll v4.9.32.3040
Spire.License.dll v4.9.32.3040
Spire.Pdf.dll v2.8.86.3040

2. Operation System, for example:
Windows 7 Enterprise Edition SP1 x64
Regional and Language Options

3. Project can reproduce the issue
All code about this problem, a simple project which can reproduce this problem will be better.

4. Test Document or Test data
Please provide your test document to us if convenient, it may help us reproduce your issue quickly. We promise to keep your document confidential and we will not use it for any other purpose. Besides, you could also remove the security data of your document and then send it to us.

Thanks and Regards,
Harry
Technical Support / Developer,
e-iceblue Support Team
User avatar

harry.support
 
Posts: 180
Joined: Mon Nov 08, 2010 3:11 pm

Fri Feb 07, 2014 8:12 am

Hello there,

Has your issue been resolved? Could you please give us some feedback if convenient?
Thank you in advance.
If you have any questions, please tell us.

Regards,
Benjamin
E-iceblue support team
User avatar

Benjamin Du
 
Posts: 82
Joined: Thu Jul 25, 2013 2:38 am

Wed Feb 12, 2014 8:03 am

Hello,

Have your issue been fixed? Could you please give us some feedback if convenient?
Thank you.
If there are any questions, welcome to get it back to us.

Regards,
Benjamin
E-iceblue support team
User avatar

Benjamin Du
 
Posts: 82
Joined: Thu Jul 25, 2013 2:38 am

Thu Apr 06, 2023 1:34 pm

Hello,

When I ran attached html with your test.jar as 'java -jar test.jar' i can get pdf file generated.

Where as when i try to generate in local with
Code: Select all
public static void main(String args[]) {
      try {
         com.spire.license.LicenseProvider.setLicenseKey(LICENSE_KEY);
         String htmlString = HtmlToString(HTML_PATH);
         String outputFile = TEMP_PATH + "genrated.pdf";
         String pluginPath = PLUGIN_PATH;
         // Set the plugin path
         HtmlConverter.setPluginPath(pluginPath);
         System.out.println("outputFile " + outputFile);
         HtmlConverter.convert(htmlString, outputFile, true, 100000, new Size(700, 900), new PdfMargins(0));
         System.out.println("outputResource.getFile().length() " + new File(outputFile).length());
      } catch (Exception e) {
         e.printStackTrace();
      }

   }

   // Convert a HTML file to string
   public static String HtmlToString(String filePath) throws IOException {
        String path = filePath;
        File file = new File(path);
        FileReader fileReader = new FileReader(file);
        BufferedReader bufferedReader = new BufferedReader(fileReader);
        StringBuilder stringBuilder = new StringBuilder();
        String temp = "";
        while ((temp = bufferedReader.readLine()) != null) {
            stringBuilder.append(temp + "");
        }
        bufferedReader.close();
        String str = stringBuilder.toString();
        return str;
    }

it gives me below error
Code: Select all
class com.spire.pdf.packages.sprLyB: Illegal characters in path.
com.spire.pdf.packages.sprBdc.spr  (Path.java:293)
com.spire.pdf.packages.sprOla.spr  (Unknown Source)
com.spire.pdf.packages.sprFJa.spr  (Unknown Source)
com.spire.pdf.htmlconverter.qt.HtmlConverter.convert(Unknown Source)
com.spire.pdf.htmlconverter.qt.HtmlConverter.convert(Unknown Source)
com.liferay.rbi.rbiHtmlToPdfSpire.portlet.SpireMain.main(SpireMain.java:47)
   at com.spire.pdf.packages.sprBdc.spr  (Path.java:293)
   at com.spire.pdf.packages.sprOla.spr  (Unknown Source)
   at com.spire.pdf.packages.sprFJa.spr  (Unknown Source)
   at com.spire.pdf.htmlconverter.qt.HtmlConverter.convert(Unknown Source)
   at com.spire.pdf.htmlconverter.qt.HtmlConverter.convert(Unknown Source)
   at com.liferay.rbi.rbiHtmlToPdfSpire.portlet.SpireMain.main(SpireMain.java:47)


In local I'm using below jdk
Code: Select all
openjdk version "1.8.0_362"
OpenJDK Runtime Environment (Zulu 8.68.0.20-SA-win64) (build 1.8.0_362-b08)
OpenJDK 64-Bit Server VM (Zulu 8.68.0.20-SA-win64) (build 25.362-b08, mixed mode)

Dasgupta
 
Posts: 52
Joined: Fri Mar 11, 2022 9:14 am

Fri Apr 07, 2023 10:34 am

Hi,

Thanks for your message.
Your error could be avoided by adding "LoadHtmlType.Source_Code". But It also can not generate the PDF file. I have logged this issue into our tracking system with the ticket SPIREPDF-5913, our Dev team will do further investigation and fixing. Once there is any update, we will keep you informed. Sorry for the inconvenience caused.We suggest that you use my previous code to do the conversion.If there is any other issues, just feel free to contact.

Best Regards,
Herman
E-iceblue support team
User avatar

Herman.Yan
 
Posts: 115
Joined: Wed Mar 08, 2023 2:00 am

Return to Spire.Doc