Why log out when using documents4j library in spring mvc project

162 Views Asked by At

I using Spring MVC web project and I need the documents4j library when converting the docx file to pdf. Documents4j can convert docx to pdf properly but then my web session is logged out. Does anyone know why?

I'am using Spring mvc web structure and i need documents4j for docx to convert pdf. the code I use to convert:

    File inputWord = new File("Tests.docx");
File outputFile = new File("Test_out.pdf");
try  {
    InputStream docxInputStream = new FileInputStream(inputWord);
    OutputStream outputStream = new FileOutputStream(outputFile);
    IConverter converter = LocalConverter.builder().build();
    converter.convert(docxInputStream).as(DocumentType.DOCX).to(outputStream).as(DocumentType.PDF).execute();
    outputStream.close();
    System.out.println("success");
} catch (Exception e) {
    e.printStackTrace();
}

I am using following dependicies;

<dependency>
    <groupId>com.documents4j</groupId>
    <artifactId>documents4j-local</artifactId>
    <version>1.0.3</version>
</dependency>
<dependency>
    <groupId>com.documents4j</groupId>
    <artifactId>documents4j-api</artifactId>
    <version>1.0.3</version>
</dependency>
<dependency>
    <groupId>com.documents4j</groupId>
    <artifactId>documents4j-transformer-msoffice-word</artifactId>
    <version>1.0.3</version>
</dependency>
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-simple</artifactId>
    <version>1.7.13</version>
</dependency>

My output:

INFO com.documents4j.conversion.msoffice.MicrosoftWordBridge - From-Microsoft-Word-Converter was started successfully
INFO com.documents4j.job.LocalConverter - The documents4j local converter has started successfully
INFO com.documents4j.conversion.msoffice.MicrosoftWordBridge - Requested conversion from C:\a\b3106f03-c187-4059-bbd0-46b7bb4a1404\temp1 (application/vnd.com.documents4j.any-msword) to C:\a\b3106f03-c187-4059-bbd0-46b7bb4a1404\temp2 (application/pdf)
0

There are 0 best solutions below