Carregando arquivo de template por InputStream

parent aad88432
...@@ -47,7 +47,7 @@ import org.w3c.dom.Element; ...@@ -47,7 +47,7 @@ import org.w3c.dom.Element;
public class GeraCaderno { public class GeraCaderno {
public static void processaCaderno(ActionRequest actionRequest,ActionResponse actionResponse,JSONArray listaConteudos,String dataDivulgacao) throws Docx4JException, JAXBException, IOException, ParseException, PortalException{ public void processaCaderno(ActionRequest actionRequest,ActionResponse actionResponse,JSONArray listaConteudos,String dataDivulgacao) throws Docx4JException, JAXBException, IOException, ParseException, PortalException{
...@@ -56,8 +56,9 @@ public class GeraCaderno { ...@@ -56,8 +56,9 @@ public class GeraCaderno {
//String pathTemplate = context.getRealPath(""); //String pathTemplate = context.getRealPath("");
//InputStream templateCaderno = GeraCaderno.class.getClass().getResourceAsStream("/META-INF/resources/template/TemplateCaderno.docx"); //InputStream templateCaderno = GeraCaderno.class.getClass().getResourceAsStream("/META-INF/resources/template/TemplateCaderno.docx");
InputStream templateCaderno = getClass().getResourceAsStream("/META-INF/resources/template/TemplateCaderno.docx");
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
String templateCaderno = PortalUtil.getPortalURL(themeDisplay) + "/o/mprj.doerj.caderno/template/TemplateCaderno.docx"; //String templateCaderno = PortalUtil.getPortalURL(themeDisplay) + "/o/mprj.doerj.caderno/template/TemplateCaderno.docx";
String conteudo=""; String conteudo="";
String orgao=""; String orgao="";
...@@ -67,7 +68,8 @@ public class GeraCaderno { ...@@ -67,7 +68,8 @@ public class GeraCaderno {
MainDocumentPart currentDocumentPart = null; MainDocumentPart currentDocumentPart = null;
//WordprocessingMLPackage templatePackage = WordprocessingMLPackage.load(new File(templateCaderno.toString())); //WordprocessingMLPackage templatePackage = WordprocessingMLPackage.load(new File(templateCaderno.toString()));
WordprocessingMLPackage templatePackage = WordprocessingMLPackage.load(new File(templateCaderno)); //WordprocessingMLPackage templatePackage = WordprocessingMLPackage.load(new File(templateCaderno));
WordprocessingMLPackage templatePackage = WordprocessingMLPackage.load(templateCaderno);
//System.out.println(XmlUtils.marshaltoString(templatePackage.getMainDocumentPart().getJaxbElement(), true, true)); //System.out.println(XmlUtils.marshaltoString(templatePackage.getMainDocumentPart().getJaxbElement(), true, true));
WordprocessingMLPackage acumuladoPackage = WordprocessingMLPackage.createPackage(); WordprocessingMLPackage acumuladoPackage = WordprocessingMLPackage.createPackage();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment