How to convert an html webpage to a picture like google preview.
Is there a Java library permitting this?
Is there a command-line argument to call browsers to make them convert a web page into a picture .png for instance?
Using Qt, you can create a simple window with a QWebView (this is webkit under the covers), and then use QWidget::render() method to get QPixmap, and then convert it to QImage.
Qt is C++, but python and java bindings exist also.
http://www.roseindia.net/java/example/java/swing/Print.shtml
Here's a way to do it!
See here. It shows that iText and FlyingSaucer (xhtmlrenderer) have such options.
Related
I want to implement a function that can see PowerPoint on the web at this time.
You can do it simply by converting PowerPoint to an image, but if you convert it to an image, I think there are issues that you can not use video or audio.
So the idea was to convert PowerPoint to HTML and place it where I wanted. However, it does not have much ability to directly implement the pure function of converting PowerPoint to HTML. To solve this problem, I have been looking for open source or various libraries, but I have not found them yet.
The development environment is java8 + Spring Boot.
If you are OK with converting your PPT files to PDF before converting them to HTML, then pdf2htmlEX could be worth looking at. It is the best tool I could find for this kind of work, as it is capable of converting PDFs to HTML very precisely (have a look at the exmples 1,2,3,4). You should be able to find wrapper libraries in the maven repo so that you are able to call it from your Java applications.
If you are OK in using iframe you may use a Microsoft solution https://products.office.com/it-IT/office-online/view-office-documents-online
You may use this code:
<iframe src='https://view.officeapps.live.com/op/embed.aspx?src=[you_ppt_url]' width='100%' height='600px' frameborder='0'>
There's an older node package called PPTX2HTML. It outputs a bunch of garbled code on a canvas element, but it might work. They even have a demo website to try it out. They seemed to have broken the powerpoint up into parseable XML and rendered the elements.
I am trying to recreate a C# program I made in Java. I used the the htmlagilitypack and XPaths to display text from a website in the C# program. Is there a library for Java in which I can use XPaths or is there a better way to do this? Thanks!
Check out jsoup -- a fairly-recent and decent-looking Java HTML parsing library, which seems quite powerful and easy to use, with nice CSS-like selector syntax for accessing content.
I am trying create a java function to convert image files such as "jpg, jpeg, gif, png" into favicon.ico. Does anyone know any library can do that? I want pure java or javascript way. Not the way using imageMagick with jni
Take a look at image4J which will allow you to create ICO images through Java
As simply as...
List<BufferedImage> listOfImages = ...;
ICOEncoder.write(listOfImages , new File("favicon.ico"));
You may also want to check out Reading/Loading an Image as well...
Disclaimer: I not aiming to Answer the question in the most efficient way, but i found an interesting possibility how to solve this problem in an unconventional manner.
with some googling i found this existing site http://mrcoles.com/favicon-creator/ (first result, for the searchterms "javascript create ico").
It has javascript code to create an ICO file, coping this code and adding some canvas html5 magic like found here, you could build the whole thing in Javascript and having lots of fun.
Just a crazy Javascript approach, from the do-it-yourself (copy-past-it-yourself) shelf. :)))
I want to create something like this (code is here):
in pdf format. I'm using google charts and regarding to this forum converting chart to pdf is impossible. I've already tryied iText+XMLWorker, but there is some problem with css and any js supporting at all, I think.
So, the questions are: How can I convert html+css+js to .pdf file? Or, may be, the issue have other variants?
As promised in the comment, I've asked Raf. This was his answer:
One way to use XML Worker for HTML+CSS+JS is to use a browser engine to preprocess the HTML. Examples of such a browser engine are WebKit (Chrome, Safari) and Gecko (Firefox). These can interpret the CSS and JS and give you HTML that is ready to be parsed by XML Worker.
Examples of competing products are:
wkhtmltopdf, a command line tool that uses WebKit as its rendering engine.
Prince XML supports HTML+CSS+JS to PDF using their own engine.
Maybe there are others, but this is what Raf told me. I hope this helps.
Do you know how to convert (save) HTML to an image? Any format is acceptable: jpg, png, ... I tried this code but it does not correctly convert images from HTML (<img> tag).
A solution in Java would be preferred; however, I would appreciation any approach.
Well, here is the outline of a solution, at least:
You need a HTML renderer (Gecko, Webkit et al). Then you need to capture it's "output".
The first approaches that spring to mind are
Create a batch tool yourself, using an open source rendering engine - then render this to an image. This could be done with Qt and QWebKit, maybe even with Qt Jambi (for java). There is an example for c++ here, in the Qt developer blog.
Automating an X11 browser and using capture to capture the contents of the window. Could be a problem with scrolling, IDK.
One solution would be to use WebDriver
Another solution could be provided by this article : Capture screenshots with Selenium
They are both Java solutions.
Your description is a little shy on what your trying to do. Could you please give more details?
If you are just trying to take the html and make an image of it what you might want to try is to create a new image and insert the html as text into the image. Once that is done, you can save the image to the type of your choice. I don't know if this is what you are looking for though.