Please take that into consideration in the future. By ignoring that great content, you fail to appreciate the hard work that was done. People have done a great effort writing tutorials in answer to questions similar to yours. When you are using iText and you are confronted with an iText-related question, your first reflex should be to visit the official iText web site where you will find the information I summarized above. In the context of that Code of Conduct, I want to inform you that you can contribute to a better atmosphere in the future by using the information that is provided on the official iText web site before asking a question. Stack Overflow has introduced a new Code of Conduct that aims to create a healthier atmosphere on the web site (be kind, contribute, show respect are some of the aspects highlighted in its subtitle). FontBase gives you all the stability, speed, and reliability of a paid font manager, but free and available on all platforms. Now you can create a Font object like this: BaseFont baseFont = BaseFont.createFont(BODONIBLACK, BaseFont.WINANSI, BaseFont.EMBEDDED) Just like with iText 7 you need a font program: public static final String BODONIBLACK = "src/main/resources/fonts/BodoniMTBlack.ttf" In the unlikely event that you don't have any other choice than to use iText 5, then you should read the Using fonts in PDF and iText The font instance can be used as a parameter for the setFont() method: Paragraph bodoni = new Paragraph().setFont(font).add("Bodoni") PdfFont font = PdfFontFactory.createFont(fontProgram, PdfEncodings.WINANSI, true) Using the FontProgram instance, you can create a PdfFont object. Next, you can use this path to create a FontProgram object obtained from the FontProgramFactory: FontProgram fontProgram = FontProgramFactory.createFont(BODONIBLACK) Mpre specifically, if you want to use "Bodoni MT Black", you need the file BodoniMTBlack.ttf somewhere on your computer, for instance: public static final String BODONIBLACK = "src/main/resources/fonts/BodoniMTBlack.ttf" This tutorial explains that you need a font program if you don't want to use one of the standard Type 1 fonts such as times roman. If you follow my advice and upgrade, then you should read the iText 7 tutorial chapter about fonts: Suppose that at some point you need support for SVG in the context of HTML to PDF conversion, you will need to throw away all your iText code and start anew with iText 7. Suppose that at some point you need support for PDF 2.0, then you'll need to throw away your iText 5 code, because support for PDF 2.0 will never be supported in iText 5. ![]() If you are working on a new project, you should abandon iText 5 and upgrade to iText 7 because all new development will be done on iText 7, not on iText 5. FontBase 2.0 Mac and Linux support and much more () over 5 years ago from Dominik Levitsky, Designer & Developer. ![]() ![]() The current version of iText is iText 7.1.2: The code in your question is code that uses iText 5.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |