-1

XHTMLWorker で html テキストを pdf に変換しようとして失敗したので、とても退屈です。

これは私のコードです:

File tempDocPdf;    
com.itextpdf.text.Document docItext;

// crée un pdf vide
docItext = new com.itextpdf.text.Document(PageSize.A4);

// crée le fichier en mémoire
tempDocPdf = new File("c:/temp/",docDTO.getNomDocument() + ".pdf"); 
docDTO.setNomPdf(docDTO.getNomDocument() + ".pdf");
PdfWriter writer = PdfWriter.getInstance(docItext, new FileOutputStream(tempDocPdf));
docItext.addTitle(docDTO.getNomDocument());

// permet de spécifier si les contrôles de navigation sont affichés
writer.setViewerPreferences(PdfWriter.HideWindowUI);                

// ouverture du document pdf (pret à enregistrer des données)
docItext.open();                        

StringReader str = new StringReader("<b>Test XmlWorker</b>");
System.out.println("test 0");

XMLWorkerHelper worker = XMLWorkerHelper.getInstance();
System.out.println("test 10");

worker.parseXHtml(writer, docItext, str); 
System.out.println("test 20");

// crée le pdf  
docItext.close();   
System.out.println("test 30");

//enregistrer dans le document:
buildDocNotes(tempDocPdf);

//suppression du fichier temporaire
tempDocPdf.delete();

私はこの例外があります:

 DETAIL : java.security.AccessControlException: Access denied (java.lang.RuntimePermission getenv.windir)
    at java.security.AccessController.throwACE(AccessController.java:100)
    at java.security.AccessController.checkPermission(AccessController.java:174)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:544)
    at java.lang.System.getenv(System.java:322)
    at com.itextpdf.text.FontFactoryImp.registerDirectories(FontFactoryImp.java:573)
    at com.itextpdf.tool.xml.XMLWorkerFontProvider.<init>(XMLWorkerFontProvider.java:71)
    at com.itextpdf.tool.xml.XMLWorkerFontProvider.<init>(XMLWorkerFontProvider.java:62)
    at com.itextpdf.tool.xml.pipeline.html.HtmlPipelineContext.<init>(HtmlPipelineContext.java:111)
    at com.itextpdf.tool.xml.XMLWorkerHelper.parseXHtml(XMLWorkerHelper.java:166)
    at com.pasquier.DAO.sauvLocal.PdfSauvLocalDAO.creerPdf(PdfSauvLocalDAO.java:219)
    at com.pasquier.DAO.sauvLocal.PdfSauvLocalDAO.detacher(PdfSauvLocalDAO.java:73)
    at com.pasquier.launcher.sauvLocal.SauvLocalProvider.recupInfosPdfSauvLocale(SauvLocalProvider.java:68)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:611)
    at lotus.domino.axis.providers.java.RPCProvider.invokeMethod(Unknown Source)
    at lotus.domino.axis.providers.java.RPCProvider.processMessage(Unknown Source)
    at lotus.domino.axis.providers.java.JavaProvider.invoke(Unknown Source)
    at lotus.domino.axis.strategies.InvocationStrategy.visit(Unknown Source)
    at lotus.domino.axis.SimpleChain.doVisiting(Unknown Source)
    at lotus.domino.axis.SimpleChain.invoke(Unknown Source)
    at lotus.domino.axis.handlers.soap.SOAPService.invoke(Unknown Source)
    at lotus.domino.axis.server.AxisServer.invoke(Unknown Source)
    at lotus.domino.ws.AxisHandler.doPost(Unknown Source)
    at lotus.domino.ws.AxisHandler.invoke(Unknown Source)
    at lotus.domino.WebServiceHelper.runHandler(Unknown Source)
    at lotus.domino.WebServiceHelper.Run(Unknown Source)
    at lotus.domino.WebServiceBase.NotesMain(Unknown Source)
    at lotus.domino.AgentBase.runNotes(Unknown Source)
    at lotus.domino.NotesThread.run(Unknown Source)

私は解決策を始めようとしています:問題は環境変数windirにあるので、この変数にアクセスする許可を与えようとしますか?

4

1 に答える 1