使用java itext和IBM i RPG ILE时引用#START NON-TRANSLATABLE的异常 [英] Exception referring # START NON-TRANSLATABLE while working with java itext and IBM i RPG ILE

查看:106
本文介绍了使用java itext和IBM i RPG ILE时引用#START NON-TRANSLATABLE的异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用java itext库,并进行非常简单的测试.代码可以通过,但是在关闭文档时,由于java.lang.String.compareToIgnoreCase的空指针异常而失败.

working with java itext library, with a very simple test. Code passes but when closing document, it fails due to null pointer exception with java.lang.String.compareToIgnoreCase.

将itext Java代码嵌入到IBM i RPGIV代码中时会发生.不确定是JNI/RPGIV转换问题(应将utf8转换为EBCDIC本机字符集)还是适当的itext问题.如果有任何itext开发人员可以确认我是否是典型的itext问题,或者听起来不是那样,这会有所帮助,特别是对START NON-TRANSLATABLE的引用.

It happens while embedding itext java code into IBM i RPGIV code. Not sure yet if it is a JNI/RPGIV conversion problem (utf8 should be converted to EBCDIC native charset) or a proper itext issue. It would help if any itext developer could confirm me if it could be a typical itext issue or not sounds like that, specially the reference to START NON-TRANSLATABLE.

线程主"中的异常#START 在NON-TRANSLATABLEjava.lang.NullPointerException java.lang.String.compareToIgnoreCase(String.java:603)
在 java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:94) 在java.io.BufferedOutputStream.flush(BufferedOutputStream.java:152)
在 com.itextpdf.text.pdf.OutputStreamCounter.flush(OutputStreamCounter.java:89) 在com.itextpdf.text.DocWriter.close(DocWriter.java:233)
在com.itextpdf.text.pdf.PdfWriter.close(PdfWriter.java:1341)
在com.itextpdf.text.pdf.PdfDocument.close(PdfDocument.java:901)
在com.itextpdf.text.Document.close(Document.java:415)

Exception in thread "main"# START NON-TRANSLATABLEjava.lang.NullPointerException at java.lang.String.compareToIgnoreCase(String.java:603)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:94) at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:152)
at com.itextpdf.text.pdf.OutputStreamCounter.flush(OutputStreamCounter.java:89) at com.itextpdf.text.DocWriter.close(DocWriter.java:233)
at com.itextpdf.text.pdf.PdfWriter.close(PdfWriter.java:1341)
at com.itextpdf.text.pdf.PdfDocument.close(PdfDocument.java:901)
at com.itextpdf.text.Document.close(Document.java:415)

这是我的Plex Action图代码:

This is my Plex Action diagram code:

文档RPG原型:

Document RPG prototype:

PdfWriter RPG原型: 方法Document.open: 类元素段: 段落构造函数RPG原型 元素接口(段落实现Element): 将段落添加到文档方法: 文件关闭方法:

PdfWriter RPG prototype: Method Document.open: Class Element Paragraph: Paragraph constructor RPG Prototype Element interface (Paragraph implements Element): Add paragraph to document method: Document close method:

这些是我实现的Plex API:

These are my Plex API implemented:

创建文档:

创建PdfWriter:

create PdfWriter:

打开文档:

创建段落:

将段落添加到文档

关闭文档:

最后,我用以下值启动Java: classpath =库的完整列表(itext + Apache POI,所有正在运行) java_home = Java 7的路径

Finally, I start java with these values: classpath = full list of libraries (itext + Apache POI, all running) java_home = path to java 7

推荐答案

在IBM i上使用纯Java对itext进行测试后,最终解决了.它今天有效,并为我提供了找到嵌入式itext问题的指导. PdfWriter类使用不当.我将EBCDIC字符串转换为jstring,然后分配了FileOutputStream对象而不进行转换.从jstring获取FileOutputStream对象将正确的文件对象传递给PdfWriter.现在,该过程如下所示:

Finally solved, after testing itext on IBM i in plain java. It worked today, and give me directions to locate the embedded itext issue. It was the PdfWriter class which was improperly used. I converted a EBCDIC string to jstring, and then assigned a FileOutputStream object without conversion. Getting a FileOutputStream object from jstring passed the right file object to PdfWriter. The procedure looks now as follows:

  /free
     PhraseString = new_String( %trim(&(1:)));
     pdfFilePath = new_FileOutputStream(PhraseString);
     pdfWriter = get_PdfWriter( pdfDocument: pdfFilePath);
  /end-free

这篇关于使用java itext和IBM i RPG ILE时引用#START NON-TRANSLATABLE的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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