I have tried to convert HTML to PDF using java iText API and it is working fine as well but the problem is API is not allowing to include the external CSS.
Can any one tell me how to convert html with external css to pdf?
You can inline CSS in your code, using for example Jericho library.
You have on their page the ready code sample:
http://jericho.htmlparser.net/samples/console/src/ConvertStyleSheets.java
Related
I want to convert a portion of my jsp page to pdf. Now I am considering iText for this. Now iText will convert html code to pdf which is fine. But how to fetch my html code with all the stylling applied?
I have my css classes in external css file. I am trying to fetch html code but not getting the css rules applied to elements.
Is there any alternative way?
I know it's possible to convert an HTML file to PDF using Google Drive (HTML2PDF using Google Drive API) but I'd like to know if this HTML has images and CSS files is possible and how to do that.
You need convert HTML to a Docs file and export it as PDF. During the docs conversion most of the non-trivial styles are being trimmed. Basic coloring, sizing and positioning will all you'll get. The exported PDF is the Docs' file's PDF version. Images will be preserved though.
You can make experiments by uploading your html files to Google Drive on drive.google.com with conversion settings on and see the results.
For images you could try this: Embedding Base64 Images
Worked for me when uploading by web. Should work with my solution https://stackoverflow.com/a/21711109/592042
Css can be written right into html file.
Can anyone guide how to generate image from input html code by Java API or Jquery library?
otherwise, how can I make a screenshot of a snippet of HTML code as it is interpreted by the browser?
for example :
if I have this HTML code :
<h1>Logo</h1><img src="http://blog.stackoverflow.com/wp-content/uploads/stackoverflow-logo-300.png">
I will generate an image which includes a screenshot of this code as it's interpreted by the browser
See: rendering html to png (server-side)
And as you want a Java API, Html2Image is the best solution for you.
Which APIs in java help in extracting table metadata from a pdf, and presenting that table in a web page?
The result should be that when the source of page is viewed it will show the html code of that table.
Itext is usefull in this context
http://itextpdf.com/
I assume that, you need a PDF library for Java.
PDFBox is one of the popular libraries created to PDF manipulation and I think it is worth to look at it.
try The Metadata Extract Tool which extracts metadata from specific file types including PDF. Then you can parse the xml output with any Java XML parser. Once you're able to parse it, elements can be easily laid down in your view page.
JPedal library in java is usually used to convert pdf to XML or HTML. However, I needed to know if we could extract data from HTML5 document and save it to XML using JPedal library API?
Is there any other possible alternative to this?
Also , I am trying to parse HTML5 document using Java and store it in XML. are there any good solutions to find just specific tags and render an XML out of them?
Please do let me know . Thank you.
There are a number of Java HTML parsers out there, but I recommend using the HTML5 parser from validator.nu available for download from here: http://about.validator.nu/htmlparser/.
Written to use the HTML5 parser algorithm by one of the main protagonists of HTML5, Henri Sivonen of Mozilla, you won't find a more reliable HTML parser and it creates a true DOM that can be manipulated using standard XML tools and queried for hyperlinks using XPath. There are examples of how to use XSLT transformations with it and how to get an XML serialization of the created DOM.