如何将不同的字体应用于 iText 中 PDFPCell 中的段落和块

How to apply different font to Paragraph and Chunk in PDFCell in iText

我需要你的帮助来为 PDFCell 中的段落和块应用不同的字体样式。我的代码如下:

BaseFont bf = BaseFont.createFont("c://windows//fonts//arial.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
Font font = new Font(bf, 16);
Font welcomeFont = new Font(Font.TIMES_ROMAN, 20,Font.UNDERLINE | Font.BOLD);
Chunk welcomeText = new Chunk("WelCome ", welcomeFont);
PdfPTable table = new PdfPTable(1);
PdfPCell cell =
  new PdfPCell(new Paragraph("\u0625\u0644\u0649 \u0645\u0646 \u064a\u0647\u0645\u0647 \u0627\u0644\u0623\u0645\u0631"+welcomeText,
                                           font));
table.setRunDirection(PdfWriter.RUN_DIRECTION_RTL);
table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
cell.setBorder(Rectangle.NO_BORDER);
table.addCell(cell);
doc.add(table);

以上代码没有应用不同的字体大小和样式

将块或短语添加到段落中。

Paragraph p = new Paragraph();
p.add(chunk1);
p.add(chunk2);
PdfPCell cell = new PdfPCell(p);

也可以(并且希望)在复合模式下使用 PdfPCell 并在那里直接添加对象。