-1

I have a HTML page and I can see this page with my browser without any error. Problem is when I try to convert this HTML to PDF with iText or any other programs, these programs gives hundreds of error. Is there a way to convert HTML file to PDF file without tag checking? I mean I want to get what I see from my web browser as PDF.

EDIT: My html page is a little big so I can't write it here. Here is the first error I am getting with iText

line;

<table style="border-color:blue; " border="0" cellspacing="0px" width="700" cellpadding="0px"> 

error;

Exception in thread "main" java.lang.NumberFormatException: For input string: "0px"
hellzone
  • 5,393
  • 25
  • 82
  • 148
  • 2
    What are some of the errors? Just because a browser is able to render an HTML document doesn't mean the document is correctly structured or doesn't have some other problems. Browsers are *very* forgiving about DOM errors. – David Jan 27 '14 at 13:25
  • @David I edited my answer but when I solve this error a new error comes. – hellzone Jan 27 '14 at 13:39
  • You might want to post your code and the url for a quicker resolution. – StoopidDonut Jan 27 '14 at 13:42
  • @hellzone: Seems like a straightforward error. The engine expects `cellspacing` to be an integer (since it should be an integer), but your markup has `"0px"` which is clearly *not* an integer. The markup is invalid. Again, browsers are very forgiving about this, but other things are not. I recommend using the W3C markup validation service to check your markup: http://validator.w3.org/ – David Jan 27 '14 at 13:45
  • @David with validator.w3.org I am getting several errors but none of them is NumberFormatException for "0px". – hellzone Jan 27 '14 at 13:47
  • 1
    @hellzone: I'm not sure what you expect the W3C validator to be doing, but it's not trying to run your Java code or using iText in any way. It's just validating the HTML markup of your page. Those markup validation errors will need to be corrected, otherwise the behavior of other tools (such as iText) will be undefined. Again, the error you received from iText was because your markup is invalid. First fix the markup, *then* use iText. – David Jan 27 '14 at 13:50

1 Answers1

1

You have this error:

Exception in thread "main" java.lang.NumberFormatException: For input string: "0px"

That error is because the program is seeing the "0px" as string, so you can make a new varible with datatype int For example:`int textSize= 0;

and complete the process normally`

Abdelrahman Wahdan
  • 2,056
  • 4
  • 36
  • 43
  • I am using java. I think it is for .net platform. – hellzone Jan 27 '14 at 13:31
  • 1
    @hellzone: What has .net to do with this? No, Abdelrahman should be right. Per HTML specification the values in `cellpadding` and `cellspacing` **are** already in pixels. You are not *allowed* to specify `px` -- that is a CSS-only notation. – Jongware Jan 27 '14 at 14:25