I have to read a PDF file and and extract some information from it. Therefor I am using PDFBox. Now I have the problem, that I want to display the results by drawing them on a JPanel. But to do this right, I need the font information of the underlying string.
My problem now is, that I found no good way to convert a PDFont
to a java.awt.Font
. I thought of create some mapping by using the string representation of the PDFont
and extract the relevant information from it, like
Arial -> new Font("Arial", Font.PLAIN, size);
Arial,Bold -> new Font("Arial", Font.BOLD, size);
//and so on
But this does't work, because the string representation differs for every font, for example
Times-Roman -> new Font("Times-Roman", Font.PLAIN, size);
Times-Bold -> new Font("Times-Roman", Font.BOLD, size);
Is there a better way to do the converting?