# How to convert .docx file to .pdf file using connector?

**URL:** <https://community.ofelia.com/t/how-to-convert-docx-file-to-pdf-file-using-connector/26311>\
**Category:** Q&A\
**Created:** [27 August 2024 04:30 UTC](https://community.ofelia.com/t/how-to-convert-docx-file-to-pdf-file-using-connector/26311 "2024-08-27T04:30:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![archaeus8](https://avatars.discourse-cdn.com/v4/letter/a/ac8455/32.png) [@archaeus8](https://community.ofelia.com/u/archaeus8)\
**Post date:** [27 August 2024 04:30 UTC](https://community.ofelia.com/t/how-to-convert-docx-file-to-pdf-file-using-connector/26311/1 "2024-08-27T04:30:14Z")

</div>

o.b.e.c.i.ConnectorExecutorImpl - Finish execution of connector class org.bonitasoft.engine.core.connector.impl.SConnectorAdapter  
ma  
java.lang.IllegalArgumentException: Property ‘[http://javax.xml.XMLConstants/property/accessExternalSchema](http://javax.xml.XMLConstants/property/accessExternalSchema)’ is not recognized.  
at org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.setAttribute(Unknown Source) ~[xercesImpl-2.9.18920199439905226265.jar:?]  
at org.apache.poi.util.XMLHelper.trySet(XMLHelper.java:284) ~[poi-5.2.09065113461907373529.jar:5.2.0]  
at org.apache.poi.util.XMLHelper.getDocumentBuilderFactory(XMLHelper.java:114) ~[poi-5.2.09065113461907373529.jar:5.2.0]  
at org.apache.poi.util.XMLHelper.(XMLHelper.java:85) ~[poi-5.2.09065113461907373529.jar:5.2.0]  
at org.apache.poi.ooxml.util.DocumentHelper.newDocumentBuilder(DocumentHelper.java:47) ~[poi-ooxml-5.2.04853598215373728735.jar:5.2.0]  
at org.apache.poi.ooxml.util.DocumentHelper.(DocumentHelper.java:36) ~[poi-ooxml-5.2.04853598215373728735.jar:5.2.0]  
at org.apache.poi.openxml4j.opc.internal.ContentTypeManager.parseContentTypesFile(ContentTypeManager.java:393) ~[poi-ooxml-5.2.04853598215373728735.jar:5.2.0]  
at org.apache.poi.openxml4j.opc.internal.ContentTypeManager.(ContentTypeManager.java:102) ~[poi-ooxml-5.2.04853598215373728735.jar:5.2.0]  
at org.apache.poi.openxml4j.opc.internal.ZipContentTypeManager.(ZipContentTypeManager.java:53) ~[poi-ooxml-5.2.04853598215373728735.jar:5.2.0]  
at org.apache.poi.openxml4j.opc.ZipPackage.getPartsImpl(ZipPackage.java:282) ~[poi-ooxml-5.2.04853598215373728735.jar:5.2.0]  
at org.apache.poi.openxml4j.opc.OPCPackage.getParts(OPCPackage.java:743) ~[poi-ooxml-5.2.04853598215373728735.jar:5.2.0]  
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:315) ~[poi-ooxml-5.2.04853598215373728735.jar:5.2.0]  
at org.apache.poi.ooxml.util.PackageHelper.open(PackageHelper.java:59) ~[poi-ooxml-5.2.04853598215373728735.jar:5.2.0]  
at org.apache.poi.ooxml.util.PackageHelper.open(PackageHelper.java:47) ~[poi-ooxml-5.2.04853598215373728735.jar:5.2.0]  
at org.apache.poi.xwpf.usermodel.XWPFDocument.(XWPFDocument.java:156) ~[poi-ooxml-5.2.04853598215373728735.jar:5.2.0]  
at fr.opensagres.xdocreport.converter.docx.poi.itext.XWPF2PDFViaITextConverter.convert(XWPF2PDFViaITextConverter.java:66) ~[fr.opensagres.xdocreport.converter.docx.xwpf-2.0.418264493794101301526.jar:2.0.4]  
at org.bonitasoft.connectors.document.converter.core.AbstractDocumentConverter.convert(AbstractDocumentConverter.java:54) ~[bonita-connector-document-converter-2.3.017087949147520413833.jar:?]  
at org.bonitasoft.connectors.document.converter.DocumentConverterConnector.executeBusinessLogic(DocumentConverterConnector.java:83) ~[bonita-connector-document-converter-2.3.017087949147520413833.jar:?]  
at org.bonitasoft.engine.connector.AbstractConnector.execute(AbstractConnector.java:77) ~[bonita-common-8.0.0.jar:?]  
at org.bonitasoft.engine.core.connector.impl.SConnectorAdapter.execute(SConnectorAdapter.java:74) ~[bonita-server-8.0.0.jar:?]  
at org.bonitasoft.engine.connector.impl.ConnectorExecutorImpl$ExecuteConnectorCallable.call(ConnectorExecutorImpl.java:247) ~[bonita-server-8.0.0.jar:?]  
at org.bonitasoft.engine.connector.impl.ConnectorExecutorImpl$ExecuteConnectorCallable.call(ConnectorExecutorImpl.java:208) ~[bonita-server-8.0.0.jar:?]  
at org.bonitasoft.engine.connector.impl.ConnectorExecutorImpl.lambda$wrapForStats$1(ConnectorExecutorImpl.java:163) ~[bonita-server-8.0.0.jar:?]  
at org.bonitasoft.engine.connector.impl.ConnectorExecutorImpl.lambda$execute$0(ConnectorExecutorImpl.java:150) ~[bonita-server-8.0.0.jar:?]  
at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700) [?:?]  
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]  
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]  
at java.lang.Thread.run(Thread.java:834) [?:?]

---

<div class="post-metadata">

**Author:** ![nicolas.chabanoles](https://dub1.discourse-cdn.com/flex013/user_avatar/community.ofelia.com/nicolas.chabanoles/32/721_2.png) [@nicolas.chabanoles](https://community.ofelia.com/u/nicolas.chabanoles)\
**Post date:** [3 September 2024 08:43 UTC](https://community.ofelia.com/t/how-to-convert-docx-file-to-pdf-file-using-connector/26311/2 "2024-09-03T08:43:42Z")

</div>

Hello, I tried this morning and successfully converted a random .docx file I received recently from a contact.

Can you try the following:

- try to convert another docx file to see if the error persists
- if the error persists, I suggest to reduce the scope of complexity by testing in Java directly from a test class in the connector project: [https://github.com/bonitasoft/bonita-connector-document-converter](https://github.com/bonitasoft/bonita-connector-document-converter)

Here is a code snippet of such a test case you could write:

```auto
@Test
    void should_convert_document() throws Exception {
        //given
        Path fileToConvert = Paths.get("path_to_your_file.docx");
        byte[] fileContent = Files.readAllBytes(fileToConvert);

        // simulate that the document is stored into Bonita
        final DocumentImpl document = new DocumentImpl();
        document.setContentMimeType("UTF-8");
        document.setFileName("a-significant-name.docx");
        document.setContentStorageId("TheStorageID");

        doReturn(document).when(processAPI).getLastDocument(processInstanceId, "documentName");
        doReturn(fileContent).when(processAPI).getDocumentContent("TheStorageID");

        // When
        final HashMap<String, Object> parameters = new HashMap<String, Object>();
        parameters.put(DocumentConverterConnector.SOURCE_DOCUMENT, "documentName");
        parameters.put(DocumentConverterConnector.ENCODING, "UTF-8");

        connector.setInputParameters(parameters);
        connector.validateInputParameters();

        //then
        Map<String, Object> result = connector.execute();

        // Define the file path where you want to write the byte array
        Path path = Paths.get("output-connector-test.pdf");

        // Write the byte array to the file
        Files.write(path, ((DocumentValue)result.get("outputDocumentValue")).getContent());

        assertThat(Files.readAllBytes(path)).isNotEmpty();

    }

```

With that test case, a file is written to your filesystem, which you can open manually to verify that the PDF is generated properly.

I hope this helps,  
Captain Bonita
