public class WordDocument extends Object implements Printable
Modifier and Type | Class and Description |
---|---|
static class |
WordDocument.KeyInfoWordConvert
This is the Main-Class for the jOfficeConvert.jar that can generate server
key requests, validate a key, and display server information.
|
NO_SUCH_PAGE, PAGE_EXISTS
Constructor and Description |
---|
WordDocument(byte[] docByteArray)
Load a Word file from a byte array.
|
WordDocument(byte[] docByteArray,
WordConvertOptions opts)
Load a Word file from a byte array.
|
WordDocument(InputStream docFileStream)
Load a Word document from an input stream.
|
WordDocument(InputStream docFileStream,
WordConvertOptions opts)
Load a Word document from an input stream.
|
WordDocument(String filePath)
Load a Word document from a file.
|
WordDocument(String filePath,
WordConvertOptions opts)
Load a Word document from a file - with convert options
|
WordDocument(URL docURL)
Load a Word file from a URL.
|
WordDocument(URL docURL,
WordConvertOptions opts)
Load a Word file from a URL.
|
Modifier and Type | Method and Description |
---|---|
WordDocument |
append(byte[] docByteArray)
Convert a Word document from a byte array and append it to this WordDocument object.
|
WordDocument |
append(InputStream inputStream)
Convert a Word document from an InputStream and append it to this WordDocument object.
|
WordDocument |
append(String fileName)
Convert a Word document from a file and append it to this WordDocument object.
|
WordDocument |
append(URL docURL)
Convert a Word document from a URL and append it to this WordDocument object.
|
int |
getPageCount()
Return the number of pages in the converted document.
|
static String |
getVersion()
Returns version string for jOfficeConvert.
|
static void |
loadLicense(InputStream licenseStream)
Method to load a license file from an inputstream.
|
static void |
loadLicense(String licenseFile)
Method to load a license file.
|
int |
print(Graphics graphics,
PageFormat pageFormat,
int pageIndex)
Implementation of the print method to make WordDocument fulfill the Printable interface.
|
void |
print(PrintOptions options)
Prints this Word document.
|
void |
print(String printerName,
PrintOptions options)
Prints this Word document to the specified printer, by name.
|
void |
print(String printerName,
PrintOptions options,
PrintRequestAttributeSet printAttrSet)
Prints this Word document to the specified printer, by name and passes the attribute set to the printer job.
|
void |
printToDefaultPrinter(PrintOptions options)
Prints the Word document to the default printer.
|
void |
saveAsPDF(OutputStream pdfFileStream)
Converts the Word document into a PDF document then
saves the created PDF Document to a file using an Output Stream
|
void |
saveAsPDF(OutputStream pdfFileStream,
PDFSecuritySettings securitySettings)
Converts the Word document into a PDF document, applies
the security settings and then saves the created PDF Document to
a file using an Output Stream
|
void |
saveAsPDF(String pdfFile)
Converts the Word document into a PDF document then
saves the created PDF Document to a file using a String filename
|
void |
saveAsPDF(String pdfFile,
PDFSecuritySettings securitySettings)
Converts the Word document into a PDF document, applies
the security settings and then saves the created PDF Document to
a file using a String filename
|
void |
saveDocumentAsTIFF(OutputStream outStream,
TIFFOptions options)
Save the entire document as a multi-page TIFF image the given OutputStream.
|
void |
saveDocumentAsTIFF(String fileName,
TIFFOptions options)
Save the entire document as a multi-page TIFF image to the given String Filename.
|
void |
savePageAsGIF(int pageIndex,
OutputStream outStream,
int dpi)
Save the rendered image of the page to the given OutputStream in GIF format.
|
void |
savePageAsGIF(int pageIndex,
String fileName,
int dpi)
Save the rendered image of the page to the given String Filename in GIF format.
|
void |
savePageAsJPEG(int pageIndex,
OutputStream outStream,
int resDPI,
float quality)
Save the rendered image of the page to the given OutputStream in JPEG format.
|
void |
savePageAsJPEG(int pageIndex,
String fileName,
int resDPI,
float quality)
Save the rendered image of the page to the given String Filename in JPEG format.
|
void |
savePageAsPNG(int pageIndex,
OutputStream outStream,
int dpi)
Save the rendered image of the page to the given OutputStream in PNG format.
|
void |
savePageAsPNG(int pageIndex,
String fileName,
int dpi)
Save the rendered image of the page to the given String Filename in PNG format.
|
void |
savePageAsTIFF(int pageIndex,
OutputStream outStream,
TIFFOptions options)
Render a page to an image and save it in TIFF format.
|
void |
savePageAsTIFF(int pageIndex,
String fileName,
TIFFOptions options)
Render a page to an image and save it in TIFF format.
|
static boolean |
setKey(String key)
Sets product key.
|
static void |
setUserFontDirectories(List<String> userFontDirs)
Set user font directories.
|
public WordDocument(String filePath, WordConvertOptions opts) throws IOException, OfficeException
filePath
- The path to the fileopts
- Word file conversion optionsIOException
OfficeException
public WordDocument(String filePath) throws IOException, OfficeException
filePath
- The path to the fileIOException
OfficeException
public WordDocument(InputStream docFileStream, WordConvertOptions opts) throws IOException, OfficeException
docFileStream
- Input Stream representing the Word fileopts
- Word file conversion optionsIOException
OfficeException
public WordDocument(InputStream docFileStream) throws IOException, OfficeException
docFileStream
- Input Stream representing the Word fileIOException
OfficeException
public WordDocument(byte[] docByteArray, WordConvertOptions opts) throws IOException, OfficeException
docByteArray
- byteArray representing the Word fileopts
- Word file conversion optionsIOException
OfficeException
public WordDocument(byte[] docByteArray) throws IOException, OfficeException
docByteArray
- byteArray representing the Word fileIOException
OfficeException
public WordDocument(URL docURL, WordConvertOptions opts) throws IOException, OfficeException
docURL
- URL representing the Word fileopts
- Word file conversion optionsIOException
OfficeException
public WordDocument(URL docURL) throws IOException, OfficeException
docURL
- URL representing the Word fileIOException
OfficeException
public static boolean setKey(String key)
key
- Product key.public static void loadLicense(InputStream licenseStream) throws com.qoppa.pdf.LicenseException
licenseStream
- The input stream for the license file contents.com.qoppa.pdf.LicenseException
- If there are any problems with the license filepublic static void loadLicense(String licenseFile) throws com.qoppa.pdf.LicenseException, IOException
licenseFile
- The full path to the license file.com.qoppa.pdf.LicenseException
- If there are any problems with the license fileIOException
public WordDocument append(String fileName) throws OfficeException, IOException
fileName
- file path of a Word fileOfficeException
IOException
public WordDocument append(InputStream inputStream) throws OfficeException, IOException
inputStream
- InputStream representing a Word fileOfficeException
IOException
public WordDocument append(byte[] docByteArray) throws OfficeException, IOException
docByteArray
- byte array representing a Word fileOfficeException
IOException
public WordDocument append(URL docURL) throws OfficeException, IOException
docURL
- URL representing a Word fileOfficeException
IOException
public static String getVersion()
public void saveAsPDF(String pdfFile) throws IOException, PDFException
pdfFile
- String representing the name of the file to save toPDFException
IOException
public void saveAsPDF(OutputStream pdfFileStream) throws IOException, PDFException
pdfFileStream
- Output Stream the PDF document will be written toPDFException
IOException
public void saveAsPDF(String pdfFile, PDFSecuritySettings securitySettings) throws PDFException, IOException
pdfFile
- String representing the name of the file to save tosecuritySettings
- PDFSecuritySettings object containing encryption informationIOException
PDFException
public void saveAsPDF(OutputStream pdfFileStream, PDFSecuritySettings securitySettings) throws PDFException, IOException
pdfFileStream
- Output Stream the PDF document will be written tosecuritySettings
- PDFSecuritySettings object containing encryption informationIOException
PDFException
public int getPageCount()
public void print(PrintOptions options) throws PrinterException, OfficeException
options
- Print job settings. Use this object to define
how to print the document. If null, it will print using default settings.PrinterException
OfficeException
public void print(String printerName, PrintOptions options) throws PrinterException, OfficeException
options
- Print job settings. Use this object to define
how to print the document. If null, it will print using default settings.printerName
- The name of the printer to print to. If this parameter
is set to null, the method will print to the default printer.PrinterException
- This exception is thrown if the printer is not
found or if there is an error while printing.OfficeException
public void print(String printerName, PrintOptions options, PrintRequestAttributeSet printAttrSet) throws PrinterException, OfficeException
options
- Print job settings. Use this object to define
how to print the document. If null, it will print using default settings.printerName
- The name of the printer to print to. If this parameter
is set to null, the method will print to the default printer.printAttrSet
- The attribute set to pass to the printer. This parameter simply gets passed through to the printer job to set options
such as the media tray, chromaticity and others. If null is passed, the print job will use default attributes.PrinterException
- This exception is thrown if the printer is not
found or if there is an error while printing.OfficeException
public void printToDefaultPrinter(PrintOptions options) throws PrinterException, OfficeException
options
- Print job settings. Use this object to define
how to print the document. If null, it will print using default settings.PrinterException
- This exception is thrown if the printer is not
found or if there is an error while printing.OfficeException
public void savePageAsPNG(int pageIndex, OutputStream outStream, int dpi) throws IOException, OfficeException
pageIndex
- The 0 based page index.outStream
- The stream to save the image to.dpi
- Dots per inch at which to render the image. 72 is the native PDF resolution and is equivalent to 100% scale.IOException
OfficeException
public void savePageAsPNG(int pageIndex, String fileName, int dpi) throws IOException, OfficeException
pageIndex
- The 0 based page index.fileName
- The name of the PNG file.dpi
- Dots per inch at which to render the image. 72 is the native PDF resolution and is equivalent to 100% scale.IOException
OfficeException
public void savePageAsGIF(int pageIndex, OutputStream outStream, int dpi) throws IOException, OfficeException
pageIndex
- The 0 based page index.outStream
- The stream to save the image to.dpi
- Dots per inch at which to render the image. 72 is the native PDF resolution and is equivalent to 100% scale.IOException
OfficeException
public void savePageAsGIF(int pageIndex, String fileName, int dpi) throws IOException, OfficeException
pageIndex
- The 0 based page index.fileName
- The name of the GIF file.dpi
- Dots per inch at which to render the image. 72 is the native PDF resolution and is equivalent to 100% scale.IOException
OfficeException
public void savePageAsJPEG(int pageIndex, OutputStream outStream, int resDPI, float quality) throws IOException, OfficeException
pageIndex
- The 0 based page index.outStream
- The stream to save the image to.resDPI
- Dots per inch at which to render the image. 72 is the native PDF resolution and is equivalent to 100% scale.quality
- The quality setting to use for JPEG compression. The range for this value is 0.0 to 1.0.
Lower values mean higher compression and lower quality. As a guideline, 0.25 is low quality, 0.5 is medium
quality and 0.75 is high quality.IOException
OfficeException
public void savePageAsJPEG(int pageIndex, String fileName, int resDPI, float quality) throws IOException, OfficeException
pageIndex
- The 0 based page index.fileName
- The name of the file to save to.resDPI
- Dots per inch at which to render the image. 72 is the native PDF resolution and is equivalent to 100% scale.quality
- The quality setting to use for JPEG compression. The range for this value is 0.0 to 1.0.
Lower values mean higher compression and lower quality. As a guideline, 0.25 is low quality, 0.5 is medium
quality and 0.75 is high quality.IOException
OfficeException
public void savePageAsTIFF(int pageIndex, String fileName, TIFFOptions options) throws IOException, OfficeException
pageIndex
- The 0 based page index.fileName
- The name of the file to save the image to.options
- Options to use when saving the image, such as the TIFF compression type.IOException
OfficeException
public void savePageAsTIFF(int pageIndex, OutputStream outStream, TIFFOptions options) throws IOException, OfficeException
pageIndex
- The 0 based page index.outStream
- The output stream to write the image to.options
- Options to use when saving the image, such as the TIFF compression type.IOException
OfficeException
public void saveDocumentAsTIFF(String fileName, TIFFOptions options) throws IOException, OfficeException
TIFFOptions
object as an argument to describe various
TIFF options when saving the file.fileName
- The name of the file to write the TIFF image to.options
- Options to use when saving the TIFF file.IOException
OfficeException
public void saveDocumentAsTIFF(OutputStream outStream, TIFFOptions options) throws IOException, OfficeException
TIFFOptions
object as an argument to describe various
TIFF options when saving the file.outStream
- The stream to save the image to.options
- Options to use when saving the TIFF file.IOException
OfficeException
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException
print
in interface Printable
graphics
- The printer graphics to draw the page ontopageFormat
- The page format of the target pagepageIndex
- The page to printPrinterException
public static void setUserFontDirectories(List<String> userFontDirs)
userFontDirs
- - List of font directory path strings