[]
        
首页
开发者学堂
文档
论坛
市场
生态机会
活动
立即试用
(Showing Draft Content)

DocumentProperties

Class DocumentProperties

java.lang.Object
com.grapecity.documents.excel.DocumentProperties

public class DocumentProperties extends Object
表示 PDF 文档的文档属性。

使用此类可以定义 PDF 元数据,例如生成文档时要使用的标题、作者、主题、关键字、创建者、制作者、创建日期、修改日期和 PDF 版本。将实例分配给 PdfSaveOptions.setDocumentProperties(DocumentProperties) 可在 PDF 导出期间应用这些属性。


 Workbook workbook = new Workbook();
 IWorksheet worksheet = workbook.getWorksheets().get(0);
 worksheet.getRange("A1").setValue("Quarterly Sales Summary");
 DocumentProperties documentProperties = new DocumentProperties();
 documentProperties.setTitle("Quarterly Sales Summary");
 documentProperties.setAuthor("Author");
 documentProperties.setPdfVersion(1.5f);
 PdfSaveOptions options = new PdfSaveOptions();
 options.setDocumentProperties(documentProperties);
 String fileName = "DocumentProperties.pdf";
 workbook.save(fileName, options);
 
  • Constructor Details

    • DocumentProperties

      public DocumentProperties()
  • Method Details

    • getPdfVersion

      public float getPdfVersion()
      获取生成的文档的 PDF 版本。

      此值指定生成文档时使用的 PDF 版本。

      
       DocumentProperties properties = new DocumentProperties();
       properties.setPdfVersion(1.4f);
       float pdfVersion = properties.getPdfVersion();
       
      Returns:
      生成的文档的 PDF 版本。
    • setPdfVersion

      public void setPdfVersion(float value)
      设置生成的文档的 PDF 版本。

      此值指定生成文档时使用的 PDF 版本。

      
       DocumentProperties properties = new DocumentProperties();
       properties.setPdfVersion(1.4f);
       
      Parameters:
      value - 生成的文档的 PDF 版本。
    • getTitle

      public String getTitle()
      获取文档的标题。

      此属性指定存储在文档属性中的标题。

      
       DocumentProperties properties = new DocumentProperties();
       properties.setTitle("Quarterly Sales Summary");
       String title = properties.getTitle();
       
      Returns:
      文档的标题。
    • setTitle

      public void setTitle(String value)
      设置文档的标题。

      此属性指定存储在文档属性中的标题。

      
       DocumentProperties properties = new DocumentProperties();
       properties.setTitle("Quarterly Sales Summary");
       
      Parameters:
      value - 文档的标题。
    • getAuthor

      public String getAuthor()
      获取创建文档的人员姓名。
      
       DocumentProperties properties = new DocumentProperties();
       properties.setAuthor("Author");
       String author = properties.getAuthor();
       
      Returns:
      创建文档的人员姓名。如果未设置作者,则返回 null。
    • setAuthor

      public void setAuthor(String value)
      设置创建文档的人员姓名。
      
       DocumentProperties properties = new DocumentProperties();
       properties.setAuthor("Author");
       
      Parameters:
      value - 创建文档的人员姓名。如果未设置作者,则设置为 null。
    • getSubject

      public String getSubject()
      获取文档的主题。

      使用此属性可获取与文档关联的主题元数据。

      
       DocumentProperties properties = new DocumentProperties();
       properties.setSubject("Quarterly Sales Summary");
       String subject = properties.getSubject();
       
      Returns:
      文档的主题。
    • setSubject

      public void setSubject(String value)
      设置文档的主题。

      使用此属性可设置与文档关联的主题元数据。

      
       DocumentProperties properties = new DocumentProperties();
       properties.setSubject("Quarterly Sales Summary");
       
      Parameters:
      value - 文档的主题。
    • getKeywords

      public String getKeywords()
      获取与文档关联的关键字。

      返回的字符串包含以逗号分隔的文档关键字列表。

      
       DocumentProperties properties = new DocumentProperties();
       properties.setKeywords("report, sales, quarterly");
       String keywords = properties.getKeywords();
       
      Returns:
      与文档关联的以逗号分隔的关键字;如果未设置关键字,则为 null。
    • setKeywords

      public void setKeywords(String value)
      设置与文档关联的关键字。

      返回的字符串包含以逗号分隔的文档关键字列表。

      
       DocumentProperties properties = new DocumentProperties();
       properties.setKeywords("report, sales, quarterly");
       
      Parameters:
      value - 与文档关联的以逗号分隔的关键字;如果未设置关键字,则为 null。
    • getCreator

      public String getCreator()
      获取创建原始文档的应用程序名称。

      此值表示原始文档或应用程序创建者。它不同于 getProducer(),后者标识生成 PDF 文档的应用程序或库。

      
       DocumentProperties properties = new DocumentProperties();
       properties.setCreator("Report Designer");
       String creator = properties.getCreator();
       
      Returns:
      创建原始文档的应用程序名称;如果尚未设置,则为 null。
    • setCreator

      public void setCreator(String value)
      设置创建原始文档的应用程序的名称。

      此值表示原始文档或应用程序创建者。它不同于 getProducer(),后者标识生成 PDF 文档的应用程序或库。

      
       DocumentProperties properties = new DocumentProperties();
       properties.setCreator("Report Designer");
       
      Parameters:
      value - 创建原始文档的应用程序的名称;如果未设置,则为 null。
    • getProducer

      public String getProducer()
      获取生成 PDF 文档的应用程序或库的名称。

      此值表示 PDF 生成器或导出器,并且不同于 getCreator(),后者标识原始文档或应用程序创建者。

      
       DocumentProperties properties = new DocumentProperties();
       properties.setProducer("PDF Exporter");
       String producer = properties.getProducer();
       
      Returns:
      生成 PDF 文档的应用程序或库的名称。如果未设置生成器,则返回 null。
    • setProducer

      public void setProducer(String value)
      设置生成 PDF 文档的应用程序或库的名称。

      此值表示 PDF 生成器或导出器,并且不同于 getCreator(),后者标识原始文档或应用程序创建者。

      
       DocumentProperties properties = new DocumentProperties();
       properties.setProducer("PDF Exporter");
       
      Parameters:
      value - 生成 PDF 文档的应用程序或库的名称。如果未设置制作者,则设置为 null。
    • getCreationDate

      public Calendar getCreationDate()
      获取文档的创建日期和时间。

      使用此方法可以检索先前通过 setCreationDate(Calendar) 为 PDF 文档属性分配的值。

      
       DocumentProperties properties = new DocumentProperties();
       properties.setCreationDate(new GregorianCalendar(2019, 5, 24));
       Calendar creationDate = properties.getCreationDate();
       
      Returns:
      文档的创建日期和时间;如果未设置创建日期,则为 null。
    • setCreationDate

      public void setCreationDate(Calendar value)
      设置文档创建的日期和时间。

      使用此方法可以分配存储在文档属性中的创建时间戳。

      
       DocumentProperties properties = new DocumentProperties();
       Calendar creationDate = new GregorianCalendar(2024, 2, 15, 10, 30, 0);
       properties.setCreationDate(creationDate);
       
      Parameters:
      value - 要设置的创建日期和时间。此值可以为 null。
    • getModifyDate

      public Calendar getModifyDate()
      获取文档最近一次修改的日期和时间。

      使用此方法可以检索存储在此 DocumentProperties 实例中的修改时间戳。

      
       DocumentProperties properties = new DocumentProperties();
       properties.setModifyDate(new GregorianCalendar(2020, 5, 24));
       Calendar modifyDate = properties.getModifyDate();
       
      Returns:
      文档最近一次修改的日期和时间;如果未设置修改日期,则为 null。
    • setModifyDate

      public void setModifyDate(Calendar value)
      设置文档最近一次修改的日期和时间。

      使用此属性可在 PDF 文档属性中存储修改时间戳。传递 null 会清除存储的修改日期。

      
       DocumentProperties properties = new DocumentProperties();
       properties.setCreationDate(new GregorianCalendar(2019, 5, 24));
       properties.setModifyDate(new GregorianCalendar(2020, 5, 24));
       
      Parameters:
      value - 要设置的修改日期和时间。null 会清除存储的修改日期。
    • toString

      public String toString()
      Returns a string that describes the current document properties.
      Overrides:
      toString in class Object
      Returns:
      A string that contains the PDF version and metadata values stored in this instance.