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 optionsIOExceptionOfficeExceptionpublic WordDocument(String filePath) throws IOException, OfficeException
filePath - The path to the fileIOExceptionOfficeExceptionpublic WordDocument(InputStream docFileStream, WordConvertOptions opts) throws IOException, OfficeException
docFileStream - Input Stream representing the Word fileopts - Word file conversion optionsIOExceptionOfficeExceptionpublic WordDocument(InputStream docFileStream) throws IOException, OfficeException
docFileStream - Input Stream representing the Word fileIOExceptionOfficeExceptionpublic WordDocument(byte[] docByteArray,
WordConvertOptions opts)
throws IOException,
OfficeException
docByteArray - byteArray representing the Word fileopts - Word file conversion optionsIOExceptionOfficeExceptionpublic WordDocument(byte[] docByteArray)
throws IOException,
OfficeException
docByteArray - byteArray representing the Word fileIOExceptionOfficeExceptionpublic WordDocument(URL docURL, WordConvertOptions opts) throws IOException, OfficeException
docURL - URL representing the Word fileopts - Word file conversion optionsIOExceptionOfficeExceptionpublic WordDocument(URL docURL) throws IOException, OfficeException
docURL - URL representing the Word fileIOExceptionOfficeExceptionpublic 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 fileIOExceptionpublic WordDocument append(String fileName) throws OfficeException, IOException
fileName - file path of a Word fileOfficeExceptionIOExceptionpublic WordDocument append(InputStream inputStream) throws OfficeException, IOException
inputStream - InputStream representing a Word fileOfficeExceptionIOExceptionpublic WordDocument append(byte[] docByteArray) throws OfficeException, IOException
docByteArray - byte array representing a Word fileOfficeExceptionIOExceptionpublic WordDocument append(URL docURL) throws OfficeException, IOException
docURL - URL representing a Word fileOfficeExceptionIOExceptionpublic static String getVersion()
public void saveAsPDF(String pdfFile) throws IOException, PDFException
pdfFile - String representing the name of the file to save toPDFExceptionIOExceptionpublic void saveAsPDF(OutputStream pdfFileStream) throws IOException, PDFException
pdfFileStream - Output Stream the PDF document will be written toPDFExceptionIOExceptionpublic void saveAsPDF(String pdfFile, PDFSecuritySettings securitySettings) throws PDFException, IOException
pdfFile - String representing the name of the file to save tosecuritySettings - PDFSecuritySettings object containing encryption informationIOExceptionPDFExceptionpublic void saveAsPDF(OutputStream pdfFileStream, PDFSecuritySettings securitySettings) throws PDFException, IOException
pdfFileStream - Output Stream the PDF document will be written tosecuritySettings - PDFSecuritySettings object containing encryption informationIOExceptionPDFExceptionpublic 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.PrinterExceptionOfficeExceptionpublic 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.OfficeExceptionpublic 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.OfficeExceptionpublic 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.OfficeExceptionpublic 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.IOExceptionOfficeExceptionpublic 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.IOExceptionOfficeExceptionpublic 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.IOExceptionOfficeExceptionpublic 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.IOExceptionOfficeExceptionpublic 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.IOExceptionOfficeExceptionpublic 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.IOExceptionOfficeExceptionpublic 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.IOExceptionOfficeExceptionpublic 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.IOExceptionOfficeExceptionpublic 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.IOExceptionOfficeExceptionpublic 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.IOExceptionOfficeExceptionpublic int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException
print in interface Printablegraphics - The printer graphics to draw the page ontopageFormat - The page format of the target pagepageIndex - The page to printPrinterExceptionpublic static void setUserFontDirectories(List<String> userFontDirs)
userFontDirs - - List of font directory path strings