All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.swiftboot.fileconvert.impl.WordDocx2PdfConvert Maven / Gradle / Ivy

There is a newer version: 2.4.8
Show newest version
package org.swiftboot.fileconvert.impl;

import fr.opensagres.poi.xwpf.converter.pdf.PdfConverter;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.swiftboot.fileconvert.Convert;
import org.swiftboot.fileconvert.ConvertCallback;
import org.swiftboot.fileconvert.ConvertException;

import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;

/**
 * @author swiftech
 **/
public class WordDocx2PdfConvert implements Convert {
    @Override
    public String[] supportedSourceFileType() {
        return new String[0];
    }

    @Override
    public String targetFileType() {
        return null;
    }

    @Override
    public List convert(InputStream inputStream, ConvertCallback convertCallback) throws ConvertException {
        try {
            XWPFDocument document = new XWPFDocument(inputStream);
            OutputStream outputStream = convertCallback.onPage(0);
            PdfConverter.getInstance().convert(document, outputStream, null);
            return new ArrayList() {
                {
                    add(outputStream);
                }
            };
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy