使用PDFWriter生成许多项时出错

时间:2014-11-07 06:54:35

标签: android pdf

我一直在开发可以从扫描条形码项目流程生成PDF的应用程序,但是如果我想生成10-13项,程序可以工作,但是如果我生成超过20项,那么我会被我的程序崩溃

这里是logcat错误:

11-07 13:40:06.463: E/AndroidRuntime(9538): FATAL EXCEPTION: AsyncTask #2
11-07 13:40:06.463: E/AndroidRuntime(9538): Process: com.example.testpdf, PID: 9538
11-07 13:40:06.463: E/AndroidRuntime(9538): java.lang.RuntimeException: An error occured while executing doInBackground()
11-07 13:40:06.463: E/AndroidRuntime(9538):     at android.os.AsyncTask$3.done(AsyncTask.java:300)
11-07 13:40:06.463: E/AndroidRuntime(9538):     at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
11-07 13:40:06.463: E/AndroidRuntime(9538):     at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
11-07 13:40:06.463: E/AndroidRuntime(9538):     at java.util.concurrent.FutureTask.run(FutureTask.java:242)
11-07 13:40:06.463: E/AndroidRuntime(9538):     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
11-07 13:40:06.463: E/AndroidRuntime(9538):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
11-07 13:40:06.463: E/AndroidRuntime(9538):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
11-07 13:40:06.463: E/AndroidRuntime(9538):     at java.lang.Thread.run(Thread.java:841)
11-07 13:40:06.463: E/AndroidRuntime(9538): Caused by: java.lang.OutOfMemoryError
11-07 13:40:06.463: E/AndroidRuntime(9538):     at java.lang.String.<init>(String.java:422)
11-07 13:40:06.463: E/AndroidRuntime(9538):     at java.lang.AbstractStringBuilder.toString(AbstractStringBuilder.java:642)
11-07 13:40:06.463: E/AndroidRuntime(9538):     at java.lang.StringBuilder.toString(StringBuilder.java:663)
11-07 13:40:06.463: E/AndroidRuntime(9538):     at com.example.pdfwriter.PDFDocument.toPDFString(PDFDocument.java:69)
11-07 13:40:06.463: E/AndroidRuntime(9538):     at com.example.pdfwriter.PDFWriter.asString(PDFWriter.java:113)
11-07 13:40:06.463: E/AndroidRuntime(9538):     at com.example.testpdf.ViewOfferOrder$Ganeratetask.generateHelloWorldPDF(ViewOfferOrder.java:1048)
11-07 13:40:06.463: E/AndroidRuntime(9538):     at com.example.testpdf.ViewOfferOrder$Ganeratetask.doInBackground(ViewOfferOrder.java:652)
11-07 13:40:06.463: E/AndroidRuntime(9538):     at com.example.testpdf.ViewOfferOrder$Ganeratetask.doInBackground(ViewOfferOrder.java:1)
11-07 13:40:06.463: E/AndroidRuntime(9538):     at android.os.AsyncTask$2.call(AsyncTask.java:288)
11-07 13:40:06.463: E/AndroidRuntime(9538):     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
11-07 13:40:06.463: E/AndroidRuntime(9538):     ... 4 more

然后错误引用(pdfwritter类):

public String asString() {
        mPages.render();
        return mDocument.toPDFString();
    }

有人可以帮我解决这个问题吗?

0 个答案:

没有答案