Xml parsing and itext

大城市里の小女人 提交于 2019-12-08 09:58:46

问题


Just wanted to know if it is possible to change the font,color,font size while parsing html to pdf using xmlWorker.parser Currently I am able to parse whatever I have given as the input.So I wanted to change the font,font size, font color etc if possible. Thank you


回答1:


You can create your own CSS style and add it to your HTML code. The CSS style will be applied according the priority given below where no 4 is the higher priority.

1)Browser default 2)External style sheet 3)Internal style sheet 4)Inline style

Example:

document.open();
String finall=  "<style>h1{color:orange;} </style><body><h1>This is a Demo</h1></body>";
InputStream is = new ByteArrayInputStream(finall.getBytes());
XMLWorkerHelper.getInstance().parseXHtml(pdfWriter,document, is);
document.close();

In the Example Orange color will be set to the header.



来源:https://stackoverflow.com/questions/18953835/xml-parsing-and-itext

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!