It's been three days I'm looking for (and test) libs which can perform a generation of an image from textual content. I develop an app on Android with the Augmented Reality Metaio SDK. To apply a texture with text and image embed, I must generate a PNG file. So I need a method :
- Compatible with Android
- On the Android client : not generating the PNG on a server
- With the right way like html/css, svg or Android layout for example : ie not having to make justify text and box positionning from scratch, I'm sure you understand why x)
- Which can perform a generation in external thread (ie without the user have to see the layout)
I tested a lot of solutions, but nothing works.
Using WebView
Some topics about this :
- Generate bitmap from HTML in Android
- How to use onDraw(Canvas) to obtain [...]
- Convert HTML to image (any format) on Android
- Capturing android webview image and saving to png/jpeg
- Which can replace capturePicture function
- Capture picture from WebView
Ultimately, onPageFinished is not enough and we must implement :
webView.setPictureListener(new PictureListener()
{
@Override
public void onNewPicture(WebView view, Picture picture)
{
[...]
It works, but it's deprecated and the WebView must be visible if I want to generate a png, and it does not suit me.
Using Android Layout
Some topics about this :
- How do I convert a RelativeLayout [...]
- Converting a view to Bitmap without displaying it in Android?
- Android Problems Converting ViewGroup with Children into Bitmap
- convert view into bitmap [duplicate]
Once again, I must have a visible View to generate a PNG from it.
Using svg-android
Some topics about this :
It works, but there are only basic functions : include text, image or data-uri image don't work.
Using Batik
SVG Rasterizer and its use.
It works, but not on Android.
Conversion to Dalvik format failed with error 1