0

I am using

HTMLWorker.ParseToList(New StringReader(HTMLCode), New StyleSheet)

On a String HTMLCode that contains :

  <html>
    <body>
    <table width="auto;">  
        <tr style="color:white ; background: #336699; font-style:bold;">
        <th width="257px;" height="40" >Service Name</th>
        <th width="100px;" height="40">Hits </th>
        <th width="100px;" height="40">Revenue</th>
        <th width="100px;" height="40">Service Cost</th>
        </tr>

        <tr>  
        <td width="257px;" height="30" >  GtalkDay </td> 
        <td width="257px;" height="30" > 320 </td> 
        <td width="257px;" height="30" >  67.20 </td> 
        <td width="257px;" height="30" >  (0.21 K) </td>
        </tr>

        <tr style="background: #EBEBE0">  
        <td width="257px;" height="30" >  TwitterDay </td> 
        <td width="257px;" height="30" > 885 </td> 
        <td width="257px;" height="30" >  185.85 </td> 
        <td width="257px;" height="30" >  (0.21 K) </td>
        </tr>

        <tr>  
        <td width="257px;" height="30" >  YahooDay </td> 
        <td width="257px;" height="30" > 626 </td> 
        <td width="257px;" height="30" >  131.46 </td> 
        <td width="257px;" height="30" >  (0.21 K) </td>
        </tr> 

        </table>
    </body>
    </html>

And it is returning the error:

Input string was not in a correct format.

What could be the problem? the HTML code looks perfectly fine.

all Help would be appreciated

PS: I tried to remove Width and Height and Background attributes and the Parsing worked fine

5
  • Have you tried using single quotes in place of double quotes? Commented Jan 6, 2014 at 10:22
  • @NipunAmbastha Yes and it's still returning the same error... what could be the reason? Commented Jan 6, 2014 at 10:30
  • Ok, we can debug it more. i.e. What and where issue is coming? Take new variable and assign its value New StringReader(HTMLCode); check if this is fine. Also what you have in stylesheet? Commented Jan 6, 2014 at 10:33
  • @NipunAmbastha I tried to remove all the width and background color parameters and the saving to pdf worked fine. Does this mean I can only save plain html? Commented Jan 6, 2014 at 10:35
  • Yes, HTMLParser might not accept the tag properties. Probably you will need to search out some other way to create PDF Commented Jan 6, 2014 at 10:39

1 Answer 1

2

This might be due to the not proper format of your HTML.

you should remove spaces before the closing tags of you HTML tags as shown below:

Make change of this,

<td width="257px;" height="30" >  GtalkDay </td>

to

<td width="257px;" height="30">GtalkDay</td>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.