コード例 #1
0
ファイル: COSCatalog.java プロジェクト: scireum/jpod
/** The document catalog object of the PDF document. */
public class COSCatalog extends COSBasedObject {
  /** The meta class implementation */
  public static class MetaClass extends COSBasedObject.MetaClass {
    protected MetaClass(Class instanceClass) {
      super(instanceClass);
    }

    @Override
    protected COSBasedObject doCreateCOSBasedObject(COSObject object) {
      return new COSCatalog(object);
    }
  }

  public static final COSName DK_AcroForm = COSName.constant("AcroForm"); // $NON-NLS-1$

  public static final COSName DK_Collection = COSName.constant("Collection"); // $NON-NLS-1$

  public static final COSName DK_Dests = COSName.constant("Dests"); // $NON-NLS-1$

  public static final COSName DK_EmbeddedFiles = COSName.constant("EmbeddedFiles"); // $NON-NLS-1$

  public static final COSName DK_JavaScript = COSName.constant("JavaScript"); // $NON-NLS-1$

  public static final COSName DK_FDF = COSName.constant("FDF"); // $NON-NLS-1$

  public static final COSName DK_Names = COSName.constant("Names"); // $NON-NLS-1$

  public static final COSName DK_MarkInfo = COSName.constant("MarkInfo"); // $NON-NLS-1$

  public static final COSName DK_OpenAction = COSName.constant("OpenAction"); // $NON-NLS-1$

  public static final COSName DK_Outlines = COSName.constant("Outlines"); // $NON-NLS-1$

  public static final COSName DK_Sig = COSName.constant("Sig"); // $NON-NLS-1$

  public static final COSName DK_ViewerPreferences =
      COSName.constant("ViewerPreferences"); // $NON-NLS-1$

  public static final COSName DK_PageLabels = COSName.constant("PageLabels"); // $NON-NLS-1$

  public static final COSName DK_PageLayout = COSName.constant("PageLayout"); // $NON-NLS-1$

  public static final COSName DK_Threads = COSName.constant("Threads"); // $NON-NLS-1$

  public static final COSName DK_AA = COSName.constant("AA"); // $NON-NLS-1$

  public static final COSName DK_AF = COSName.constant("AF"); // $NON-NLS-1$

  public static final COSName DK_Lang = COSName.constant("Lang"); // $NON-NLS-1$

  public static final COSName DK_SpiderInfo = COSName.constant("SpiderInfo"); // $NON-NLS-1$

  public static final COSName DK_StructTreeRoot = COSName.constant("StructTreeRoot"); // $NON-NLS-1$

  public static final COSName DK_Type = COSName.constant("Type"); // $NON-NLS-1$

  public static final COSName DK_Metadata = COSName.constant("Metadata"); // $NON-NLS-1$

  public static final COSName DK_OutputIntents = COSName.constant("OutputIntents"); // $NON-NLS-1$

  public static final COSName DK_PageMode = COSName.constant("PageMode"); // $NON-NLS-1$

  public static final COSName DK_Pages = COSName.constant("Pages"); // $NON-NLS-1$

  public static final COSName DK_PieceInfo = COSName.constant("PieceInfo"); // $NON-NLS-1$

  public static final COSName CN_Type_Catalog = COSName.constant("Catalog"); // $NON-NLS-1$

  public static final COSName DK_URI = COSName.constant("URI"); // $NON-NLS-1$

  public static final COSName DK_Version = COSName.constant("Version"); // $NON-NLS-1$

  public static final COSName DK_OCProperties = COSName.constant("OCProperties"); // $NON-NLS-1$

  /** Well known attribute names */
  public static final COSName CN_Version_1_4 = COSName.constant("1.4"); // $NON-NLS-1$

  /** The meta class instance */
  public static final MetaClass META = new MetaClass(MetaClass.class.getDeclaringClass());

  protected COSCatalog(COSObject object) {
    super(object);
  }

  /**
   * The /AF field in the document catalog.
   *
   * @return The /AF field in the document catalog.
   */
  public COSArray cosGetAF() {
    return cosGetField(DK_AF).asArray();
  }

  /**
   * The /Collection field in the document catalog.
   *
   * @return The /Collection field in the document catalog.
   */
  public COSDictionary cosGetCollection() {
    return cosGetField(DK_Collection).asDictionary();
  }

  /**
   * The /Dests field in the document catalog.
   *
   * @return The /Dests field in the document catalog.
   */
  public COSDictionary cosGetDests() {
    return cosGetField(DK_Dests).asDictionary();
  }

  /**
   * The /FDF field in the document catalog.
   *
   * @return The /FDF field in the document catalog.
   */
  public COSDictionary cosGetFDF() {
    return cosGetField(DK_FDF).asDictionary();
  }

  /**
   * The /Names field in the document catalog.
   *
   * @return The /Names field in the document catalog.
   */
  public COSDictionary cosGetNames() {
    return cosGetField(DK_Names).asDictionary();
  }

  /**
   * The object defining the open action for the document.
   *
   * @return COSDictionary or COSArray or COSNull if no entry defined.
   */
  public COSObject cosGetOpenAction() {
    return cosGetField(DK_OpenAction);
  }

  /**
   * The /Outlines field in the document catalog.
   *
   * @return The /Outlines field in the document catalog.
   */
  public COSDictionary cosGetOutline() {
    return cosGetField(DK_Outlines).asDictionary();
  }

  /**
   * The /Sig field in the document catalog.
   *
   * @return The /Sig field in the document catalog.
   */
  public COSDictionary cosGetSig() {
    return cosGetField(DK_Sig).asDictionary();
  }

  /** Set the /Collection field in the document catalog. */
  public COSDictionary cosSetCollection(COSDictionary pCollection) {
    return cosSetField(DK_Collection, pCollection).asDictionary();
  }

  /** Set the /Dests field in the document catalog. */
  public COSDictionary cosSetDests(COSDictionary pDests) {
    return cosSetField(DK_Dests, pDests).asDictionary();
  }

  /** Set the /FDF field in the document catalog. */
  public COSDictionary cosSetFDF(COSDictionary fdfDict) {
    return cosSetField(DK_FDF, fdfDict).asDictionary();
  }

  /** Set the /Names field in the document catalog. */
  public COSDictionary cosSetNames(COSDictionary pNames) {
    return cosSetField(DK_Names, pNames).asDictionary();
  }

  /** Set the /Outlines field in the document catalog. */
  public COSDictionary cosSetOutline(COSDictionary dict) {
    return cosSetField(DK_Outlines, dict).asDictionary();
  }

  /** Set the /Sig field in the document catalog. */
  public COSDictionary cosSetSig(COSDictionary sigDict) {
    return cosSetField(DK_Sig, sigDict).asDictionary();
  }

  /**
   * The /PageMode field in the document catalog.
   *
   * @return The /PageMode field in the document catalog.
   */
  public String getPageMode() {
    return getFieldString(DK_PageMode, "UseNone"); // $NON-NLS-1$
  }

  /**
   * The /Version field in the document catalog.
   *
   * @return The /Version field in the document catalog.
   */
  public String getVersion() {
    return getFieldString(DK_Version, cosGetDoc().stGetDoc().getVersion());
  }

  /*
   * (non-Javadoc)
   *
   * @see de.intarsys.pdf.cos.COSBasedObject#initializeFromScratch()
   */
  @Override
  protected void initializeFromScratch() {
    super.initializeFromScratch();
    cosSetField(DK_Type, CN_Type_Catalog.copyShallow());
    cosSetField(DK_Version, CN_Version_1_4.copyShallow());
  }

  /** Set the /PageMode field in the document catalog. */
  public void setPageMode(String value) {
    setFieldName(DK_PageMode, value);
  }

  /** Set the /Version field in the document catalog. */
  public void setVersion(String value) {
    setFieldName(DK_Version, value);
  }
}