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.