ImageGear Java PDF
Open a PDF Document

To open and load a PDF file use the openDocument method of the Document class:

 
Copy Code
void openDocument(string fileName);

Use the openDocument method to open and load a PDF file. The openDocument method has one parameter:

The following is an illustration of how to open and close a PDF file:

 
Copy Code
import com.accusoft.imagegearpdf.*;

class PdfDemo
{
        private PDF pdf;
        private Document document;
        
        // Open PDF document from filename.
        public boolean openDocument(String filename)
        {
                try
                {
                        // Create a new instance of PDF document.
                        document = pdf.createDocument();
                        
                        // Try to open PDF document from file.
                        document.openDocument(filename);
                        return true;
                }
                catch (Throwable ex)
                {
                        // Failed to open PDF file.
                        System.err.println("Exception: " + ex.toString());
                        closeDocument();
                        return false;
                }
          }
          
          // Close PDF document.
          public void closeDocument()
          {
                if (document != null)
                {
                        // Close PDF document.
                        document.close();
                        document = null;
                }
          }
}

See Also

 

 


©2016. Accusoft Corporation. All Rights Reserved.

Send Feedback