Hi,
I hit the wall so I am asking for a help or point in right direction. I
am trying to create pdf document using java (servlet) from html code
that has a table. I was able to accomplish this but I am not able to
create thin border lines. I search the web and available help but
whatever I do nothing seams to be right. I tried putting css code in
html document and also in java (cssResolver) but with the same result
the border is always to thick.
Here is the code:
Html file:
<HTML>
<HEAD>
<style type="text/css">
table{border:1px solid black;border-collapse: collapse;border-spacing:
0;cellspacing: 0}
table td {border:1px solid #000000; word-wrap: break-word;cellspacing: 0}
</style>
</HEAD>
<BODY>
<table>
<tr style="border-style:none">
<td colspan="3">Broj dijela transformatora:</td>
<td colspan="2">Tip transformatora:</td>
<td colspan="2">Naziv projekta:</td>
<td width="117">Osn. sklop.</td>
</tr>
<tr style="border-style:none">
<td id="textright" colspan="3" >First</td>
<td id="textright" colspan="2" >Second</td>
<td id="textright" colspan="2" >Third</td>
</tr>
</table>
</HTML>
</BODY>
java file:
InputStream is = urlConnection.getInputStream();
InputStreamReader fis = new InputStreamReader(is);
Document document = new Document(PageSize.A4, 20, 10, 10, 10);
PdfWriter pdfWriter = PdfWriter.getInstance (document, new
FileOutputStream(fname));
document.addAuthor("Name");
document.open();
String myCSS = "table{border:0px solid
black;border-collapse: collapse;border-spacing: 0;cellspacing: 0}";
myCSS = myCSS + "table td {border:0px solid #000000;
word-wrap: break-word;cellspacing: 0}";
HtmlPipelineContext htmlContext = new
HtmlPipelineContext(null);
htmlContext.setTagFactory(Tags.getHtmlTagProcessorFactory());
CSSResolver cssResolver =
XMLWorkerHelper.getInstance().getDefaultCssResolver(true);
cssResolver.addCss(myCSS, true);
Pipeline<?> pipeline = new CssResolverPipeline(cssResolver,
new
HtmlPipeline(htmlContext,
new
PdfWriterPipeline(document, pdfWriter)));
XMLWorker worker = new XMLWorker(pipeline, true);
XMLParser aparser = new XMLParser(worker);
aparser.parse(fis);
document.close();
pdfWriter.close();
Best regards!
--
Assoc. prof. dr. sc. Nenad Bojčetić
University of Zagreb
Faculty of Mechanical Engineering and Naval Architecture
Ivana Lučića 5
10000 Zagreb
------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples:
http://itextpdf.com/themes/keywords.php