document_metadata.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. // Copyright 2020 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef PDF_DOCUMENT_METADATA_H_
  5. #define PDF_DOCUMENT_METADATA_H_
  6. #include <string>
  7. #include "base/time/time.h"
  8. namespace chrome_pdf {
  9. // These values are persisted to logs. Entries should not be renumbered and
  10. // numeric values should never be reused.
  11. enum class PdfVersion {
  12. kUnknown = 0,
  13. k1_0 = 1,
  14. k1_1 = 2,
  15. k1_2 = 3,
  16. k1_3 = 4,
  17. k1_4 = 5,
  18. k1_5 = 6,
  19. k1_6 = 7,
  20. k1_7 = 8,
  21. k1_8 = 9, // Not an actual version. Kept for metrics purposes.
  22. k2_0 = 10,
  23. kMaxValue = k2_0
  24. };
  25. // These values are persisted to logs. Entries should not be renumbered and
  26. // numeric values should never be reused.
  27. enum class FormType {
  28. kNone = 0,
  29. kAcroForm = 1,
  30. kXFAFull = 2,
  31. kXFAForeground = 3,
  32. kMaxValue = kXFAForeground
  33. };
  34. // Document properties, including those specified in the document information
  35. // dictionary (see section 14.3.3 "Document Information Dictionary" of the ISO
  36. // 32000-1:2008 spec).
  37. struct DocumentMetadata {
  38. DocumentMetadata();
  39. DocumentMetadata(const DocumentMetadata&) = delete;
  40. DocumentMetadata& operator=(const DocumentMetadata&) = delete;
  41. ~DocumentMetadata();
  42. // Version of the document.
  43. PdfVersion version = PdfVersion::kUnknown;
  44. // The size of the document in bytes.
  45. size_t size_bytes = 0;
  46. // Number of pages in the document.
  47. size_t page_count = 0;
  48. // Whether the document is optimized by linearization (see annex F "Linearized
  49. // PDF" of the ISO 32000-1:2008 spec).
  50. bool linearized = false;
  51. // Whether the document contains file attachments (see section 12.5.6.15 "File
  52. // Attachment Annotations" of the ISO 32000-1:2008 spec).
  53. bool has_attachments = false;
  54. // The type of form contained in the document.
  55. FormType form_type = FormType::kNone;
  56. // The document's title.
  57. std::string title;
  58. // The name of the document's creator.
  59. std::string author;
  60. // The document's subject.
  61. std::string subject;
  62. // The document's keywords.
  63. std::string keywords;
  64. // The name of the application that created the original document.
  65. std::string creator;
  66. // If the document's format was not originally PDF, the name of the
  67. // application that converted the document to PDF.
  68. std::string producer;
  69. // The date and time the document was created.
  70. base::Time creation_date;
  71. // The date and time the document was most recently modified.
  72. base::Time mod_date;
  73. };
  74. } // namespace chrome_pdf
  75. #endif // PDF_DOCUMENT_METADATA_H_