I'm using version 2.1.7 of iText and I want to generate a PDF version of an HTML.
My HTML file contains font awesome icons:
<i class="fa fa-check" style="color:green" aria-hidden="true"></i>
When I now generate a PDF file from this HTML, nothing is displayed...
I think I'll need to register the font awesome with the font provider, but until now, I didn't found out how :(
This is my code to generate the pdf:
// pdf conversion
ConverterProperties props = new ConverterProperties();
FontProvider dfp = new DefaultFontProvider(true, true, false);
/* Temporary fix for display issue with blocks (in current html2pdf version (2.0.1) */
props.setTagWorkerFactory(new LabelBlockTagWorkerFactory());
props.setCssApplierFactory(new LabelBlockCssApplierFactory());
props.setFontProvider(dfp);
HtmlConverter.convertToDocument(html, pdfDoc, props);
footerHandler.writeTotal(pdfDoc);
pdfDoc.close();
Anyone has an idea?
Font awesome icons are injected by javascript and css into the pseudo before area. The only way you can process that if you are doing pure html is to use the font awesome cheat sheet, get the character code, use a span with that font family. You would need to download a TTF fontawesome font and register it in iText.
Although this is not iText and uses other PDF formatting, you can look here to see pseudo elements:
http://www.cloudformatter.com/CSS2Pdf.Demos.PseudoElem
Here for Fontawesome and Gylphicons:
http://www.cloudformatter.com/CSS2Pdf.Demos.GlyphIcons
And you can download the Javascript to see what happens however the whole part that does what I state above has been removed because you can get the pseudo elements from the DOM of the browser now. Before, the code would do as i said and just inject a <span> in the content with the right font-family.
You would need to abandon the use of fontawesome and just use the actual characters in the HTML as nothing processing the HTML+CSS is also going to process the Javascript that injects the icon, no more than it would replace <div id="mychart"/> with the actual chart, unless you use a solution that will execute the Javascript before you print.
Related
The MinervaNeue skin on my MediaWiki installation is not loading the text formatting of the wiki. The attached image is an example:
The Vector skin doesn't give me any issues (but it isn't mobile-friendly, either). Does anyone have a solution for this?
Edit: Here is the part of LocalSettings.php where I load and apply the skin:
wfLoadSkin( 'MinervaNeue' );
wfLoadExtension( 'MobileFrontend' );
$wgMFAutodetectMobileView = true;
$wgMFDefaultSkinClass= "SkinMinerva";
ResourceLoader CSS modules have a target property; the target must include mobile to be loaded on mobile devices. E.g. this is how Vector does it.
Presumably whatever source your text formatting styling comes from omits to do that.
I use the asciidoctor-maven-plugin(1.5.3) to convert asciidoc files to pdf and html files.
Problem:
The pdf file that is created is rendered including the admonition icons - So, all is well here.
The html file on the other hand does not seem to be created in the right way - the admonition icons are missing. There is no text/caption instead just a strange placeholder.
I tried using the :icons: font backend attribute, where font is the only option I found in the asciidoc documentation.
(By the way this is the same as adding <icons>font</icons> like shown below in the pom.xml.)
The font option should show icons from http://fortawesome.github.io/Font-Awesome/icons/ but it does not.
Question:
Do I have to import those icons form anywhere or dowload them and specifically include them using the :iconsdir: path/to/icons backend attribute?
The important part of the pom.xml looks like this.
<configuration>
<backend>html5</backend>
<sourceHighlighter>coderay</sourceHighlighter>
<attributes>
<imagesdir>./images</imagesdir>
<toc>left</toc>
<icons>font</icons>
<sectanchors>true</sectanchors>
<idprefix/>
<idseparator>-</idseparator>
</attributes>
</configuration>
Ok, this is embarrassing, at least one half of the story.
The embarrassing part
The actual mistake I made was using the noscript firefox plugin, which disallowed the use of fontawesome....
In fact, I had to explicitly allow cloudfare.com in noscript to make it work.
So, my pom.xml stays with the attribute <icons>font</icons>.
The good part
I found out how to use custom icons:
declare <iconsdir>./images/icons</iconsdir> (This is also the default, relative to the source directory.)
copy some icons in it. I got them from here. (Pay attention to the names: note.png for NOTE: This is a note.)
change <icons>font</icons> to <icons>image</icons>
I am using Jasper Report 5.6.0 + JSF 2.2 + Primefaces 5.2
My problem is in detail band (content) of the jrxml I am passing RTF from pe:ckEditor here. This editor have many rich components e.g. tables, radio, fonts etc.
In generated document many styles escaped automatically. like table or font. While that text-field markup is html.
More: font will be changed if i generate html instead of pdf. and my rough guess is if any font that is not in JasperReport -> iText library it will escaped automatically
To render RTF text you use markup="rtf" on the textElement, however you will not be able to render tables, text alignment, box's ecc.
This feature is only for producing styled text., how the text looks (bold, size, color ecc.)
What are your options?
Convert to html and use the HTML Renderer Component, note neither this is perfect since it will renderer and image of your html (problem with overflow and size).
Create your own RTF component, I have not seen an RTF Renderer Component and I don't think there are any open tracker for this feature request in the JasperSoft Community
Parse the RTF in java and use dynamic jasper to generate your report (or subreport relative to the RTF)
When generating pdf, if font extension is not provided , iText will use (quoting #Bruno Lowagie) "its best effort" to render your font, this often is not enough. Consider adding font-extension to your project
Check list for rendering font in pdf using jasper report
How to add font extensions using iReport or JasperSoft Studio
Note: If you are using the HTML Renderer Component this will not be needed since it is rendering an image.
I have a html page having some static text as well as some controls like dropdownlist and textbox etc along with a button e.g., "Download as pdf".I need to generate a pdf file using angularjs taking the selected value of dropdownlist and value of textbox etc alongwith static content.
The page also uses some external fonts in addition to custom CSS. I need all these in my pdf.
Is it possible in jsPDF?
I tried using fromHTML():- but it only prints the text of text nodes only.
Then I tried using some built-in functions like setFont(), setFontType() etc. I also tried addFont(), but I couldn't figure out what to be passed in font style.
I even tried adding my font in the standardFonts array of addFonts() function in jsPDF library and install my external font in the system(windows folder/fonts). But it's not working.
As jsPDf has some limited designing features only, it is not meeting my requirements.
Is there any other strong tool which I can use?
I have problem with a web page where it is display some symbols wrongly only in mozilla. The page is click here In this page there are so many -> symbols used. It is displayed as ® in mozilla. So how can i make it to display properly as -> symbol in mozilla. The page has style which are created by micosoft word. I want to retain those as it is.So any css trick can i use it to do?
To get the error i am facing please go to this page and search for software ® click ‘Buy now’.
You use specific Microsoft extensions :
<span style="mso-list:Ignore">§<span style="font:7.0pt "Times New Roman""> </span></span>
And defining fonts in style enclosing them with " is clearly buggy.
I don't know what MSWord tries to do but it's obviously not trying to build a standard HTML document for the World Wide Web. Is that a recent version ?
You'll have to fix the generated HTML.
Another problem is that your rendering relies on the Times New Roman font, which isn't available in non Windows computer.
Using standard HTML and encoding your document in UTF-8, you could replace those spans with simple arrow characters.
But the better solution would be to simply forget the idea to convert a MSOffice document to HTML and to build a proper HTML document instead.