Java - read font characters from ttf file - java

For android app I'm working right now i have to test that font file supplies all needed characters. Hoverwer I can have a lot ttf files, so i wanted to check every.
But heres my problem: How to read font chars in UTF-8 and iterate through them?
Any help would be appreciated.

You should try using the sfntly library
This has been used in Android Font Creator project
I was able to print glyph ids and names using the test program on a desktop app. Should work on Android as well.

Ok, the way it worked for me was that a friend of mine prepared svg file with font and we could generate data with javascript from that file.

Related

Aspose Android via java

I am using aspose java jar for web application and aspose Android via java for mobile application. By default aspose increase font size when i create pdf from mobile . Can someone tell me what exactly aspose doing for mobile?
Thanks for your inquiry. I suspect that the difference in font size is actually the difference in fonts. Android has a limited set of fonts and when Aspose.Words cannot find some fonts upon rendering document to PDF it tries to substitute them. You can configure font substitution rules using FontSubstitutionSetings class.
If you need the exact rendering, then the same set of fonts must be used on different platforms. You can put the required fonts into a folder and use it as font source in FontSettings.

Generate PDF or Similar to it

I'm creating a JAVA application
and I want to create and display and print a PDF file.
Like this example:
http://img11.hostingpics.net/pics/331702Sanstitre.jpg
So can you give the right way to do it ?
I mean is this a pdf file displayed into a JPanel or something else ?
and thnx alot.
For working with PDF files I would recommend using a library such as Apache PDFBox which has the ability to write, read, and print PDF files using org.apache.pdfbox.PrintPDF
The API can be found Here
As for displaying it in the JFrame, you can simply read the text and print it out in a Swing Text Area
For generation of pdf files you can use Jasper Reports library. It is popular API for creation pdf files from template in which specific data is inserted. Template files have ".jrxml" extension and can be created and edited by Jaspersoft Studio. These files look like forms with variable fields, this is very useful for generating different kinds of reports.
The API for Jasper Reports Library can be found here.

The printed PDF file is different form the original PDF file

I use the PDFBox 1.8.3 jar to print a PDF file in printer(HW). I printed the PDF file in both ways normal and program. When I print the PDF using normal way, I got the original pdf file as a printed document. But when I use my code I'm unable to get the original pdf file as the printed output. I can see a couple of changes in the printed file; for example alignments, font and ink are different from the original document.
ReadPDF readPDF = new ReadPDF();
PDDocument document = readPDF.loadPdf(path);
document.addPage(new PDPage());
printerJob.setPageable(document);
printRequestAttributeSet.add(new PageRanges(1,3));
printerJob.print(printRequestAttributeSet);
Also I try to uppgrade the PDFBox jar 1.8.3 to upcoming jar 2.0.0. I faced a few difficulties (for example: in PDFBox 2.0.0 I'm unable to use the printerJob.setPageable(document);). Could you please help me to solve this issue.
This is sometimes related with printer also. Please try out in a different printer, just to check.
You can have a look at the answer of below question on StackOverflow and can make use of extracts from the explaination.
How to determine artificial bold style ,artificial italic style and artificial outline style of a text using PDFBOX
Also, verify if the fonts which are supplied to the original PDF are also present in the container in which the application is running.
Shishir

Pdf Text Coordinate / Font

I have a project, i have to get title,author informations from inside of the PDF file(not from metaData). So i try to read text from PDF by given coordinates and try to get fonts of texts.
Is there any way to do that, can anyone give advise ? Or is there another solutions to do my project?
Thanks for every help and thought you're sharing with me.
There are multiple PDF libraries for Java which allow you to extract text, my favourite being iText, as examples for text parsing have a look at ExtractPageContentArea and other examples from chapter 15 of iText in Action, 2nd edition.
Currently there is no example making use of the font information, but the information is available to the RenderListeners.

Displaying embedded fonts with PDFBox and Swing

I am using PDFBox to display PDF files inside a JInternalFrame. When opening PDF I get lots of warnings like this:
Changing font on <m> from <Tahoma Negrita> to the default font
I am aware that the fonts being reported are not part of the standard set of 14 fonts. So I decided to check if those fonts are embedded on the PDF file (thinking that there shouldn't be a problem loading embedded fonts, right?).
So I open the file on different readers and check properties/fonts. I am in doubt whether this section reports fonts required by the document or fonts actually embedded in the document.
The information that I get is as follows:
BAAAA+Tahoma-Bold (embedded Subset), type:TrueType, Encoding:
CAAAA+Tahoma (Embedded Subset), type:TrueType, Encoding:
Confused about this, I researched on how to embed fonts from OpenOffice and found that the PDF/A-1a option should be checked. So I made another PDF using this option (in case this was not used when making the original PDF file), yet I got the same results.
I would like your guidance understanding how this works. I would like to be able to open PDF files just as PDF readers do. I also read about the PDFBox_External_Fonts.properties but I am guessing this file shouldn't be modified since I am dealing with embedded fonts.
Thanks.
pdfbox is not able to parse embedded subsets of TrueType fonts.
As far as I understand it, embedded TrueType subsets are missing some metadata for the font file that pdfbox needs.
The bug is known but not easy to solve. Right now I can only advise to use embedded Type 1 Fonts if possible, pdfbox can deal with them.
You can also try to set the path to your complete font files in your pdfbox.jar under org/apache/pdfbox/resources/PDFBox_External_Fonts.properties, so if pdfbox cannot parse the subset, at least it can find a full path to the original font file. Maybe that works, but I have not tested this.
Good Luck!

Categories

Resources