blob: 615912bd7333329d5056dffdb69b10d735a62934 [file] [log] [blame]
Daniel Hosseinian3881c97a2020-03-25 21:41:091// 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 Hosseiniancdcaa4a2021-01-14 04:04:5710#include "base/time/time.h"
11
Daniel Hosseinian3881c97a2020-03-25 21:41:0912namespace chrome_pdf {
13
Daniel Hosseinianbc316552020-03-26 05:57:5814// These values are persisted to logs. Entries should not be renumbered and
15// numeric values should never be reused.
16enum 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 Hosseinian571e1ea2021-02-05 02:30:1031// These values are persisted to logs. Entries should not be renumbered and
32// numeric values should never be reused.
33enum class FormType {
34 kNone = 0,
35 kAcroForm = 1,
36 kXFAFull = 2,
37 kXFAForeground = 3,
38 kMaxValue = kXFAForeground
39};
40
Daniel Hosseinian3881c97a2020-03-25 21:41:0941// Document properties, including those specified in the document information
42// dictionary (see section 14.3.3 "Document Information Dictionary" of the ISO
Lei Zhang448c4292021-10-18 17:29:5343// 32000-1:2008 spec).
Daniel Hosseinian3881c97a2020-03-25 21:41:0944struct DocumentMetadata {
45 DocumentMetadata();
46 DocumentMetadata(const DocumentMetadata&) = delete;
47 DocumentMetadata& operator=(const DocumentMetadata&) = delete;
48 ~DocumentMetadata();
49
Daniel Hosseinian571e1ea2021-02-05 02:30:1050 // Version of the document.
Daniel Hosseinianbc316552020-03-26 05:57:5851 PdfVersion version = PdfVersion::kUnknown;
52
Daniel Hosseinian34a0c382021-02-19 21:25:4453 // The size of the document in bytes.
54 size_t size_bytes = 0;
55
Daniel Hosseinian571e1ea2021-02-05 02:30:1056 // 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 Zhang448c4292021-10-18 17:29:5360 // PDF" of the ISO 32000-1:2008 spec).
Daniel Hosseinian24b11ad2021-01-12 08:59:0361 bool linearized = false;
62
Daniel Hosseinian571e1ea2021-02-05 02:30:1063 // Whether the document contains file attachments (see section 12.5.6.15 "File
Lei Zhang448c4292021-10-18 17:29:5364 // Attachment Annotations" of the ISO 32000-1:2008 spec).
Daniel Hosseinian571e1ea2021-02-05 02:30:1065 bool has_attachments = false;
66
67 // Whether the document is tagged (see section 14.8 "Tagged PDF" of the ISO
Lei Zhang448c4292021-10-18 17:29:5368 // 32000-1:2008 spec).
Daniel Hosseinian571e1ea2021-02-05 02:30:1069 bool tagged = false;
70
71 // The type of form contained in the document.
72 FormType form_type = FormType::kNone;
73
Daniel Hosseinian3881c97a2020-03-25 21:41:0974 // 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 Hosseinianfe846102021-01-12 20:14:2883 // The document's keywords.
84 std::string keywords;
85
Daniel Hosseinian3881c97a2020-03-25 21:41:0986 // 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 Hosseiniancdcaa4a2021-01-14 04:04:5792
93 // The date and time the document was created.
94 base::Time creation_date;
95
Daniel Hosseinian571e1ea2021-02-05 02:30:1096 // The date and time the document was most recently modified.
Daniel Hosseiniancdcaa4a2021-01-14 04:04:5797 base::Time mod_date;
Daniel Hosseinian3881c97a2020-03-25 21:41:0998};
99
100} // namespace chrome_pdf
101
102#endif // PDF_DOCUMENT_METADATA_H_