@Test public void roundTripWriteAndRead() throws TaskException, IOException { List<String> strings = Arrays.asList("ଓଡ଼ିଆଭାଷା", "ગુજરાતી ਪੰਜਾਬੀ தமிழ்", "සිංහල", "န\u103Aမာဘာသာ", "هذا هو كل الحق إلى اليسار", "123 יתימאה ןחבמ", "032 ציר הורמון הגדילה", "This is الحق Mixed יתימאה ןחבמ", "ਹਰਜੋਤ ਸਿੰਘ ភាសាខ្មែរ latin ąćęłńóśźż ทดสอบ വീട मानक हिन्दी ് జ উ ☗⦄✸▃ ", "ציר הורמון הגדילה"); for (String str : strings) { PDDocument doc = new PDDocument(); PDPage page = new PDPage(); new PageTextWriter(doc).write(page, new Point(10, 10), str, getStandardType1Font(StandardType1Font.HELVETICA), 10.0d, Color.BLACK); doc.addPage(page); try (PDDocumentHandler handler = new PDDocumentHandler(doc)) { File tmp = IOUtils.createTemporaryBuffer(); handler.savePDDocument(tmp, NoEncryptionAtRest.INSTANCE); PDDocument doc2 = PDFParser.parse(SeekableSources.seekableSourceFrom(tmp)); String text = new PdfTextExtractorByArea().extractTextFromArea(doc2.getPage(0), new Rectangle(0, 0, 1000, 1000)); assertEquals(noWhitespace(str), noWhitespace(text)); } } }
public static PDType1Font getStandardType1Font(StandardType1Font st1Font) { return STANDARD_TYPE1_FONTS.get(st1Font); }
FontUtils { public static PDType1Font getStandardType1Font(StandardType1Font st1Font) { return STANDARD_TYPE1_FONTS.get(st1Font); } }
FontUtils { public static PDType1Font getStandardType1Font(StandardType1Font st1Font) { return STANDARD_TYPE1_FONTS.get(st1Font); } private  FontUtils(); }
FontUtils { public static PDType1Font getStandardType1Font(StandardType1Font st1Font) { return STANDARD_TYPE1_FONTS.get(st1Font); } private  FontUtils(); static PDType1Font getStandardType1Font(StandardType1Font st1Font); static PDFont fontOrFallback(String text, PDFont font, PDDocument document); static void clearLoadedFontCache(); static void clearLoadedFontCache(PDDocument document); static PDFont loadFont(PDDocument document, FontResource font); static final PDFont findFontFor(PDDocument document, String text); static boolean isOnlyWhitespace(String text); static String removeWhitespace(String text); static boolean canDisplaySpace(PDFont font); static boolean canDisplay(String text, PDFont font); static double calculateBBoxHeight(String text, PDFont font); static boolean isBold(PDFont font); static boolean isItalic(PDFont font); static List<String> wrapLines(String rawLabel, PDFont font, float fontSize, double maxWidth,
            PDDocument document); static double getSimpleStringWidth(String text, PDFont font, double fontSize); static List<TextWithFont> resolveFonts(String label, PDFont font, PDDocument document); static String removeUnsupportedCharacters(String text, PDDocument doc); static String replaceUnsupportedCharacters(String text, PDDocument doc, String replacement); }
FontUtils { public static PDType1Font getStandardType1Font(StandardType1Font st1Font) { return STANDARD_TYPE1_FONTS.get(st1Font); } private  FontUtils(); static PDType1Font getStandardType1Font(StandardType1Font st1Font); static PDFont fontOrFallback(String text, PDFont font, PDDocument document); static void clearLoadedFontCache(); static void clearLoadedFontCache(PDDocument document); static PDFont loadFont(PDDocument document, FontResource font); static final PDFont findFontFor(PDDocument document, String text); static boolean isOnlyWhitespace(String text); static String removeWhitespace(String text); static boolean canDisplaySpace(PDFont font); static boolean canDisplay(String text, PDFont font); static double calculateBBoxHeight(String text, PDFont font); static boolean isBold(PDFont font); static boolean isItalic(PDFont font); static List<String> wrapLines(String rawLabel, PDFont font, float fontSize, double maxWidth,
            PDDocument document); static double getSimpleStringWidth(String text, PDFont font, double fontSize); static List<TextWithFont> resolveFonts(String label, PDFont font, PDDocument document); static String removeUnsupportedCharacters(String text, PDDocument doc); static String replaceUnsupportedCharacters(String text, PDDocument doc, String replacement); static PDFont HELVETICA; static final FontResource[] TYPE0FONTS; }