yogendra nandanwar

Greenhorn
+ Follow
since Jul 18, 2013
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by yogendra nandanwar



Please find below POC for html to pdf conversion and exception coming from code.



Below html generated from excel 2003. iText API required all the attribute inside tags in quote but in generated html quote is missing in attributes



Test HTML String:



<html xmlns:o="urn:schemas-microsoft-com:office:office"

xmlns:x="urn:schemas-microsoft-com:office:excel"

xmlns="http://www.w3.org/TR/REC-html40">



<head>

<meta http-equiv=Content-Type content="text/html; charset=windows-1252">

<meta name=ProgId content=Excel.Sheet>

<meta name=Generator content="Microsoft Excel 11">

<link rel=File-List href="TEST_files/filelist.xml">

<link rel=Edit-Time-Data href="TEST_files/editdata.mso">

<link rel=OLE-Object-Data href="TEST_files/oledata.mso">

<!--[if gte mso 9]><xml>

<o:DocumentProperties>

<o:Author>osnpo271</o:Author>

<o:LastAuthor>osnpo271</o:LastAuthor>

<o:Created>2013-07-17T04:22:53Z</o:Created>

<o:LastSaved>2013-07-17T05:04:04Z</o:LastSaved>

<o:Company>tata-aig</o:Company>

<o:Version>11.5606</o:Version>

</o:DocumentProperties>

</xml><![endif]-->

<style>

<!--table

{mso-displayed-decimal-separator:"\.";

mso-displayed-thousand-separator:"\,";}

@page

{margin:1.0in .75in 1.0in .75in;

mso-header-margin:.5in;

mso-footer-margin:.5in;}

tr

{mso-height-source:auto;}

col

{mso-width-source:auto;}

br

{mso-data-placement:same-cell;}

.style0

{mso-number-format:General;

text-align:general;

vertical-align:bottom;

white-space:nowrap;

mso-rotate:0;

mso-background-source:auto;

mso-pattern:auto;

color:windowtext;

font-size:10.0pt;

font-weight:400;

font-style:normal;

text-decoration:none;

font-family:Arial;

mso-generic-font-family:auto;

mso-font-charset:0;

border:none;

mso-protection:locked visible;

mso-style-name:Normal;

mso-style-id:0;}

td

{mso-style-parent:style0;

padding-top:1px;

padding-right:1px;

padding-left:1px;

mso-ignore:padding;

color:windowtext;

font-size:10.0pt;

font-weight:400;

font-style:normal;

text-decoration:none;

font-family:Arial;

mso-generic-font-family:auto;

mso-font-charset:0;

mso-number-format:General;

text-align:general;

vertical-align:bottom;

border:none;

mso-background-source:auto;

mso-pattern:auto;

mso-protection:locked visible;

white-space:nowrap;

mso-rotate:0;}

.xl24

{mso-style-parent:style0;

border:.5pt solid windowtext;}

-->

</style>

<!--[if gte mso 9]><xml>

<x:ExcelWorkbook>

<x:ExcelWorksheets>

<x:ExcelWorksheet>

<x:Name>Sheet1</x:Name>

<x:WorksheetOptions>

<x:Print>

<x:ValidPrinterInfo/>

<x:HorizontalResolution>600</x:HorizontalResolution>

<x:VerticalResolution>600</x:VerticalResolution>

</x:Print>

<x:ShowPageBreakZoom/>

<x:Selected/>

<x:Panes>

<x:Pane>

<x:Number>3</x:Number>

<x:ActiveRow>12</x:ActiveRow>

<x:ActiveCol>1</x:ActiveCol>

</x:Pane>

</x:Panes>

<x:ProtectContents>False</x:ProtectContents>

<x:ProtectObjects>False</x:ProtectObjects>

<x:ProtectScenarios>False</x:ProtectScenarios>

</x:WorksheetOptions>

</x:ExcelWorksheet>

<x:ExcelWorksheet>

<x:Name>Sheet2</x:Name>

<x:WorksheetOptions>

<x:ProtectContents>False</x:ProtectContents>

<x:ProtectObjects>False</x:ProtectObjects>

<x:ProtectScenarios>False</x:ProtectScenarios>

</x:WorksheetOptions>

</x:ExcelWorksheet>

<x:ExcelWorksheet>

<x:Name>Sheet3</x:Name>

<x:WorksheetOptions>

<x:ProtectContents>False</x:ProtectContents>

<x:ProtectObjects>False</x:ProtectObjects>

<x:ProtectScenarios>False</x:ProtectScenarios>

</x:WorksheetOptions>

</x:ExcelWorksheet>

</x:ExcelWorksheets>

<x:WindowHeight>8700</x:WindowHeight>

<x:WindowWidth>10395</x:WindowWidth>

<x:WindowTopX>120</x:WindowTopX>

<x:WindowTopY>60</x:WindowTopY>

<x:ProtectStructure>False</x:ProtectStructure>

<x:ProtectWindows>False</x:ProtectWindows>

</x:ExcelWorkbook>

</xml><![endif]-->

</head>



<body link=blue vlink=purple>



<table x:str border=0 cellpadding=0 cellspacing=0 width=192 style='border-collapse:

collapse;table-layout:fixed;width:144pt'>

<col width=64 span=3 style='width:48pt'>

<tr height=17 style='height:12.75pt'>

<td height=17 class=xl24 width=64 style='height:12.75pt;width:48pt'>TEST1</td>

<td class=xl24 width=64 style='border-left:none;width:48pt'>TEST2</td>

<td width=64 style='width:48pt'></td>

</tr>

<tr height=17 style='height:12.75pt'>

<td height=17 class=xl24 style='height:12.75pt;border-top:none'> </td>

<td class=xl24 style='border-top:none;border-left:none'> </td>

<td></td>

</tr>

<tr height=17 style='height:12.75pt'>

<td height=17 class=xl24 style='height:12.75pt;border-top:none'> </td>

<td class=xl24 style='border-top:none;border-left:none'> </td>

<td></td>

</tr>

<tr height=17 style='height:12.75pt'>

<td height=17 class=xl24 style='height:12.75pt;border-top:none'> </td>

<td class=xl24 style='border-top:none;border-left:none'> </td>

<td></td>

</tr>

<tr height=17 style='height:12.75pt'>

<td height=17 colspan=3 style='height:12.75pt;mso-ignore:colspan'></td>

</tr>

<tr height=17 style='height:12.75pt'>

<td height=17 colspan=3 style='height:12.75pt;mso-ignore:colspan'></td>

</tr>

<tr height=17 style='height:12.75pt'>

<td height=17 colspan=3 style='height:12.75pt;mso-ignore:colspan'></td>

</tr>

<tr height=17 style='height:12.75pt'>

<td height=17 colspan=3 style='height:12.75pt;mso-ignore:colspan'></td>

</tr>

<tr height=17 style='height:12.75pt'>

<td height=17 colspan=3 style='height:12.75pt;mso-ignore:colspan'></td>

</tr>

<tr height=17 style='height:12.75pt'>

<td height=17 colspan=3 style='height:12.75pt;mso-ignore:colspan'></td>

</tr>

<tr height=17 style='height:12.75pt'>

<td height=17 colspan=3 style='height:12.75pt;mso-ignore:colspan'></td>

</tr>

<tr height=17 style='height:12.75pt'>

<td height=17 colspan=3 style='height:12.75pt;mso-ignore:colspan'></td>

</tr>

<tr height=17 style='height:12.75pt'>

<td height=17 colspan=3 style='height:12.75pt;mso-ignore:colspan'></td>

</tr>

<tr height=17 style='height:12.75pt'>

<td height=17 colspan=3 style='height:12.75pt;mso-ignore:colspan'></td>

</tr>

<tr height=17 style='height:12.75pt'>

<td height=17 colspan=3 style='height:12.75pt;mso-ignore:colspan'></td>

</tr>

<![if supportMisalignedColumns]>

<tr height=0 style='display:none'>

<td width=64 style='width:48pt'></td>

<td width=64 style='width:48pt'></td>

<td width=64 style='width:48pt'></td>

</tr>

<![endif]>

</table>

</body>

</html>

=============================================================================================

Java Code to conver html to pdf

Using : below Java API

iText-2.0.8.jar

core-renderer-minimal.jar

java version 1.6



strPDF = StrBuf.toString();

OutputStream outStrmPdf = null;

try {

outStrmPdf = new FileOutputStream(outputPdfPath);

ITextRenderer renderer = new ITextRenderer();

renderer.setDocumentFromString(strPDF);

renderer.layout();

renderer.createPDF(outStrmPdf);

outStrmPdf.close();

}

catch (Exception e) {

e.printStackTrace();

}



===========================================================================================

Exception from code

FATAL ERROR: 'org.xml.sax.SAXParseException: Open quote is expected for attribute "http-equiv" associated with an element type "meta".'

:Open quote is expected for attribute "http-equiv" associated with an element type "meta".