lv.eparaksts.pdf

## Class PdfDocument

- java.lang.Object
- - lv.eparaksts.pdf.PdfDocument

- All Implemented Interfaces:
    Validatable

      public class PdfDocument
      extends Object
      implements Validatable

  A `PdfDocument` represents interface for PDF document format.
  See Also:
    `PdfDocument(InputStream)`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `PdfDocument(InputStream inputStream)` Creates PDF document from `InputStream`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `PdfBasicSignature` | `addSignature()` Adds a new signature to the document with default properties.
    `PdfBasicSignature` | `addSignature(Map<String,String> map)` Adds a new signature to the document with specified properties.
    `void` | `close()` Cleans all temporary files and frees resources.
    `int` | `getPageCount()` Returns the number of pages in this PDF document.
    `List<PdfPageProperties>` | `getPageProperties()` Returns the properties of all of the pages in this PDF document.
    `PdfPageProperties` | `getPageProperties(int index)` Returns the properties of the given page in this PDF document.
    `PdfDocumentProperties` | `getProperties()` Returns the properties of this PDF document.
    `int` | `getSignatureCount()` Returns count of signatures of the document.
    `List<PdfSignature>` | `getSignatures()` Returns the signatures in this PDF document.
    `float` | `getVersion()` Returns the PDF specification version this document conforms to.
    `File` | `getWorkingFile()` Returns a `File` for reading working data from this `PdfDocument`.
    `void` | `removeSignature(PdfSignature signature)` Removes last signature from the document.
    `ValidationResult` | `validate()` Validates this object.
    `ValidationResult` | `validate(ValidationPolicy validationPolicy)`
    `void` | `writeTo(File file)` Writes the document content to the given output file.
    `void` | `writeTo(OutputStream out)` Writes the document content to the given output stream.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### PdfDocument

          public PdfDocument(InputStream inputStream)
                      throws PdfException

      Creates PDF document from `InputStream`
      Parameters:
        `inputStream` - PDF document
      Throws:
        `PdfException`

  - ### Method Detail

    - #### getVersion

          public float getVersion()

      Returns the PDF specification version this document conforms to.
      Returns:
        the PDF version (e.g. 1.4f).

    - #### getProperties

          public PdfDocumentProperties getProperties()

      Returns the properties of this PDF document.
      Returns:
        the properties of this PDF document.

    - #### getPageCount

          public int getPageCount()

      Returns the number of pages in this PDF document.
      Returns:
        number of pages.

    - #### getPageProperties

          public List<PdfPageProperties> getPageProperties()
                                                    throws PdfException

      Returns the properties of all of the pages in this PDF document.
      Returns:
        the properties of all of the pages.
      Throws:
        `PdfException`

    - #### getPageProperties

          public PdfPageProperties getPageProperties(int index)
                                              throws PdfException

      Returns the properties of the given page in this PDF document.
      Returns:
        the properties of the page.
      Throws:
        `PdfException`

    - #### getSignatureCount

          public int getSignatureCount()
                                throws PdfException

      Returns count of signatures of the document.
      Returns:
        count of signatures.
      Throws:
        `PdfException`

    - #### getSignatures

          public List<PdfSignature> getSignatures()
                                           throws PdfException

      Returns the signatures in this PDF document.
      Returns:
        the signatures.
      Throws:
        `PdfException`

    - #### addSignature

          public PdfBasicSignature addSignature()
                                         throws PdfException

      Adds a new signature to the document with default properties.
      Returns:
        BASIC profile signature interface.
      Throws:
        `PdfException`

    - #### addSignature

          public PdfBasicSignature addSignature(Map<String,String> map)
                                         throws PdfException

      Adds a new signature to the document with specified properties. Properties can be used to override the default configuration of the new signature.
      Parameters:
        `map` - properties.
      Returns:
        BASIC profile signature interface.
      Throws:
        `PdfException`

    - #### removeSignature

          public void removeSignature(PdfSignature signature)
                               throws PdfException

      Removes last signature from the document.
      Throws:
        `PdfException`

    - #### writeTo

          public void writeTo(OutputStream out)
                       throws PdfException

      Writes the document content to the given output stream.
      Parameters:
        `out` - output stream.
      Throws:
        `PdfException`

    - #### writeTo

          public void writeTo(File file)
                       throws PdfException

      Writes the document content to the given output file.
      Parameters:
        `file` - output file.
      Throws:
        `PdfException`

    - #### close

          public void close()
                     throws PdfException

      Cleans all temporary files and frees resources.
      Throws:
        `PdfException`

    - #### validate

          public ValidationResult validate()

      Description copied from interface: `Validatable`
      Validates this object.
      Specified by:
        `validate` in interface `Validatable`
      Returns:
        the validation result.

    - #### validate

          public ValidationResult validate(ValidationPolicy validationPolicy)

      Specified by:
        `validate` in interface `Validatable`

    - #### getWorkingFile

          public File getWorkingFile()

      Returns a `File` for reading working data from this `PdfDocument`.

      NOTE: Do not modify the underlying file, as it will corrupt the PDF integrity!

      Returns:
        file.

Copyright VAS Latvijas Valsts radio un televizijas centrs / Developed by SIA EUSO