public final class DocumentToPDFConverter extends Object
Modifier and Type | Method | Description |
---|---|---|
static int |
convert(File document,
String libreOfficeExecutablePath) |
Uses LibreOffice to convert an office document to PDF using the provided LibreOffice executable path.
|
static int |
convert(File document,
String libreOfficeExecutablePath,
boolean allowOverwrite) |
Uses LibreOffice to convert an office document to PDF using the provided LibreOffice executable path.
|
static boolean |
hasConvertibleFileType(File file) |
Returns whether the provided file has a convertible file type
|
public static int convert(File document, String libreOfficeExecutablePath, boolean allowOverwrite) throws IOException, InterruptedException
Creates a file with the same name (with .pdf extension) in the same directory as the source file.
If the output file already exists, it will not be overwritten and an IOException will be thrown.
document
- Office document to convert to PDFlibreOfficeExecutablePath
- Absolute path for the LibreOffice executable to use to convert the documentallowOverwrite
- Boolean flag on whether the output file can be overwrittenIOException
- If the LibreOffice executable was not found, the document does not exist, the document does
not have a valid file extension, or the output file already exists (and allowOverwrite
is set to false)InterruptedException
- If the conversion process gets interruptedpublic static int convert(File document, String libreOfficeExecutablePath) throws IOException, InterruptedException
Creates a file with the same name (with .pdf extension) in the same directory as the source file.
If the output file already exists, it will not be overwritten and an IOException will be thrown.
document
- Office document to convert to PDFlibreOfficeExecutablePath
- Absolute path for the LibreOffice executable to use to convert the documentIOException
- If the LibreOffice executable was not found, the document does not exist, the document does
not have a valid file extension, or the output file already exists (will not overwrite)InterruptedException
- If the conversion process gets interruptedpublic static boolean hasConvertibleFileType(File file)
file
- file to checkCopyright 2021 IDRsolutions ltd. All rights reserved.