0

我正在使用 iText 库在我的应用程序中生成新的 pdf。但我的问题是如何在程序中使用未嵌入的字体?我会尝试这段代码,但它对我不起作用。

FONTS = "assets/Zapfino.ttf"
BaseFont bf = BaseFont.createFont(FONTS,"CP1251", BaseFont.EMBEDDED);
font = new Font(bf,18);
Paragraph pr = new Paragraph(p12,font);
document.add(pr);

并给出错误

    05-06 10:08:31.740: W/System.err(1129): com.itextpdf.text.DocumentException: assets/Zapfino.ttf cannot be embedded due to licensing restrictions.
    05-06 10:08:31.740: W/System.err(1129):     at com.itextpdf.text.pdf.TrueTypeFont.<init>(TrueTypeFont.java:371)
    05-06 10:08:31.740: W/System.err(1129):     at com.itextpdf.text.pdf.BaseFont.createFont(BaseFont.java:699)
    05-06 10:08:31.740: W/System.err(1129):     at com.itextpdf.text.pdf.BaseFont.createFont(BaseFont.java:615)
    05-06 10:08:31.740: W/System.err(1129):     at com.itextpdf.text.pdf.BaseFont.createFont(BaseFont.java:450)
    05-06 10:08:31.740: W/System.err(1129):     at com.example.pdfformate.MainActivity.createPdf(MainActivity.java:108)
05-06 10:08:31.740: W/System.err(1129):     at com.example.pdfformate.MainActivity.access$0(MainActivity.java:90)
05-06 10:08:31.750: W/System.err(1129):     at com.example.pdfformate.MainActivity$1.onClick(MainActivity.java:74)
05-06 10:08:31.750: W/System.err(1129):     at android.view.View.performClick(View.java:2485)
05-06 10:08:31.750: W/System.err(1129):     at android.view.View$PerformClick.run(View.java:9080)
05-06 10:08:31.750: W/System.err(1129):     at android.os.Handler.handleCallback(Handler.java:587)
05-06 10:08:31.750: W/System.err(1129):     at android.os.Handler.dispatchMessage(Handler.java:92)
05-06 10:08:31.750: W/System.err(1129):     at android.os.Looper.loop(Looper.java:123)
05-06 10:08:31.750: W/System.err(1129):     at android.app.ActivityThread.main(ActivityThread.java:3683)
05-06 10:08:31.750: W/System.err(1129):     at java.lang.reflect.Method.invokeNative(Native Method)
05-06 10:08:31.750: W/System.err(1129):     at java.lang.reflect.Method.invoke(Method.java:507)
05-06 10:08:31.750: W/System.err(1129):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-06 10:08:31.750: W/System.err(1129):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-06 10:08:31.750: W/System.err(1129):     at dalvik.system.NativeStart.main(Native Method)

有什么帮助吗?

4

0 回答 0