Set default font in PDF in Java

We at Aspose are glad to announce a new release of Aspose.PDF for Java. Aspose.PDF for Java 18.5 is available on Aspose Artifactory for download. In the latest release our Java API, we have introduced the feature of setting default font in PDF documents. Furthermore, you’ll now be able to get all the fonts from the PDF in Java. Several bug fixes and performance improvements have also been made in this release of the API. A detailed overview of API improvements and changes has been given over the release notes page of Aspose.PDF for Java 18.5.

Set Default Font Name in PDF

Usually, Aspose.PDF for Java API used to replace fonts with the default font in PDF documents when specific fonts were not present or installed in the device where document was being generated. Therefore, we have investigated for feasibility; if a font is used and embedded into the document, the output document should have same font – instead of being replaced by some default font. We have implemented this feature by introducing setDefaultFontName() method in PdfSaveOptions class. An example with complete code snippet is also showcased in API documentation for how to set the default font in a PDF document:

Get all Fonts from PDF File

One of the excited features in Aspose.PDF for Java 18.5 is to get all fonts from PDF document programmatically. With this release of the API, you can get all fonts by using getAllFonts() method. An example with complete Java code snippet is given at following link of the API documentation:

Miscellaneous Fixes

Along with the features, which have been announced above, we have also fixed the following reported bugs in this release of the API:

  • NullPointerException when saving PDF as HTML
  • Aspose.Pdf 18.4 throws exception “Incomplete private key - missing CRT.” when signing document with .pfx file
  • PDF to HTML: Extra space is being rendered with commos
  • Text goes beyond the page after replacing
  • PDF to HTML - Hyperlinks are removed in resultant file

As it is always recommended to use latest release of our API’s because they include latest features/improvements and fixes related to issues reported in earlier released versions. Therefore, please download the latest release of Aspose.PDF for Java 18.5.