坚持使用iText创建pdf文件 [英] Stuck on creating pdf file with iText

查看:174
本文介绍了坚持使用iText创建pdf文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用iText创建pdf文件.

I am trying to create pdf files using iText.

我将itextpdf-5.5.3.jar包含到我的项目中,并按照本教程中的步骤进行操作:

I included itextpdf-5.5.3.jar into my project and following steps in this tutorial:

http://blog.mettletech.co/wp /blog/generate-pdf-file-in-android/

但是当此代码出现以下错误时:

But when this code i getting following errors:

10-30 16:52:57.163: E/dalvikvm(28969): Could not find class 'com.itextpdf.awt.PdfPrinterGraphics2D', referenced from method com.itextpdf.text.pdf.PdfContentByte.createPrinterGraphicsShapes
10-30 16:52:57.213: E/dalvikvm(28969): Could not find class 'java.awt.image.PixelGrabber', referenced from method com.itextpdf.text.Image.getInstance
10-30 16:52:57.223: E/dalvikvm(28969): Could not find class 'java.awt.image.BufferedImage', referenced from method com.itextpdf.text.Image.getInstance

在简单的pdf上我没有出现任何错误,但是在创建包括表等的更复杂的pdf时却出现了thesee错误.

I dont get any errors on simplier pdf but i am getting thesee errors while creating more complex pdfs including tables etc.

您能在这方面给我带头吗?

Can you give me a lead on this?

推荐答案

您遇到的问题不是由iText引起的,而是由创建Android的人做出的特定设计选择引起的.如果您查看有关Android iText的官方页面(更好地称为 iTextG ),则会发现其中一些类在Android上被禁止.这就是为什么使用iTextG jar和 not 普通iText jar的重要性:

The problem you are experiencing isn't caused by iText, but by a specific design choice made by the people who created Android. If you look at the official page about iText for Android (better known as iTextG), you learn that some classes are forbidden on Android. That's why it's important to use the iTextG jar and not the ordinary iText jar:

Google App Engine白名单中未列出的任何类的引用已被删除.

正如您从Android课程中学到的那样, awt 包(以及 nio 包等)中的所有类都不能在Android上使用.因此,您不能使用诸如PdfGraphics2D之类的类,因为该类是抽象java.awt.Graphics2D类的实现,该类不在

As you know from your Android lessons, all classes in the awt packages (and in the nio packages, etc...) can not be used on Android. Hence you can not use classes such as PdfGraphics2D because that class is an implementation of the abstract java.awt.Graphics2D class that is not on Google's white list for Android and GAE.

因此,您可能在引入AWT相关功能方面犯了错误,或者您没有使用iText的Android端口.

So either you are making the mistake of introducing AWT-related functionality, or you are not using the Android port of iText.

这篇关于坚持使用iText创建pdf文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆