Search in sources :

Example 1 with SaveOptions

use of com.aspose.words.SaveOptions in project iaf by ibissource.

the class WordConvertor method convert.

@Override
public void convert(MediaType mediaType, Message message, CisConversionResult result, String charset) throws Exception {
    if (!MEDIA_TYPE_LOAD_FORMAT_MAPPING.containsKey(mediaType)) {
        throw new IllegalArgumentException("Unsupported mediaType " + mediaType + " should never happen here!");
    }
    try (InputStream inputStream = message.asInputStream(charset)) {
        Document doc = new Document(inputStream, MEDIA_TYPE_LOAD_FORMAT_MAPPING.get(mediaType));
        new Fontsetter(cisConversionService.getFontsDirectory()).setFontSettings(doc);
        SaveOptions saveOptions = SaveOptions.createSaveOptions(SaveFormat.PDF);
        saveOptions.setMemoryOptimization(true);
        long startTime = new Date().getTime();
        doc.save(result.getPdfResultFile().getAbsolutePath(), saveOptions);
        long endTime = new Date().getTime();
        LOGGER.debug("Conversion(save operation in convert method) takes  :::  " + (endTime - startTime) + " ms");
        result.setNumberOfPages(getNumberOfPages(result.getPdfResultFile()));
    }
}
Also used : InputStream(java.io.InputStream) SaveOptions(com.aspose.words.SaveOptions) Document(com.aspose.words.Document) Date(java.util.Date)

Aggregations

Document (com.aspose.words.Document)1 SaveOptions (com.aspose.words.SaveOptions)1 InputStream (java.io.InputStream)1 Date (java.util.Date)1