![]() ![]() ![]() ![]() The following code snippet illustrates this. You can add text using the standard PDF fonts, by initializing PdfFont class as PdfStandardFont class. The details can be referred from the link below. PDF has fourteen base fonts, also known as standard fonts which has special significance. Chinese, Japanese and Korean (CJK) fonts.Drawing text using different fontsĮssential PDF allows you to add text to the PDF document using the following types of fonts. You can download a complete working sample from GitHub. Save ( "Output.pdf" ) 'Close the document. Black, New PointF ( 0, 0 )) 'Save the document. DrawString ( "Hello World!!!", font, PdfBrushes. Dim font As PdfFont = New PdfStandardFont ( PdfFontFamily. Pages ( 0 ), PdfLoadedPage ) 'Create PDF graphics for the page Dim graphics As PdfGraphics = page. Dim doc As New PdfLoadedDocument ( "input.pdf" ) 'Get first page from document Dim page As PdfLoadedPage = Tr圜ast ( doc. If (wordMLPackage.getMainDocumentPart().'Load a PDF document. Clean up, so any ObfuscatedFontPart temp files can be deleted processEventīyteArrayOutputStream os = new ByteArrayOutputStream() ĭocx4J.toFO(foSettings, os, Docx4J.FLAG_EXPORT_PREFER_XSL) PDF/A-1a, PDF/A-2a and PDF/A-3a require accessibility to be enabledįtAccessibility(true) // suppress "missing language information" messages from FOUserAgent. String fopConfig = Files.readString(new ClassPathResource("fop.xml").getFile().toPath()) įOSettings foSettings = Docx4J.createFOSettings() įtApacheFopConfiguration(fopConfig) įOUserAgent foUserAgent = FORendererApacheFOP.getFOUserAgent(foSettings) įoUserAgent.getRendererOptions().put("pdf-a-mode", "PDF/A-1b") Mapper fontMapper = new IdentityPlusMapper() WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(classPathResource.getFile()) ![]() This is the final conversion code I'm using: // Document loading (required) NimbusRoman-Bold.pfb StandardSymbolsPS.pfbįrom a web search, it seems that the way to proceed is to create a fop.xml configuration file, mapping the font names to the files I extracted. NimbusRoman-BoldItalic.pfb StandardSymbolsPS.afm NimbusRoman-BoldItalic.afm NimbusSans-Regular.pfb NimbusRoman-Bold.afm NimbusSans-Regular.afm NimbusMonoPS-Regular.pfb NimbusSans-Italic.pfb NimbusMonoPS-Regular.afm NimbusSans-Italic.afm NimbusMonoPS-Italic.pfb NimbusSans-Bold.pfb NimbusMonoPS-Italic.afm NimbusSans-BoldItalic.pfb NimbusMonoPS-Bold.pfb NimbusSans-BoldItalic.afm NimbusMonoPS-BoldItalic.pfb NimbusSans-Bold.afm NimbusMonoPS-BoldItalic.afm NimbusRoman-Regular.pfb NimbusMonoPS-Bold.afm NimbusRoman-Regular.afm I think I set up everything correctly, but enabling the A-1b profile causes the following exception: Caused by: java.io.FileNotFoundException: Neither an AFM nor a PFM file was found for NimbusRoman-BoldItalic.pfbĪt .(Type1FontLoader.java:147)Īt .FontLoader.getFont(FontLoader.java:126)Īt .FontLoader.loadFont(FontLoader.java:110)Īt .LazyFont.load(LazyFont.java:119)Ĭaused by: : Failed to read font file NimbusRoman-BoldItalic.pfbĪt .LazyFont.load(LazyFont.java:132)Īt .LazyFont.hasChar(LazyFont.java:179)Īt .Font.hasChar(Font.java:278)Īt .lectFontForCharacter(FontSelector.java:47)Īt .lectFontForCharacterInText(FontSelector.java:85)Īt .(TextLayoutManager.java:162)Īt .AbstractLayoutManager.getChildLM(AbstractLayoutManager.java:118) afm files in the /home/luca/Desktop/ubuntufonts/ path. The PDF/A-1b profile requires embedding of all fonts, including the standard base-14 ones, so I have extracted the Ubuntu Type1 fonts from /usr/share/fonts/type1/urw-base35 and I have 14. The document is nothing fancy, it uses the basic windows fonts Calibri, Courier New, Times New Roman, Symbol, Wingdings. I need to export a docx document to PDF/A-1b on a Ubuntu server, using the Apache FOP backend. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |