Print Emoji on PDF in Android - java

I have requirement to export pdf from local database, And I have done this for image and text it work perfect, but I want to print emoji on a PDF and I don't know how. If anyone has an idea, please reply. For PDF export I am using iTextPDF and for Emoji Emojicon.

Maybe you can use https://github.com/pepibumur/emojize for add emojis to your project. There are methods for parsing or sth:
public static String emojiText(String text){}
public static String demojizedText(String text){}
There are emoji graphics and apis https://github.com/arvida/emoji-cheat-sheet.com

Related

Ocr could not convert some characters properly in java

I am trying to get text from element which are inside canvas, I am trying to capture canvas portion as image and then extracting text from image using OCR library. But I am facing issue as some of characters are not getting converted in exact text.
I am using Selenium webdriver, Java and Maven.
Code to extract text from image:
Ocr.setUp();
Ocr ocr = new Ocr(); // create a new OCR engine
ocr.startEngine("eng", Ocr.SPEED_FASTEST); // English
textFromImage = ocr.recognize(new File[]{new File("E:\\Device.png")},
Ocr.RECOGNIZE_TYPE_TEXT, Ocr.OUTPUT_FORMAT_PLAINTEXT);
System.out.println(textFromImage);
ocr.stopEngine();
Currently I am trying to get text which is in google search text box from below image :
I am expecting output as get text : What is swift in iOS
But OCR returns text : Whatls swlflln IOS as per following screenshot:
Some how OCR could not covert some characters same as what in image. Is there any other solution for this?

how can I write java code with syntax highlighting using pdfbox

I am trying to create a java project that simply prints a project source code, be it java, php, c++ and others.
I can create the PDF just fine with iText, but now I need some kind of highlighting the java code I read the same way a code editor like sublime highlights. I discovered pdfbox: a library for creating/manipulating PDF files, but I can't find how to highlight code text(like sublime does) by using this library. Any help?
Copying from another SO question : highlight text using pdfbox when it's location in the pdf is known
PDDocument doc = PDDocument.load(/*path to the file*/);
PDPage page = (PDPage)doc.getDocumentCatalog.getAllPages.get(i);
List annots = page.getAnnotations;
PDAnnotationTextMarkup markup = new PDAnnotationTextMarkup(PDAnnotationTextMarkup.Su....);
markup.setRectangle(/*your PDRectangle*/);
markup.setQuads(/*float array of size eight with all the vertices of the PDRectangle in anticlockwise order*/);
annots.add(markup);
doc.save(/*path to the output file*/);

Parsing multiple images from a web page and display to an android device

I am trying to parse the images that are display in this link http://lawncare.ncsu.edu/RSSFeed.aspx and display it in an android device. Right now, I am only able to parse the text associated with the images. Can anyone suggest any ideas on how to go about parsing these images? Preferably not using JSoup because I am already half way down the code.
Try looking at this question over here at : How to parse XML using the SAX parser
specifically the answer given by damiean and his solution.
This is a part of my code where i am parsing the rss feed :
Bundle b = new Bundle();
b.putString("title", feed.getItem(position).getTitle());
b.putString("description", feed.getItem(position).getDescription());
b.putString("content", feed.getItem(position).getContent());
b.putString("link", feed.getItem(position).getLink());
b.putString("pubdate", feed.getItem(position).getPubDate().toString());
What i have done is that the "field" contains both the description(text) and the image . I passed the whole "content" field contents into a WebView and it displays the image as well as the text correctly.

Adding images to rtf file in java with iText

I am using itext 2.1.7 to create a rtf file dynamically in a spring MVC controller.
The class I am using is RTFWriter2. This works well. But I am not able to add an image to it.
The image is a byte array which I get from a JPA domain object. I also tried to read a sample image from a file. But this does not work either. The image class is from the itext package and its constructor allows an byte array.
This is the code I use:
Image img = Image.getInstance(user.getStammdaten().getProfileImage());
document.add(img);
document.newPage();
Any clues?
Maybe this scripst will help you.
https://joseluisbz.wordpress.com/2011/06/22/script-de-clases-rtf-para-jsp-y-php/
Now,
Here there is an example of use:
https://joseluisbz.wordpress.com/2011/07/16/subiendo-imagenes-png-y-jpg-y-archivos-a-mysql-con-php-y-jsp-y-mostrarlos-en-rtf-usando-clases/

How to convert UTF-8 string to RTF string in java?

Currently my project need export report to MS Word , and i choose using RTFTemplate engine to do it. But my problem is I need convert all character to RTF string first . Everyone have experiment with this problem can suggest me ?
Yes.
You can use RtfDocument from iText:
new RtfDocument().filterSpecialChar(baos, sentence, true, true);
I've described it with details in my blog:
http://lechlukasz.wordpress.com/2010/02/03/rtftemplate-and-character-encoding/
POI
is an apache project that help works with MS Office format.

Categories