Daniel Hosseinian | 3881c97a | 2020-03-25 21:41:09 | [diff] [blame] | 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 | |
| 5 | #ifndef PDF_DOCUMENT_METADATA_H_ |
| 6 | #define PDF_DOCUMENT_METADATA_H_ |
| 7 | |
| 8 | #include <string> |
| 9 | |
Daniel Hosseinian | cdcaa4a | 2021-01-14 04:04:57 | [diff] [blame] | 10 | #include "base/time/time.h" |
| 11 | |
Daniel Hosseinian | 3881c97a | 2020-03-25 21:41:09 | [diff] [blame] | 12 | namespace chrome_pdf { |
| 13 | |
Daniel Hosseinian | bc31655 | 2020-03-26 05:57:58 | [diff] [blame] | 14 | // These values are persisted to logs. Entries should not be renumbered and |
| 15 | // numeric values should never be reused. |
| 16 | enum class PdfVersion { |
| 17 | kUnknown = 0, |
| 18 | k1_0 = 1, |
| 19 | k1_1 = 2, |
| 20 | k1_2 = 3, |
| 21 | k1_3 = 4, |
| 22 | k1_4 = 5, |
| 23 | k1_5 = 6, |
| 24 | k1_6 = 7, |
| 25 | k1_7 = 8, |
| 26 | k1_8 = 9, // Not an actual version. Kept for metrics purposes. |
| 27 | k2_0 = 10, |
| 28 | kMaxValue = k2_0 |
| 29 | }; |
| 30 | |
Daniel Hosseinian | 571e1ea | 2021-02-05 02:30:10 | [diff] [blame] | 31 | // These values are persisted to logs. Entries should not be renumbered and |
| 32 | // numeric values should never be reused. |
| 33 | enum class FormType { |
| 34 | kNone = 0, |
| 35 | kAcroForm = 1, |
| 36 | kXFAFull = 2, |
| 37 | kXFAForeground = 3, |
| 38 | kMaxValue = kXFAForeground |
| 39 | }; |
| 40 | |
Daniel Hosseinian | 3881c97a | 2020-03-25 21:41:09 | [diff] [blame] | 41 | // Document properties, including those specified in the document information |
| 42 | // dictionary (see section 14.3.3 "Document Information Dictionary" of the ISO |
Lei Zhang | 448c429 | 2021-10-18 17:29:53 | [diff] [blame] | 43 | // 32000-1:2008 spec). |
Daniel Hosseinian | 3881c97a | 2020-03-25 21:41:09 | [diff] [blame] | 44 | struct DocumentMetadata { |
| 45 | DocumentMetadata(); |
| 46 | DocumentMetadata(const DocumentMetadata&) = delete; |
| 47 | DocumentMetadata& operator=(const DocumentMetadata&) = delete; |
| 48 | ~DocumentMetadata(); |
| 49 | |
Daniel Hosseinian | 571e1ea | 2021-02-05 02:30:10 | [diff] [blame] | 50 | // Version of the document. |
Daniel Hosseinian | bc31655 | 2020-03-26 05:57:58 | [diff] [blame] | 51 | PdfVersion version = PdfVersion::kUnknown; |
| 52 | |
Daniel Hosseinian | 34a0c38 | 2021-02-19 21:25:44 | [diff] [blame] | 53 | // The size of the document in bytes. |
| 54 | size_t size_bytes = 0; |
| 55 | |
Daniel Hosseinian | 571e1ea | 2021-02-05 02:30:10 | [diff] [blame] | 56 | // Number of pages in the document. |
| 57 | size_t page_count = 0; |
| 58 | |
| 59 | // Whether the document is optimized by linearization (see annex F "Linearized |
Lei Zhang | 448c429 | 2021-10-18 17:29:53 | [diff] [blame] | 60 | // PDF" of the ISO 32000-1:2008 spec). |
Daniel Hosseinian | 24b11ad | 2021-01-12 08:59:03 | [diff] [blame] | 61 | bool linearized = false; |
| 62 | |
Daniel Hosseinian | 571e1ea | 2021-02-05 02:30:10 | [diff] [blame] | 63 | // Whether the document contains file attachments (see section 12.5.6.15 "File |
Lei Zhang | 448c429 | 2021-10-18 17:29:53 | [diff] [blame] | 64 | // Attachment Annotations" of the ISO 32000-1:2008 spec). |
Daniel Hosseinian | 571e1ea | 2021-02-05 02:30:10 | [diff] [blame] | 65 | bool has_attachments = false; |
| 66 | |
| 67 | // Whether the document is tagged (see section 14.8 "Tagged PDF" of the ISO |
Lei Zhang | 448c429 | 2021-10-18 17:29:53 | [diff] [blame] | 68 | // 32000-1:2008 spec). |
Daniel Hosseinian | 571e1ea | 2021-02-05 02:30:10 | [diff] [blame] | 69 | bool tagged = false; |
| 70 | |
| 71 | // The type of form contained in the document. |
| 72 | FormType form_type = FormType::kNone; |
| 73 | |
Daniel Hosseinian | 3881c97a | 2020-03-25 21:41:09 | [diff] [blame] | 74 | // The document's title. |
| 75 | std::string title; |
| 76 | |
| 77 | // The name of the document's creator. |
| 78 | std::string author; |
| 79 | |
| 80 | // The document's subject. |
| 81 | std::string subject; |
| 82 | |
Daniel Hosseinian | fe84610 | 2021-01-12 20:14:28 | [diff] [blame] | 83 | // The document's keywords. |
| 84 | std::string keywords; |
| 85 | |
Daniel Hosseinian | 3881c97a | 2020-03-25 21:41:09 | [diff] [blame] | 86 | // The name of the application that created the original document. |
| 87 | std::string creator; |
| 88 | |
| 89 | // If the document's format was not originally PDF, the name of the |
| 90 | // application that converted the document to PDF. |
| 91 | std::string producer; |
Daniel Hosseinian | cdcaa4a | 2021-01-14 04:04:57 | [diff] [blame] | 92 | |
| 93 | // The date and time the document was created. |
| 94 | base::Time creation_date; |
| 95 | |
Daniel Hosseinian | 571e1ea | 2021-02-05 02:30:10 | [diff] [blame] | 96 | // The date and time the document was most recently modified. |
Daniel Hosseinian | cdcaa4a | 2021-01-14 04:04:57 | [diff] [blame] | 97 | base::Time mod_date; |
Daniel Hosseinian | 3881c97a | 2020-03-25 21:41:09 | [diff] [blame] | 98 | }; |
| 99 | |
| 100 | } // namespace chrome_pdf |
| 101 | |
| 102 | #endif // PDF_DOCUMENT_METADATA_H_ |