com.spire.pdf
Class PdfDocument

java.lang.Object
  extended by com.spire.pdf.PdfDocument

public class PdfDocument
extends java.lang.Object

Root object of the library to create PDF files.


Constructor Summary
PdfDocument()
          Initializes a new instance of the class.
PdfDocument(byte[] bytes)
          Initializes a new instance of the class.
PdfDocument(byte[] bytes, java.lang.String password)
          Initializes a new instance of the class.
PdfDocument(java.io.InputStream stream)
          Initializes a new instance of the class.
PdfDocument(java.io.InputStream stream, java.lang.String password)
          Initializes a new instance.
PdfDocument(PdfConformanceLevel Pdflevel)
          Deprecated. This method will be removed in the future.
PdfDocument(java.lang.String filename)
          Initializes a new instance of the class.
PdfDocument(java.lang.String filename, java.lang.String password)
          Initializes a new instance of the class.
 
Method Summary
 PdfPageBase appendPage()
          append a page to the pdf files
 void appendPage(PdfDocument doc)
          append a page to the pdf files
static void clearCustomFontsFolders()
          Clear the path of the folder where the custom font is located.
 void close()
          Closes the document.
 void createBooklet(java.lang.String fileName, double width, double height, boolean bothSides)
          Create booklet.
 void createBooklet(java.lang.String fileName, float width, float height, boolean bothSides)
          for the document create booklet
 void createBooklet(java.lang.String fileName, float width, float height, boolean bothSides, DrawPageInBookletEventHandler beginDrawPage, DrawPageInBookletEventHandler endDrawPage)
          Create booklet.
 void decrypt()
          Decrypts the document.
 void decrypt(java.lang.String ownerPassword)
          Decrypts the document.
 java.lang.Object deepClone()
          Creates a new object that is a copy of the current instance.
 void dispose()
          Releases unmanaged resources and performs other cleanup operations before the is reclaimed by garbage collection.
 void encrypt(PdfSecurityPolicy securityPolicy)
          Encrypts the document.
 PdfAction getAfterOpenAction()
          Gets the action to execute when the document is opened.
 PdfJavaScriptAction getAfterPrintAction()
          Gets the action to be performed after the document is printed.
 PdfJavaScriptAction getAfterSaveAction()
          Gets the jave script action to be performed after the document is saved.
 boolean getAllowCreateForm()
          Get or Set Allow Create Form.
 PdfAttachmentCollection getAttachments()
          Gets the collection of document attachments displayed on a PDF page.
 PdfJavaScriptAction getBeforeCloseAction()
          Gets the action to be performed before the document is closed.
 PdfJavaScriptAction getBeforePrintAction()
          Gets or sets the action to be performed before the document is printed.
 PdfJavaScriptAction getBeforeSaveAction()
          Gets the java script action to be performed before the document is saved.
 PdfBookmarkCollection getBookmarks()
          Gets the bookmarks.
 PdfCollection getCollection()
          Gets pdf collections.
 PdfColorSpace getColorSpace()
          Gets the color space for page that will be created.
 PdfCompressionLevel getCompressionLevel()
          Gets or sets the desired level of stream compression.
 PdfConformanceLevel getConformance()
          Get document PdfConformanceLevel
 PdfConvertOptions getConvertOptions()
          Gets some options when do convert operation.
 int getCustomScaling()
          Get current document print PageScaling
 PdfDocumentInformation getDocumentInformation()
          Gets document's information and properties.
 PdfPieceInfo getDocumentPieceInfo()
          Gets document piece info.
static boolean getEnableFontCache()
          Indicates whether enable font cache.
static boolean getExportTextEnableOCR()
           
static IOCR getExportTextOCRHandler()
           
 PdfFileInfo getFileInfo()
          Get The file info int the PDF document
 PdfForm getForm()
          Gets the loaded form.
 PdfDocumentActions getJavaScripts()
          Gets the additional document's actions.
 PdfLayerCollection getLayers()
          Gets Optional content properties
 PdfXmpMetadata getMetadata()
          Get the document metadata.
 PdfCatalogNames getNames()
          Gets document catalog names.
 PdfPageLabels getPageLabels()
          Get page labels.
 PdfPageCollection getPages()
          Gets the pages.
 PdfPrintPageScaling getPageScaling()
          Get PdfDocument Print PageScaling
 PdfPageSettings getPageSettings()
          Get a page settings in the pdf documents
 PdfDocumentBase getPDFStandard()
          Deprecated. 
 PrintSettings getPrintSettings()
          Get print settings.
 boolean getPrintUsingImageMode()
          get print by using image mode
 PdfSectionCollection getSections()
          Gets the sections of a page
 PdfSecurity getSecurity()
          Deprecated. This method may be removed in the future. please use methods(Encrypt(PdfSecurityPolicy SecurityPolicy), decrypt(), getSecurityPolicy()) instead.
 PdfSecurityPolicy getSecurityPolicy()
          Gets the document's security policy.
 byte[] getSignatreContuent(java.lang.String signName)
          Get the signature content
 java.lang.Object getTag()
           
 PdfDocumentTemplate getTemplate()
          Gets the template of pdf document
 PdfUsedFont[] getUsedFonts()
          Gets the m_fonts which are available in the PDF document.
 boolean getUseHighQualityImage()
          Indicates whether to use the high qulity image when convert document
 PdfViewerPreferences getViewerPreferences()
          Gets a viewer preferences object controlling the way the document is to be presented on the screen or in print.
 PdfPageBase insertPage(PdfDocument doc, int pageIndex)
          Imports a page.
 PdfPageBase insertPage(PdfDocument doc, int pageIndex, int resultPageIndex)
          Imports a page.
 PdfPageBase insertPage(PdfDocument doc, PdfPageBase page)
          Imports a page.
 PdfPageBase insertPageRange(PdfDocument doc, int startIndex, int endIndex)
          Imports a page range from a loaded document.
static boolean isAutoOptimizingTextColor()
           
static void isAutoOptimizingTextColor(boolean autoOptimizingTextColor)
           
 boolean isEncrypted()
          Indicates the document is encrypted or not
static boolean isPasswordProtected(java.io.InputStream stream)
          Deprecated. use PdfDocument.isEncrypted() instead.
static boolean isPasswordProtected(java.lang.String fileName)
          Deprecated. use PdfDocument.isEncrypted() instead.
 boolean isPortfolio()
          Indicates the document is a PDF Portfolio or not.
 void loadFromBytes(byte[] bytes)
          Initializes a new instance of the class.
 void loadFromFile(java.lang.String filename)
          Initializes a new instance of the class.
 void loadFromFile(java.lang.String fileName, FileFormat fileFormat)
          Loading the specified format file.
 void loadFromFile(java.lang.String filename, java.lang.String password)
          Initializes a new instance of the class.
 void loadFromStream(java.io.InputStream stream)
          Initializes a new instance of the class.
 void loadFromSvg(java.io.InputStream stream)
          Load pdf from svg stream.
 void loadFromSvg(java.lang.String fileName)
          Load Pdf from svg file.
 void loadFromXPS(byte[] xpsBytes)
          Load a xps bytes array.
 void loadFromXPS(java.io.InputStream xpsStream)
          Load a xps stream.
 void loadFromXPS(java.lang.String fileName)
          Load a xps file.
static PdfDocumentBase merge(PdfDocumentBase dest, java.lang.Object... srcs)
          Merges the specified source documents and return destination document.
static PdfDocumentBase mergeFiles(java.io.InputStream[] inputStreams)
          Merges the PDF documents specified by the Stream.
static void mergeFiles(com.spire.ms.System.IO.Stream[] inputFiles, com.spire.ms.System.IO.Stream outputFile)
          Merge the PDF documents.
static PdfDocumentBase mergeFiles(java.lang.String[] InputFiles)
          Merges the PDF documents specified by the paths The array of string paths. A new PDF document containing all merged documents.
static void mergeFiles(java.lang.String[] inputFiles, java.lang.String outputFile)
          Merge the PDF documents.
static PdfDocumentBase mergeFiles(java.lang.String firstInputFile, java.lang.String secInputFile)
          Merges the PDF documents specified by the paths.
 void print()
          Print document
 void print(PrintSettings printSettings)
          Print document.
 boolean removeDocumentJavaScript()
          remove document's javaScript
 java.awt.image.BufferedImage saveAsImage(int pageIndex)
          Saves PDF document page as BufferedImage
 java.awt.image.BufferedImage saveAsImage(int pageIndex, PdfImageType type)
          Saves PDF document page as image
 java.awt.image.BufferedImage saveAsImage(int pageIndex, PdfImageType type, int dpiX, int dpiY)
          Saves PDF document page as image,Set PdfImageType and image Dpi
 void saveToFile(java.lang.String filename)
          Saves PDF document to file.
 void saveToFile(java.lang.String filename, FileFormat fileFormat)
          Saves PDF document to file.
 void saveToFile(java.lang.String filename, int startIndex, int endIndex, FileFormat fileFormat)
          Saves PDF document to other Format files.
 void saveToPdf(java.lang.String fileName, PdfConformanceLevel pdfConformanceLevel)
          Deprecated. Please use PdfStandardsConverter instead.
 void saveToPdfX1A2001(java.lang.String fileName)
          Deprecated. 
 java.io.ByteArrayOutputStream[] saveToStream(FileFormat format)
          Convert the specified range of the document pages to the format file which saved to streams.
 java.io.ByteArrayOutputStream[] saveToStream(int startIndex, int endIndex, FileFormat format)
          Convert the specified range of the document pages to the format file which saved to streams.
 void saveToStream(java.io.OutputStream stream)
          Saves the document to the specified stream.
 void saveToStream(java.io.OutputStream stream, FileFormat format)
          Saves the document to the specified stream.
 void saveToTiff(java.lang.String tiffFilename)
          Save the document to tiff.
 void saveToTiff(java.lang.String tiffFilename, int startPage, int endPage, int dpix, int dpiy)
           
 void saveToTiff(java.lang.String tiffFilename, int startPage, int endPage, TiffCompressionTypes tiffCompressionTypes)
          Deprecated. 
 void setAfterOpenAction(PdfAction value)
          Sets the action to execute when the document is opened.
 void setAfterPrintAction(PdfJavaScriptAction value)
          Sets the action to be performed after the document is printed.
 void setAfterSaveAction(PdfJavaScriptAction value)
          Sets the jave script action to be performed after the document is saved.
 void setAllowCreateForm(boolean value)
           
 void setBeforeCloseAction(PdfJavaScriptAction value)
          Sets the action to be performed before the document is closed.
 void setBeforePrintAction(PdfJavaScriptAction value)
          Sets the action to be performed before the document is printed.
 void setBeforeSaveAction(PdfJavaScriptAction value)
          Sets the java script action to be performed before the document is saved.
 void setColorSpace(PdfColorSpace value)
          Sets the color space for page that will be created.
 void setCompressionLevel(PdfCompressionLevel value)
          Sets the desired level of stream compression.
static void setCustomFontsFolders(java.lang.String fontPath)
          Set the path to the folder where the custom font is located.
 void setCustomScaling(int value)
          Set current document print PageScaling
 void setDocumentPieceInfo(PdfPieceInfo pieceInfo)
          Sets document piece info.
static void setEnableFontCache(boolean value)
           
static void setExportTextEnableOCR(boolean enableOCR)
           
static void setExportTextOCRHandler(IOCR iOCR)
          when export text,if have image ,will call IOCR and add text to export content.
static void setExportTextOCRHandler(IOCR iOCR, boolean enableOCR)
           
 void setFileInfo(PdfFileInfo value)
          Set The file info int the PDF document
 void setMetadata(PdfXmpMetadata metadata)
          Set the document metadata.
 void setPageLabels(PdfPageLabels value)
          Get page labels.
 void setPageScaling(PdfPrintPageScaling value)
          Set PdfDocument Print PageScaling
 void setPageSettings(PdfPageSettings value)
          Set a page settings in the pdf documents
 void setPDFStandard(PdfDocumentBase value)
          Deprecated. 
 void setPrintUsingImageMode(boolean usingImageMode)
          set print by using image mode
 void setTag(java.lang.Object value)
           
 void setUseHighQualityImage(boolean value)
           
 void setUsePsDirectlyForConvert(boolean value)
           
 void setViewerPreferences(PdfViewerPreferences value)
          Sets a viewer preferences object controlling the way the document is to be presented on the screen or in print.
 void split(java.lang.String destFilePattern)
          Splits a PDF file to many PDF files, each of them consists of one page from the source file.
 void split(java.lang.String destFilePattern, int startNumber)
          Splits a PDF file to many PDF files, each of them consists of one page from the source file.
 boolean verifySignature(java.lang.String signName)
          Verify signature in the pdf Document
 

Constructor Detail

PdfDocument

public PdfDocument()
Initializes a new instance of the class.


PdfDocument

public PdfDocument(java.lang.String filename)
Initializes a new instance of the class.

Parameters:
filename - The path to source pdf file.
See Also:
This constructor imports an existing pdf file into the document Object. It automatically populates the Pages collection with the pages of the given document.

PdfDocument

public PdfDocument(java.lang.String filename,
                   java.lang.String password)
Initializes a new instance of the class.

Parameters:
filename - The path to source PDF document.
password - The password (user or owner) of the encrypted document.

PdfDocument

@Deprecated
public PdfDocument(PdfConformanceLevel Pdflevel)
Deprecated. This method will be removed in the future.

Set Document PdfConformanceLevel

Parameters:
Pdflevel -

PdfDocument

public PdfDocument(byte[] bytes)
Initializes a new instance of the class.

Parameters:
bytes - The byte array with the file content.

PdfDocument

public PdfDocument(byte[] bytes,
                   java.lang.String password)
Initializes a new instance of the class.

Parameters:
bytes - The byte array with the file content.
password - The password (user or owner) of the encrypted document.

PdfDocument

public PdfDocument(java.io.InputStream stream)
Initializes a new instance of the class.

Parameters:
stream - The stream with the file.

PdfDocument

public PdfDocument(java.io.InputStream stream,
                   java.lang.String password)
Initializes a new instance.

Parameters:
stream - The stream with the file.
password - The password (user or owner) of the encrypted document.
Method Detail

getUseHighQualityImage

public boolean getUseHighQualityImage()
Indicates whether to use the high qulity image when convert document


setUseHighQualityImage

public void setUseHighQualityImage(boolean value)

getAllowCreateForm

public boolean getAllowCreateForm()
Get or Set Allow Create Form.


setAllowCreateForm

public void setAllowCreateForm(boolean value)

setUsePsDirectlyForConvert

public void setUsePsDirectlyForConvert(boolean value)

getConvertOptions

public PdfConvertOptions getConvertOptions()
Gets some options when do convert operation.

Returns:
ConvertOptions

getPageScaling

public PdfPrintPageScaling getPageScaling()
Get PdfDocument Print PageScaling


setPageScaling

public void setPageScaling(PdfPrintPageScaling value)
Set PdfDocument Print PageScaling


getCustomScaling

public int getCustomScaling()
Get current document print PageScaling


setCustomScaling

public void setCustomScaling(int value)
Set current document print PageScaling


getPDFStandard

@Deprecated
public PdfDocumentBase getPDFStandard()
Deprecated. 

Get Current active pdf object


setPDFStandard

@Deprecated
public void setPDFStandard(PdfDocumentBase value)
Deprecated. 

Set Current active pdf object


getConformance

public PdfConformanceLevel getConformance()
Get document PdfConformanceLevel


getAttachments

public PdfAttachmentCollection getAttachments()
Gets the collection of document attachments displayed on a PDF page.


getBookmarks

public PdfBookmarkCollection getBookmarks()
Gets the bookmarks.


getColorSpace

public PdfColorSpace getColorSpace()
Gets the color space for page that will be created.


setColorSpace

public void setColorSpace(PdfColorSpace value)
Sets the color space for page that will be created.


getDocumentInformation

public PdfDocumentInformation getDocumentInformation()
Gets document's information and properties.


getDocumentPieceInfo

public PdfPieceInfo getDocumentPieceInfo()
Gets document piece info.


setDocumentPieceInfo

public void setDocumentPieceInfo(PdfPieceInfo pieceInfo)
Sets document piece info.


getJavaScripts

public PdfDocumentActions getJavaScripts()
Gets the additional document's actions.


getNames

public PdfCatalogNames getNames()
Gets document catalog names.


getPageLabels

public PdfPageLabels getPageLabels()
Get page labels.


setPageLabels

public void setPageLabels(PdfPageLabels value)
Get page labels.


getForm

public PdfForm getForm()
Gets the loaded form.


getPages

public PdfPageCollection getPages()
Gets the pages.


getUsedFonts

public PdfUsedFont[] getUsedFonts()
Gets the m_fonts which are available in the PDF document.


getCompressionLevel

public PdfCompressionLevel getCompressionLevel()
Gets or sets the desired level of stream compression.

See Also:
All new objects should be compressed with this level of the compression.

setCompressionLevel

public void setCompressionLevel(PdfCompressionLevel value)
Sets the desired level of stream compression.

Parameters:
value -

getPageSettings

public PdfPageSettings getPageSettings()
Get a page settings in the pdf documents

Returns:
PdfPage Settings info

setPageSettings

public void setPageSettings(PdfPageSettings value)
Set a page settings in the pdf documents


getSections

public PdfSectionCollection getSections()
Gets the sections of a page

Returns:
SectionCollection

getFileInfo

public PdfFileInfo getFileInfo()
Get The file info int the PDF document


setFileInfo

public void setFileInfo(PdfFileInfo value)
Set The file info int the PDF document


getSecurity

@Deprecated
public PdfSecurity getSecurity()
Deprecated. This method may be removed in the future. please use methods(Encrypt(PdfSecurityPolicy SecurityPolicy), decrypt(), getSecurityPolicy()) instead.

Gets the security parameters of the document.


getSecurityPolicy

public PdfSecurityPolicy getSecurityPolicy()
Gets the document's security policy.

Returns:
The document's security policy.

getViewerPreferences

public PdfViewerPreferences getViewerPreferences()
Gets a viewer preferences object controlling the way the document is to be presented on the screen or in print.


setViewerPreferences

public void setViewerPreferences(PdfViewerPreferences value)
Sets a viewer preferences object controlling the way the document is to be presented on the screen or in print.


getAfterOpenAction

public PdfAction getAfterOpenAction()
Gets the action to execute when the document is opened.

Returns:
An object specifying the action to be executed after the document is Opened.

setAfterOpenAction

public void setAfterOpenAction(PdfAction value)
Sets the action to execute when the document is opened.

Parameters:
value - An object specifying the action to be executed after the document is Opened.

getAfterPrintAction

public PdfJavaScriptAction getAfterPrintAction()
Gets the action to be performed after the document is printed.


setAfterPrintAction

public void setAfterPrintAction(PdfJavaScriptAction value)
Sets the action to be performed after the document is printed.

Parameters:
value - An object specifying the action to be executed after the document is printed. .

getAfterSaveAction

public PdfJavaScriptAction getAfterSaveAction()
Gets the jave script action to be performed after the document is saved.


setAfterSaveAction

public void setAfterSaveAction(PdfJavaScriptAction value)
Sets the jave script action to be performed after the document is saved.

Parameters:
value - An object specifying the action to be executed after the document is saved.

getBeforeCloseAction

public PdfJavaScriptAction getBeforeCloseAction()
Gets the action to be performed before the document is closed.


setBeforeCloseAction

public void setBeforeCloseAction(PdfJavaScriptAction value)
Sets the action to be performed before the document is closed.

Parameters:
value - An object specifying the action to be executed before the document is closed.

getBeforePrintAction

public PdfJavaScriptAction getBeforePrintAction()
Gets or sets the action to be performed before the document is printed.


setBeforePrintAction

public void setBeforePrintAction(PdfJavaScriptAction value)
Sets the action to be performed before the document is printed.

Parameters:
value - An object specifying the action to be executed before the document is printed.

getBeforeSaveAction

public PdfJavaScriptAction getBeforeSaveAction()
Gets the java script action to be performed before the document is saved.


setBeforeSaveAction

public void setBeforeSaveAction(PdfJavaScriptAction value)
Sets the java script action to be performed before the document is saved.


getMetadata

public PdfXmpMetadata getMetadata()
Get the document metadata.

Returns:
The document metadata.

setMetadata

public void setMetadata(PdfXmpMetadata metadata)
Set the document metadata.

Parameters:
metadata - The document metadata.

getTemplate

public PdfDocumentTemplate getTemplate()
Gets the template of pdf document


getEnableFontCache

public static boolean getEnableFontCache()
Indicates whether enable font cache.


setEnableFontCache

public static void setEnableFontCache(boolean value)

getTag

public java.lang.Object getTag()

setTag

public void setTag(java.lang.Object value)

isEncrypted

public boolean isEncrypted()
Indicates the document is encrypted or not


isPortfolio

public boolean isPortfolio()
Indicates the document is a PDF Portfolio or not.

Returns:
isPortfolio

getLayers

public PdfLayerCollection getLayers()
Gets Optional content properties

Returns:
Layer

getCollection

public PdfCollection getCollection()
Gets pdf collections.

Returns:
Collections.

dispose

public void dispose()
Releases unmanaged resources and performs other cleanup operations before the is reclaimed by garbage collection.


loadFromFile

public void loadFromFile(java.lang.String filename,
                         java.lang.String password)
Initializes a new instance of the class.

Parameters:
filename - The path to source PDF document.
password - The password (user or owner) of the encrypted document.

loadFromFile

public void loadFromFile(java.lang.String filename)
Initializes a new instance of the class.

Parameters:
filename - The path to source pdf file.
See Also:
This constructor imports an existing pdf file into the document Object. It automatically populates the Pages collection with the pages of the given document.

loadFromFile

public void loadFromFile(java.lang.String fileName,
                         FileFormat fileFormat)
Loading the specified format file.

Parameters:
fileName - The path to source pdf file.
fileFormat - The file format.

loadFromXPS

public void loadFromXPS(byte[] xpsBytes)
Load a xps bytes array.

Parameters:
xpsBytes - the xps byte array

loadFromXPS

public void loadFromXPS(java.lang.String fileName)
Load a xps file.

Parameters:
fileName -

loadFromXPS

public void loadFromXPS(java.io.InputStream xpsStream)
Load a xps stream.

Parameters:
xpsStream -

loadFromSvg

public void loadFromSvg(java.lang.String fileName)
Load Pdf from svg file.

Parameters:
fileName - A relative or absolute path for the svg file

loadFromSvg

public void loadFromSvg(java.io.InputStream stream)
Load pdf from svg stream.

Parameters:
stream - A Svg file stream

loadFromBytes

public void loadFromBytes(byte[] bytes)
Initializes a new instance of the class.

Parameters:
bytes - The byte array with the file content.

loadFromStream

public void loadFromStream(java.io.InputStream stream)
Initializes a new instance of the class.

Parameters:
stream - The stream with the file.

encrypt

public void encrypt(PdfSecurityPolicy securityPolicy)
Encrypts the document.

Parameters:
securityPolicy - The security policy.

decrypt

public void decrypt()
Decrypts the document.


decrypt

public void decrypt(java.lang.String ownerPassword)
Decrypts the document.

Parameters:
ownerPassword - The ownerPassword.

createBooklet

public void createBooklet(java.lang.String fileName,
                          float width,
                          float height,
                          boolean bothSides)
for the document create booklet

Parameters:
fileName - booklet file Name
width - booklet width
height - booklet height
bothSides - booklet double Side

createBooklet

public void createBooklet(java.lang.String fileName,
                          double width,
                          double height,
                          boolean bothSides)
Create booklet.

Parameters:
fileName - booklet name
width - The page width
height - The page height
bothSides - booklet doubleSide

createBooklet

public void createBooklet(java.lang.String fileName,
                          float width,
                          float height,
                          boolean bothSides,
                          DrawPageInBookletEventHandler beginDrawPage,
                          DrawPageInBookletEventHandler endDrawPage)
Create booklet.

Parameters:
fileName - booklet name
width - The booklet page width
height - The booklet page height
bothSides - booklet double Side
beginDrawPage - booklet begin Draw Page
endDrawPage - booklet end Draw Page

verifySignature

public boolean verifySignature(java.lang.String signName)
Verify signature in the pdf Document

Parameters:
signName - sign Name
Returns:
if return true the document is verify Signature

getSignatreContuent

public byte[] getSignatreContuent(java.lang.String signName)
Get the signature content

Parameters:
signName - The signature name.
Returns:
Bytes of the signature content.

isPasswordProtected

@Deprecated
public static boolean isPasswordProtected(java.lang.String fileName)
Deprecated. use PdfDocument.isEncrypted() instead.

Whether the file is password protected.

Parameters:
fileName - The file name
Returns:
if password protected,return true, otherwise false

isPasswordProtected

@Deprecated
public static boolean isPasswordProtected(java.io.InputStream stream)
Deprecated. use PdfDocument.isEncrypted() instead.

Whether the file is password protected.

Parameters:
stream - The file stream
Returns:
if password protected,return true, otherwise false

close

public void close()
Closes the document. completely if set to true the document should be disposed completely.

See Also:
The document is disposed after calling the Close method. So, the document can not be saved if Close method was invoked.

saveToStream

public void saveToStream(java.io.OutputStream stream)
Saves the document to the specified stream.

Parameters:
stream - The stream object where PDF document will be saved.

saveToStream

public void saveToStream(java.io.OutputStream stream,
                         FileFormat format)
Saves the document to the specified stream.

Parameters:
stream - The output stream.
format - The file format.

saveToStream

public java.io.ByteArrayOutputStream[] saveToStream(FileFormat format)
Convert the specified range of the document pages to the format file which saved to streams. FileFormat.PDF:not supported. FileFormat.XPS:return only one stream(XPS support paging). FileFormat.DOC:return only one stream(DOC support paging). FileFormat.SVG:return multiple streams(SVG not support paging,one stream to one page). FileFormat.HTML:return only one stream(HTML support paging). FileFormat.DOCX:return only one stream(DOCX support paging).

Parameters:
format - The file format
Returns:
The format file streams.

saveToStream

public java.io.ByteArrayOutputStream[] saveToStream(int startIndex,
                                                    int endIndex,
                                                    FileFormat format)
Convert the specified range of the document pages to the format file which saved to streams. FileFormat.PDF:not supported. FileFormat.XPS:return only one stream(XPS support paging). FileFormat.DOC:return only one stream(DOC support paging). FileFormat.SVG:return multiple streams(SVG not support paging,one stream to one page). FileFormat.HTML:return only one stream(HTML support paging). FileFormat.DOCX:return only one stream(DOCX support paging).

Parameters:
startIndex - The start index.
endIndex - The end index.
format - The file format
Returns:
The format file streams.

saveToFile

public void saveToFile(java.lang.String filename)
Saves PDF document to file.

Parameters:
filename - A relative or absolute path for the file

saveToTiff

public void saveToTiff(java.lang.String tiffFilename)
Save the document to tiff.

Parameters:
tiffFilename - A relative or absolute path for the tiff file.

saveToTiff

@Deprecated
public void saveToTiff(java.lang.String tiffFilename,
                                  int startPage,
                                  int endPage,
                                  TiffCompressionTypes tiffCompressionTypes)
Deprecated. 

Save the document to tiff.

Parameters:
tiffFilename - A relative or absolute path for the tiff file.
startPage - The start page index.
endPage - The end page index.
tiffCompressionTypes -

saveToTiff

public void saveToTiff(java.lang.String tiffFilename,
                       int startPage,
                       int endPage,
                       int dpix,
                       int dpiy)
Parameters:
tiffFilename - A relative or absolute path for the tiff file
startPage - The strat page index
endPage - The end page index
dpix - The dpix
dpiy - The dpiy

saveToFile

public void saveToFile(java.lang.String filename,
                       FileFormat fileFormat)
Saves PDF document to file.

Parameters:
filename - A relative or absolute path for the file
fileFormat - File format for the file

saveToPdfX1A2001

@Deprecated
public void saveToPdfX1A2001(java.lang.String fileName)
Deprecated. 

resave file to Pdf X1A2001 type file. recommand to use saveToPdf(filename,PdfConformanceLevel).

Parameters:
fileName -

saveToPdf

@Deprecated
public void saveToPdf(java.lang.String fileName,
                                 PdfConformanceLevel pdfConformanceLevel)
Deprecated. Please use PdfStandardsConverter instead.

this is recreate pdf for pdf conformance.

Parameters:
fileName -
pdfConformanceLevel -

saveToFile

public void saveToFile(java.lang.String filename,
                       int startIndex,
                       int endIndex,
                       FileFormat fileFormat)
Saves PDF document to other Format files. Current only supports save PDF document to SVG

Parameters:
filename - A relative or absolute path for the file
startIndex - The start page index.The index starts at 0
endIndex - The end page index.
fileFormat - File format for the file

saveAsImage

public java.awt.image.BufferedImage saveAsImage(int pageIndex)
Saves PDF document page as BufferedImage

Parameters:
pageIndex - Page with page index to save as image
Returns:
Returns page as BufferedImage

saveAsImage

public java.awt.image.BufferedImage saveAsImage(int pageIndex,
                                                PdfImageType type)
Saves PDF document page as image

Parameters:
pageIndex - Page index
type - PdfImageType type
Returns:
Returns page as Image

saveAsImage

public java.awt.image.BufferedImage saveAsImage(int pageIndex,
                                                PdfImageType type,
                                                int dpiX,
                                                int dpiY)
Saves PDF document page as image,Set PdfImageType and image Dpi

Parameters:
pageIndex - Page index
type - PdfImageType type
dpiX - Pictures X resolution
dpiY - Pictures Y resolution
Returns:
Returns page as Image

deepClone

public java.lang.Object deepClone()
Creates a new object that is a copy of the current instance.

See Also:
The resulting clone must be of the same type as or a compatible type to the original instance.

appendPage

public void appendPage(PdfDocument doc)
append a page to the pdf files


appendPage

public PdfPageBase appendPage()
append a page to the pdf files

Returns:
added page

insertPage

public PdfPageBase insertPage(PdfDocument doc,
                              PdfPageBase page)
Imports a page.

Parameters:
doc - The loaded document.
page - The page.
Returns:
The page in the target document.

insertPage

public PdfPageBase insertPage(PdfDocument doc,
                              int pageIndex)
Imports a page.

Parameters:
doc - The loaded document.
pageIndex - Index of the page.
Returns:
The page in the target document.

insertPage

public PdfPageBase insertPage(PdfDocument doc,
                              int pageIndex,
                              int resultPageIndex)
Imports a page.

Parameters:
doc - The loaded document.
pageIndex - Index of the page.
Returns:
The page in the target document.

insertPageRange

public PdfPageBase insertPageRange(PdfDocument doc,
                                   int startIndex,
                                   int endIndex)
Imports a page range from a loaded document.

Parameters:
doc - The loaded document.
startIndex - The start page index.
endIndex - The end page index.
Returns:
The last created page in the target document.

merge

public static PdfDocumentBase merge(PdfDocumentBase dest,
                                    java.lang.Object... srcs)
Merges the specified source documents and return destination document. The destination document, where the other documents are merged into. If it's null a new document object will be created.

Parameters:
dest - The source documents.
Returns:
The document containing merged documents.

mergeFiles

public static PdfDocumentBase mergeFiles(java.lang.String[] InputFiles)
Merges the PDF documents specified by the paths The array of string paths. A new PDF document containing all merged documents.

Returns:
Document

mergeFiles

public static PdfDocumentBase mergeFiles(java.io.InputStream[] inputStreams)
Merges the PDF documents specified by the Stream.

Parameters:
inputStreams -
Returns:
A new PDF document containing all merged documents.

mergeFiles

public static PdfDocumentBase mergeFiles(java.lang.String firstInputFile,
                                         java.lang.String secInputFile)
Merges the PDF documents specified by the paths.

Parameters:
firstInputFile -
secInputFile -
Returns:
A new PDF document containing all merged documents.

mergeFiles

public static void mergeFiles(java.lang.String[] inputFiles,
                              java.lang.String outputFile)
Merge the PDF documents.

Parameters:
inputFiles - The input pdf documents filename.
outputFile - The output pdf document filename.

mergeFiles

public static void mergeFiles(com.spire.ms.System.IO.Stream[] inputFiles,
                              com.spire.ms.System.IO.Stream outputFile)
Merge the PDF documents.

Parameters:
inputFiles - The input PDF documents stream.
outputFile - The output PDF document stream.

split

public void split(java.lang.String destFilePattern)
Splits a PDF file to many PDF files, each of them consists of one page from the source file.

Parameters:
destFilePattern - Template for destination file names. Each destination file will have 'destFileName{0***}' name, where *** is an optional format string for the number of the page inside of the source document.

split

public void split(java.lang.String destFilePattern,
                  int startNumber)
Splits a PDF file to many PDF files, each of them consists of one page from the source file. Template for destination file names. The number that is use as a start point for the page numbering. Each destination file will have 'destFileName{0***}' name, where *** is an optional format string for the number of the page inside of the source document.


getPrintSettings

public PrintSettings getPrintSettings()
Get print settings.

Returns:
print settings

removeDocumentJavaScript

public boolean removeDocumentJavaScript()
remove document's javaScript

Returns:
if True remove succesfully,else remove the failure or document doesn't have JavaScript

getPrintUsingImageMode

public boolean getPrintUsingImageMode()
get print by using image mode


setPrintUsingImageMode

public void setPrintUsingImageMode(boolean usingImageMode)
set print by using image mode


print

public void print()
Print document


print

public void print(PrintSettings printSettings)
Print document.

Parameters:
printSettings - The print settings.

setExportTextOCRHandler

public static void setExportTextOCRHandler(IOCR iOCR)
when export text,if have image ,will call IOCR and add text to export content.

Parameters:
iOCR -

setExportTextOCRHandler

public static void setExportTextOCRHandler(IOCR iOCR,
                                           boolean enableOCR)
Parameters:
iOCR -
enableOCR -

getExportTextOCRHandler

public static IOCR getExportTextOCRHandler()
Returns:

setExportTextEnableOCR

public static void setExportTextEnableOCR(boolean enableOCR)
Parameters:
enableOCR -

getExportTextEnableOCR

public static boolean getExportTextEnableOCR()

isAutoOptimizingTextColor

public static boolean isAutoOptimizingTextColor()

isAutoOptimizingTextColor

public static void isAutoOptimizingTextColor(boolean autoOptimizingTextColor)

setCustomFontsFolders

public static void setCustomFontsFolders(java.lang.String fontPath)
Set the path to the folder where the custom font is located.

Parameters:
fontPath - the folder path.

clearCustomFontsFolders

public static void clearCustomFontsFolders()
Clear the path of the folder where the custom font is located.