Reputation: 5614
We are using itextsharp library in one of our project for creating pdf from html. Everything works fine, but PDF does not create exact replica of html text.
Like for example if html is like :-
<font size="3"><font face="Courier New, Courier, monospace">Plesae <strong>enter
your</strong> text in below editor and click <font size="4">Generate button to view pdf
from html to publish add in india</font></font>
and below code is being used to generate PDF then the font size are not properly taken by itext
StringReader strReader = new StringReader(content);
arrList = HTMLWorker.parseToList(strReader, null);
Paragraph para = new Paragraph();
for (int k = 0; k < arrList.size(); ++k) {
para.add((com.lowagie.text.Element)arrList.get(k));
}
We have made changes in library for mapping font size like if font size 3 is given then take 12 but still exact replica is not being created, may be for Courier 3 we need to map 13, 14 what i really looking forward is, if there is any formula for setting font size accrodingly. The Html being generated from CkEditor.
Upvotes: 0
Views: 3639
Reputation: 22745
You need to use LoadTagStyle to handle it.
EX.
StyleSheet styles = new StyleSheet();
styles.LoadTagStyle(HtmlTags.P, HtmlTags.FONTSIZE, "16");
arrList = HTMLWorker.parseToList(strReader, style);
And add tag
to wrap your whole thing
Upvotes: 1