我试图将简单的 XHTML 文件转换为 PDF,并使用 Flying Saucer 和 iText 来实现。它在 Java 中没有问题,但是,当我尝试使用相同的代码制作 Lotus Notes 代理时,我遇到了一个我不确定如何处理的异常。
编码:
import lotus.domino.*;
import java.io.*;
import com.lowagie.text.DocumentException;
import org.xhtmlrenderer.pdf.ITextRenderer;
import org.xhtmlrenderer.util.XRLog;
import java.util.*;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
String received = agentContext.getDocumentContext().
getItemValueString("Query_String");
String[] split;
split = received.split("&");
String url = split[1];
split = url.split("/");
String outputFile = split[split.length-1];
String direc = session.getEnvironmentString("Directory", true);
outputFile = direc + "\\" + outputFile + ".pdf";
OutputStream os = new FileOutputStream(outputFile);
ITextRenderer renderer = new ITextRenderer();
renderer.setDocument(url);
renderer.layout();
renderer.createPDF(os);
os.close();
System.exit(0);
} catch(Exception e) {
e.printStackTrace();
}
}
}
这会产生以下结果:
2011 年 9 月 5 日 13:33:29 HTTP JVM:无法初始化飞碟库的配置。消息是:找不到包 java.util.PropertyResourceBundle 的资源,键 access_properties_not_allowed
2011 年 9 月 5 日 13:33:29 HTTP JVM:java.util.MissingResourceException:找不到包 java.util.PropertyResourceBundle 的资源,键 access_properties_not_allowed
2011 年 9 月 5 日 13:33:29 HTTP JVM:在 java.util.MissingResourceException.(MissingResourceException.java:50)
2011 年 9 月 5 日 13:33:29 HTTP JVM:在 java.util.ResourceBundle.getObject(ResourceBundle.java:400)
2011 年 9 月 5 日 13:33:29 HTTP JVM:在 java.util.ResourceBundle.getString(ResourceBundle.java:421)
09-05-2011 13:33:29 HTTP JVM:在 lotus.notes.JavaString.getString(未知来源)
2011 年 9 月 5 日 13:33:29 HTTP JVM:在 lotus.notes.AgentSecurityManager.checkPropertiesAccess(未知来源)
2011 年 9 月 5 日 13:33:30 HTTP JVM:在 java.lang.System.getProperties(System.java:323)
2011 年 9 月 5 日 13:33:30 HTTP JVM:在 org.xhtmlrenderer.util.Configuration.loadSystemProperties(Configuration.java:419)
2011 年 9 月 5 日 13:33:30 HTTP JVM:在 org.xhtmlrenderer.util.Configuration.(Configuration.java:147)
2011 年 9 月 5 日 13:33:30 HTTP JVM:在 org.xhtmlrenderer.util.Configuration.instance(Configuration.java:742)
2011 年 9 月 5 日 13:33:31 HTTP JVM:在 org.xhtmlrenderer.util.Configuration.valueFor(Configuration.java:463)
2011 年 9 月 5 日 13:33:31 HTTP JVM:在 org.xhtmlrenderer.util.Configuration.isTrue(Configuration.java:709)
2011 年 9 月 5 日 13:33:31 HTTP JVM:在 org.xhtmlrenderer.util.XRLog.init(XRLog.java:250)
2011 年 9 月 5 日 13:33:31 HTTP JVM:在 org.xhtmlrenderer.util.XRLog.log(XRLog.java:203)
2011 年 9 月 5 日 13:33:31 HTTP JVM:在 org.xhtmlrenderer.util.XRLog.render(XRLog.java:194)
2011 年 9 月 5 日 13:33:31 HTTP JVM:在 org.xhtmlrenderer.util.XRLog.render(XRLog.java:190)
2011 年 9 月 5 日 13:33:31 HTTP JVM:在 org.xhtmlrenderer.layout.SharedContext.(SharedContext.java:107)
2011 年 9 月 5 日 13:33:31 HTTP JVM:在 org.xhtmlrenderer.pdf.ITextRenderer.(ITextRenderer.java:111)
2011 年 9 月 5 日 13:33:31 HTTP JVM:在 org.xhtmlrenderer.pdf.ITextRenderer.(ITextRenderer.java:102)
2011 年 9 月 5 日 13:33:31 HTTP JVM:在 JavaAgent.NotesMain(未知来源)
09-05-2011 13:33:31 HTTP JVM:在 lotus.domino.AgentBase.runNotes(未知来源)
09-05-2011 13:33:31 HTTP JVM:在 lotus.domino.NotesThread.run(未知来源)
违规行是
ITextRenderer renderer = new ITextRenderer();
谷歌搜索“access_properties_not_allowed”实际上什么也没有。