Skip to content

How can I convert .doc in .docx #108

@KatRRina

Description

@KatRRina

I use this code:

public DocumentDto parseDocument(byte[] docBytes){
        try {
            ByteArrayInputStream docStream = new ByteArrayInputStream(docBytes);
            ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

            Document doc = new Document(docStream);
            doc.updateWordCount();
            doc.save(outputStream, SaveFormat.DOCX);
            // Получаем массив байт из ByteArrayOutputStream
            byte[] resultBytes = outputStream.toByteArray();
            DocxParser docxParser = new DocxParser();
            DocumentDto result = docxParser.parseDocument(resultBytes);
            result.setFormat(getDocumentType());
            docStream.close();
            outputStream.close();
            return result;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

but after the line Document doc = new Document(docStream);, there are 7 pages left in the 150-page document

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions