Modifier and Type | Field and Description |
---|---|
PdfEvent<com.aspose.ms.System.Drawing.Printing.PrintEventHandler> |
EndPrint
Adds/removes subscription on the last page printing event.
|
PdfEvent<PdfQueryPageSettingsEventHandler> |
PdfQueryPageSettings
Adds/removes subscription on the last page printing event.
|
Constructor and Description |
---|
PdfViewer()
Initializes new
PdfViewer object. |
PdfViewer(IDocument document)
Initializes new
PdfViewer object. |
Modifier and Type | Method and Description |
---|---|
void |
bindPdf(IDocument srcDoc)
Initializes the facade.
|
void |
bindPdf(InputStream srcStream)
Initializes the facade.
|
void |
bindPdf(String srcFile)
Initializes the facade.
|
void |
close()
Closes the current Pdf file.
|
void |
closePdfFile()
Closes the current Pdf file.
|
BufferedImage[] |
decodeAllPages()
Get pages of current pdf file.
|
BufferedImage |
decodePage(int pageNumber)
Decodes a page of one Pdf file.
|
BufferedImage |
decodePageToImage(int pageNumber,
ImageType imageFormat)
Decodes page to BufferedImage
|
void |
dispose()
Disposes the facade resources.
|
boolean |
getAutoResize()
Sets a bool value that indicates whether the file be printed with optimized size.
|
boolean |
getAutoRotate()
Gets a bool value that indicates whether the file be printed with auto rotation
|
int |
getAutoRotateMode()
Gets an AutoRotateMode value that indicates direction of rotation
|
int |
getCoordinateType()
Gets the page coordinate type (Media/Crop boxes).
|
int |
getCopiesPrinted()
Gets copies printed
|
PrintPageSettings |
getDefaultPageSettings()
Gets the default page settings.
|
PdfPrinterSettings |
getDefaultPrinterSettings()
Gets the default printer settings.
|
int |
getFormPresentationMode()
Gets form presentation mode.
|
int |
getHorizontalAlignment()
Gets a value that indicates horizontal alignment
|
int |
getPageCount()
Gets page count of the current Pdf file.
|
String |
getPassword()
Gets input document password.
|
boolean |
getPrintAsGrayscale()
Gets or sets a bool value that indicates whether the page is being printed as grayscale.
|
boolean |
getPrintAsImage()
Gets a mode for PdfViewer to print as image.
|
String |
getPrinterJobName()
Gets name of document in printer queue when document is printed.
|
boolean |
getPrintPageDialog()
Gets a bool value that indicates whether produce the page number dialog when printing.
|
Object |
getPrintStatus()
Gets the result of printing job.
|
RenderingOptions |
getRenderingOptions()
Gets rendering options.
|
int |
getResolution()
Gets or sets resolution during viewing and printing.
|
float |
getScaleFactor()
Gets a floating point value that indicates scale factor.
|
boolean |
getUseIntermidiateImage()
Gets the using of conversion of pdf page into intermidiate png file during printing in file
mode.
|
int |
getVerticalAlignment()
Gets a value that indicates vertical alignment
|
boolean |
isShowHiddenAreas()
Deprecated.
|
void |
openPdfFile(InputStream inputStream)
Deprecated.
|
void |
openPdfFile(String filePath)
Deprecated.
|
void |
printDocument()
Prints the Pdf document using default printer.
|
void |
printDocumentWithSettings(PdfPrinterSettings printerSettings)
Prints the Pdf document with printer settings.
|
void |
printDocumentWithSettings(PrintPageSettings pageSettings,
PdfPrinterSettings printerSettings)
Prints the Pdf document with settings.
|
void |
printLargePdf(InputStream inputStream)
Opens and prints a large Pdf stream.
|
void |
printLargePdf(InputStream inputStream,
PdfPrinterSettings printerSettings)
Opens and prints a large Pdf stream with specified printer settings.
|
void |
printLargePdf(InputStream inputStream,
PrintPageSettings pageSettings,
PdfPrinterSettings printerSettings)
Opens and prints a large Pdf stream with specified page settings and printer settings.
|
void |
printLargePdf(String filePath)
Opens and prints a large Pdf file.
|
void |
printLargePdf(String filePath,
PdfPrinterSettings printerSettings)
Opens and prints a large Pdf file with specified printer settings.
|
void |
printLargePdf(String filePath,
PrintPageSettings pageSettings,
PdfPrinterSettings printerSettings)
Opens and prints a large Pdf file with specified page settings and printer settings.
|
void |
save(InputStream destStream)
Saves the result PDF document to stream.
|
void |
save(String destFile)
Saves the result PDF document to file.
|
void |
setAutoResize(boolean value)
Sets a bool value that indicates whether the file be printed with optimized size.
|
void |
setAutoRotate(boolean value)
Sets a bool value that indicates whether the file be printed with auto rotation
|
void |
setAutoRotateMode(int value)
Sets an AutoRotateMode value that indicates direction of rotation
|
void |
setCoordinateType(int value)
Sets the page coordinate type (Media/Crop boxes).
|
void |
setFormPresentationMode(int value)
Sets form presentation mode.
|
void |
setHorizontalAlignment(int value)
Sets a value that indicates horizontal alignment
|
void |
setPassword(String value)
Sets input document password.
|
void |
setPrintAsGrayscale(boolean value)
Gets or sets a bool value that indicates whether the page is being printed as grayscale.
|
void |
setPrintAsImage(boolean value)
Sets a mode for PdfViewer to print as image.
|
void |
setPrinterJobName(String value)
Sets name of document in printer queue when document is printed.
|
void |
setPrintPageDialog(boolean value)
Sets a boolean value that indicates whether produce the page number dialog when printing.
|
void |
setRenderingOptions(RenderingOptions value)
Sets rendering options.
|
void |
setResolution(int value)
Sets resolution during viewing and printing.
|
void |
setScaleFactor(float value)
Sets a floating point value that indicates scale factor.
|
void |
setShowHiddenAreas(boolean value)
Deprecated.
|
void |
setUseIntermidiateImage(boolean value)
Sets the using of conversion of pdf page into intermidiate png file during printing in file
mode.
|
void |
setVerticalAlignment(int value)
Sets a value that indicates vertical alignment
|
public final PdfEvent<PdfQueryPageSettingsEventHandler> PdfQueryPageSettings
Adds/removes subscription on the last page printing event.
public final PdfEvent<com.aspose.ms.System.Drawing.Printing.PrintEventHandler> EndPrint
public PdfViewer()
Initializes new PdfViewer
object.
public PdfViewer(IDocument document)
Initializes new PdfViewer
object.
document
- Document object.@Deprecated public boolean isShowHiddenAreas()
This method is Deprecated Gets flag that controls visibility of hidden areas on the page.
@Deprecated public void setShowHiddenAreas(boolean value)
public Object getPrintStatus()
Gets the result of printing job. If success than null; otherwise, exception object.
public boolean getUseIntermidiateImage()
Gets the using of conversion of pdf page into intermidiate png file during printing in file mode. Use it when the size of output file is important.
public void setUseIntermidiateImage(boolean value)
Sets the using of conversion of pdf page into intermidiate png file during printing in file mode. Use it when the size of output file is important.
value
- boolean value.public int getCopiesPrinted()
Gets copies printed
public int getCoordinateType()
Gets the page coordinate type (Media/Crop boxes). CropBox value is used by default.
PageCoordinateType
public void setCoordinateType(int value)
Sets the page coordinate type (Media/Crop boxes). CropBox value is used by default.
value
- PageCoordinateType elementPageCoordinateType
public boolean getPrintAsImage()
Gets a mode for PdfViewer to print as image.
public void setPrintAsImage(boolean value)
Sets a mode for PdfViewer to print as image.
value
- boolean value
public int getPageCount()
Gets page count of the current Pdf file.
public String getPassword()
Gets input document password.
public void setPassword(String value)
Sets input document password.
value
- String valuepublic boolean getPrintPageDialog()
Gets a bool value that indicates whether produce the page number dialog when printing.
public void setPrintPageDialog(boolean value)
Sets a boolean value that indicates whether produce the page number dialog when printing.
value
- boolean valuepublic boolean getPrintAsGrayscale()
Gets or sets a bool value that indicates whether the page is being printed as grayscale. By default is false.
public void setPrintAsGrayscale(boolean value)
Gets or sets a bool value that indicates whether the page is being printed as grayscale. By default is false.
value
- boolean valuepublic String getPrinterJobName()
Gets name of document in printer queue when document is printed. Default value is file name.
public void setPrinterJobName(String value)
Sets name of document in printer queue when document is printed. Default value is file name.
value
- String valuepublic int getFormPresentationMode()
Gets form presentation mode.
FormPresentationMode
public void setFormPresentationMode(int value)
Sets form presentation mode.
value
- FormPresentationMode elementpublic RenderingOptions getRenderingOptions()
Gets rendering options.
public void setRenderingOptions(RenderingOptions value)
Sets rendering options.
value
- RenderingOptions valuepublic int getVerticalAlignment()
Gets a value that indicates vertical alignment
VerticalAlignment
public void setVerticalAlignment(int value)
Sets a value that indicates vertical alignment
value
- VerticalAlignment elementVerticalAlignment
public int getHorizontalAlignment()
Gets a value that indicates horizontal alignment
HorizontalAlignment
public void setHorizontalAlignment(int value)
Sets a value that indicates horizontal alignment
value
- HorizontalAlignment elementHorizontalAlignment
public boolean getAutoResize()
Sets a bool value that indicates whether the file be printed with optimized size.
public void setAutoResize(boolean value)
Sets a bool value that indicates whether the file be printed with optimized size.
value
- boolean value: If false print page without page scaling. If true print page with scaling to
fit to printable area.public boolean getAutoRotate()
Gets a bool value that indicates whether the file be printed with auto rotation
public void setAutoRotate(boolean value)
Sets a bool value that indicates whether the file be printed with auto rotation
value
- boolean valuepublic int getAutoRotateMode()
Gets an AutoRotateMode value that indicates direction of rotation
AutoRotateMode
public void setAutoRotateMode(int value)
Sets an AutoRotateMode value that indicates direction of rotation
value
- AutoRotateMode elementAutoRotateMode
public int getResolution()
Gets or sets resolution during viewing and printing. The higher resolution, the slower speed. The default value is 150.
public void setResolution(int value)
Sets resolution during viewing and printing. The higher resolution, the slower speed. The default value is 150.
value
- int valuepublic void printLargePdf(String filePath)
Opens and prints a large Pdf file. If your Pdf file has hundreds of pages or more or its size is more than 3 MB, this method is recommended to get better performance.
PdfViewer viewer = new PdfViewer(); viewer.setAutoResize(true); // print the file with adjusted size viewer.setAutoRotate(true); // print the file with adjusted rotation viewer.setPrintPageDialog(false);// do not produce the page number dialog when // printing viewer.setPrintLargePdf("d:\test.pdf");
filePath
- The path of Pdf file.
public void printLargePdf(InputStream inputStream)
Opens and prints a large Pdf stream. If your Pdf file has hundreds of pages or more or its size is more than 3 MB, this method is recommended to get better performance.
PdfViewer viewer = new PdfViewer(); viewer.setAutoResize ( true); //print the file with adjusted size viewer.setAutoRotate ( true); //print the file with adjusted rotation viewer.printPageDialog=false;//do not produce the page number dialog when printing viewer.printLargePdf(new MemoryStream(File.ReadAllBytes(@"d:\test.pdf"))); viewer.closePdfFile();
inputStream
- The pdf stream to be opened and printed..public void printLargePdf(String filePath, PdfPrinterSettings printerSettings)
Opens and prints a large Pdf file with specified printer settings. If your Pdf file has hundreds of pages or more or its size is more than 3 MB, this method is recommended to get better performance.
PdfViewer viewer = new PdfViewer(); viewer.setAutoResize ( true); //print the file with adjusted size viewer.setAutoRotate ( true); //print the file with adjusted rotation viewer.setPrintPageDialog ( false);//do not produce the page number dialog when printing PrinterSettings ps = new PrinterSettings(); PrintDocument prtdoc = new PrintDocument(); ps.setPrinterName ( prtdoc.getPrinterSettings().getPrinterName()); viewer.printLargePdf("d:\\test.pdf",ps); viewer.closePdfFile();
filePath
- The path of Pdf file.printerSettings
- The printer settings.public void printLargePdf(InputStream inputStream, PdfPrinterSettings printerSettings)
Opens and prints a large Pdf stream with specified printer settings. If your Pdf file has hundreds of pages or more or its size is more than 3 MB, this method is recommended to get better performance.
PdfViewer viewer = new PdfViewer(); viewer.setAutoResize(true); // print the file with adjusted size viewer.setAutoRotate(true); // print the file with adjusted rotation viewer.setPrintPageDialog(false); // do not produce the page number dialog when // printing PrinterSettings ps = new PrinterSettings(); PrintDocument prtdoc = new PrintDocument(); ps.setPrinterName(prtdoc.getPrinterSettings().getPrinterName()); viewer.printLargePdf(new FileInputStream("d:\\middleware.pdf"), ps); viewer.closePdfFile();
inputStream
- The pdf stream to be opened and printed..printerSettings
- The printer settings.public void printLargePdf(String filePath, PrintPageSettings pageSettings, PdfPrinterSettings printerSettings)
Opens and prints a large Pdf file with specified page settings and printer settings. If your Pdf file has hundreds of pages or more or its size is more than 3 MB, this method is recommended to get better performance.
PdfViewer viewer = new PdfViewer(); viewer.setAutoResize(true); // print the file with adjusted size viewer.setAutoRotate(true); // print the file with adjusted rotation viewer.setPrintPageDialog(false); // do not produce the page number dialog when // printing PrinterSettings ps = new PrinterSettings(); PrintDocument prtdoc = new PrintDocument(); ps.setPrinterName(prtdoc.getPrinterSettings().getPrinterName()); PageSettings pgs = new PageSettings(); pgs.setPaperSize(new PaperSize("A4", 827, 1169)); pgs.setMargins(new Margins(0, 0, 0, 0)); viewer.printLargePdf("d:\\test.pdf", pgs, ps); viewer.closePdfFile();
filePath
- The path of Pdf file.pageSettings
- The page settings.printerSettings
- The printer settings.public void printLargePdf(InputStream inputStream, PrintPageSettings pageSettings, PdfPrinterSettings printerSettings)
Opens and prints a large Pdf stream with specified page settings and printer settings. If your Pdf file has hundreds of pages or more or its size is more than 3 MB, this method is recommended to get better performance.
PdfViewer viewer = new PdfViewer(); viewer.setAutoResize ( true); //print the file with adjusted size viewer.setAutoRotate ( true); //print the file with adjusted rotation viewer.setPrintPageDialog ( false);//do not produce the page number dialog when printing PrinterSettings ps = new PrinterSettings(); PrintDocument prtdoc = new PrintDocument(); ps.setPrinterName ( prtdoc.getPrinterSettings().getPrinterName()); PageSettings pgs = new PageSettings(); pgs.setPaperSize ( new PaperSize("A4", 827, 1169)); pgs.setMargins ( new Margins(0, 0, 0, 0)); viewer.printLargePdf(new FileInputStream("d:\\middleware.pdf"),pgs,ps); viewer.closePdfFile();
inputStream
- The pdf stream to be opened and printed.pageSettings
- The page settings.printerSettings
- The printer settings.public BufferedImage[] decodeAllPages()
Get pages of current pdf file.
public BufferedImage decodePage(int pageNumber)
Decodes a page of one Pdf file.
pageNumber
- The page number of one Pdf file which must be between 1 and PageCount.public void printDocumentWithSettings(PrintPageSettings pageSettings, PdfPrinterSettings printerSettings)
Prints the Pdf document with settings. If the document size is not complatible to page size, pdf.kit will extend it to fit page size.
PdfViewer viewer = new PdfViewer(); viewer.openPdfFile("d:\\test.pdf"); viewer.setAutoResize ( true); //print the file with adjusted size viewer.setAutoRotate ( true); //print the file with adjusted rotation viewer.setPrintPageDialog ( false);//do not produce the page number dialog when printing PrinterSettings ps = new PrinterSettings(); PrintDocument prtdoc = new PrintDocument(); ps.setPrinterName ( prtdoc.getPrinterSettings.getPrinterName()); PageSettings pgs = new PageSettings(); pgs.setPaperSize ( new PaperSize("A4", 827, 1169)); pgs.setMargins ( new Margins(0, 0, 0, 0)); viewer.printDocumentWithSettings(pgs, ps); viewer.closePdfFile();
pageSettings
- The page setting of the printing document.printerSettings
- The printer setting of the printing document.
public void printDocumentWithSettings(PdfPrinterSettings printerSettings)
Prints the Pdf document with printer settings. The output page size will fit the the document first page size.
PdfViewer viewer = new PdfViewer(); viewer.openPdfFile("d:\\test.pdf"); viewer.setAutoResize ( true); //print the file with adjusted size viewer.setAutoRotate ( true); //print the file with adjusted rotation viewer.setPrintPageDialog ( false); //do not produce the page number dialog when printing PrinterSettings ps = new PrinterSettings(); PrintDocument prtdoc = new PrintDocument(); ps.setPrinterName ( prtdoc.getPrinterSettings().PrinterName()); viewer.printDocumentWithSettings(ps); viewer.closePdfFile();
printerSettings
- The printer setting of the printing document.public void printDocument()
Prints the Pdf document using default printer.
PdfViewer viewer = new PdfViewer(); viewer.openPdfFile("d:\\test.pdf"); viewer.setAutoResize ( true); //print the file with adjusted size viewer.setAutoRotate ( true); //print the file with adjusted rotation viewer.setPrintPageDialog ( false); //do not produce the page number dialog when printing viewer.printDocument(ps); viewer.closePdfFile();
public PrintPageSettings getDefaultPageSettings()
Gets the default page settings.
public PdfPrinterSettings getDefaultPrinterSettings()
Gets the default printer settings.
@Deprecated public void openPdfFile(String filePath)
Opens a Pdf file, but does not actually decode the pages of the Pdf file.
PdfViewer viewer = new PdfViewer(); viewer.openPdfFile("d:\\test.pdf"); viewer.closePdfFile();
filePath
- The path of Pdf file.@Deprecated public void openPdfFile(InputStream inputStream)
Opens a Pdf file stream. But does not actually decode the pages of the Pdf file.
PdfViewer viewer = new PdfViewer(); viewer.openPdfFile(new FileInputStream("d:\\test.pdf"))); viewer.closePdfFile();
inputStream
- The pdf stream to be opened.public void closePdfFile()
Closes the current Pdf file.
public BufferedImage decodePageToImage(int pageNumber, ImageType imageFormat)
Decodes page to BufferedImage
pageNumber
- int valueimageFormat
- ImageType objectpublic float getScaleFactor()
Gets a floating point value that indicates scale factor. The default value is 1.0.
public void setScaleFactor(float value)
Sets a floating point value that indicates scale factor. The default value is 1.0.
value
- floating point value.public void bindPdf(String srcFile)
Initializes the facade.
public void bindPdf(InputStream srcStream)
Initializes the facade.
public void bindPdf(IDocument srcDoc)
Initializes the facade.
public void save(String destFile)
Saves the result PDF document to file.
destFile
- The path of output PDF document.public void save(InputStream destStream)
Saves the result PDF document to stream.
destStream
- The stream of output PDF document.public void dispose()
Disposes the facade resources.
dispose
in interface com.aspose.ms.System.IDisposable