Skip to content

Commit e931e5d

Browse files
authored
PDF/A docs (#35)
1 parent f809ed8 commit e931e5d

11 files changed

Lines changed: 344 additions & 13 deletions

File tree

src/actions.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,22 +186,32 @@ pub enum ActionType {
186186
/// Go to a destination in another document.
187187
RemoteGoTo,
188188
/// Launch an application.
189+
///
190+
/// This action type is forbidden in PDF/A.
189191
Launch,
190192
/// Open a URI.
191193
Uri,
192194
/// Set an annotation's hidden flag. PDF 1.2+.
193195
SubmitForm,
194196
/// Set form fields to their default values. PDF 1.2+.
197+
///
198+
/// This action type is forbidden in PDF/A.
195199
ResetForm,
196200
/// Import form field values from a file. PDF 1.2+.
201+
///
202+
/// This action type is forbidden in PDF/A.
197203
ImportData,
198204
/// Execute a JavaScript action. PDF 1.2+.
199205
///
200206
/// See Adobe's
201207
/// [JavaScript for Acrobat API Reference](https://opensource.adobe.com/dc-acrobat-sdk-docs/acrobatsdk/pdfs/acrobatsdk_jsapiref.pdf)
202208
/// and ISO 21757.
209+
///
210+
/// This action type is forbidden in PDF/A.
203211
JavaScript,
204212
/// A rendition action to control the playing of multimedia content. PDF 1.5+.
213+
///
214+
/// This action type is forbidden in PDF/A.
205215
Rendition,
206216
}
207217

src/annotations.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ impl<'a> Annotation<'a> {
5858
}
5959

6060
/// Write the `/F` attribute.
61+
///
62+
/// Required for all annotations in PDF/A except for `Popup`.
6163
pub fn flags(&mut self, flags: AnnotationFlags) -> &mut Self {
6264
self.pair(Name(b"F"), flags.bits() as i32);
6365
self
@@ -66,6 +68,8 @@ impl<'a> Annotation<'a> {
6668
/// Start writing the `/AP` dictionary to set how the annotation shall
6769
/// be presented visually. If this dictionary contains sub dictionaries,
6870
/// [`Self::appearance_state`] must be set. PDF 1.2+.
71+
///
72+
/// Required for many annotations in PDF/A.
6973
pub fn appearance(&mut self) -> Appearance<'_> {
7074
self.insert(Name(b"AP")).start()
7175
}
@@ -147,12 +151,16 @@ impl<'a> Annotation<'a> {
147151

148152
/// Start writing the `/A` dictionary. Only permissible for the subtypes
149153
/// `Link` and `Widget`.
154+
///
155+
/// Note that this attribute is forbidden in PDF/A.
150156
pub fn action(&mut self) -> Action<'_> {
151157
self.insert(Name(b"A")).start()
152158
}
153159

154160
/// Start writing the `/AA` dictionary. Only permissible for the subtype
155161
/// `Widget`. PDF 1.3+.
162+
///
163+
/// Note that this attribute is forbidden in PDF/A.
156164
pub fn additional_actions(&mut self) -> AdditionalActions<'_> {
157165
self.insert(Name(b"AA")).start()
158166
}
@@ -246,10 +254,15 @@ pub enum AnnotationType {
246254
/// Strike out the text on the page. PDF 1.3+.
247255
StrikeOut,
248256
/// A reference to another file. PDF 1.3+.
257+
///
258+
/// Note that this annotation type is forbidden in PDF/A-1 and restricted in
259+
/// other PDF/A parts.
249260
FileAttachment,
250261
/// A widget annotation. PDF 1.2+.
251262
Widget,
252263
/// A screen annotation. PDF 1.5+.
264+
///
265+
/// Note that this annotation type is forbidden in PDF/A.
253266
Screen,
254267
}
255268

@@ -326,20 +339,32 @@ bitflags::bitflags! {
326339
/// This will hide the annotation if the viewer does not recognize its
327340
/// subtype. Otherwise, it will be rendered as specified in its appearance
328341
/// stream.
342+
///
343+
/// Must not be set for PDF/A.
329344
const INVISIBLE = 1 << 0;
330345
/// This hides the annotation from view and disallows interaction. PDF 1.2+.
346+
///
347+
/// Must not be set for PDF/A.
331348
const HIDDEN = 1 << 1;
332349
/// Print the annotation. If not set, it will be always hidden on print.
333350
/// PDF 1.2+.
351+
///
352+
/// Must be set for PDF/A.
334353
const PRINT = 1 << 2;
335354
/// Do not zoom the annotation appearance if the document is zoomed in.
336355
/// PDF 1.3+.
356+
///
357+
/// Must be set for text annotations in PDF/A.
337358
const NO_ZOOM = 1 << 3;
338359
/// Do not rotate the annotation appearance if the document is zoomed in.
339360
/// PDF 1.3+.
361+
///
362+
/// Must be set for text annotations in PDF/A.
340363
const NO_ROTATE = 1 << 4;
341364
/// Do not view the annotation on screen. It may still show on print.
342365
/// PDF 1.3+.
366+
///
367+
/// Must not be set for PDF/A.
343368
const NO_VIEW = 1 << 5;
344369
/// Do not allow interactions. PDF 1.3+.
345370
const READ_ONLY = 1 << 6;
@@ -348,6 +373,8 @@ bitflags::bitflags! {
348373
const LOCKED = 1 << 7;
349374
/// Invert the interpretation of the `no_view` flag for certain events.
350375
/// PDF 1.5+.
376+
///
377+
/// Must not be set for PDF/A.
351378
const TOGGLE_NO_VIEW = 1 << 8;
352379
/// Do not allow content changes. PDF 1.7+.
353380
const LOCKED_CONTENTS = 1 << 9;

src/color.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,11 @@ impl ColorSpace<'_> {
353353
}
354354

355355
/// Device color spaces.
356+
///
357+
/// Please note that the use of the device color spaces is restricted by several
358+
/// PDF standards such as PDF/A, PDF/X, et cetera. Their appearance will be
359+
/// governed by any applicable [output intent](crate::writers::OutputIntent) and
360+
/// default color spaces.
356361
impl ColorSpace<'_> {
357362
/// Write a `DeviceRGB` color space.
358363
pub fn device_rgb(self) {
@@ -647,7 +652,8 @@ impl DeviceNAttrs<'_> {
647652
/// Start writing the `/Colorants` dictionary. Its keys are the colorant
648653
/// names and its values are separation color space arrays.
649654
///
650-
/// Required if the `/Subtype` attribute is `NChannel`.
655+
/// Required if the `/Subtype` attribute is `NChannel`. Required for spot
656+
/// colors in PDF/A-2, PDF/A-3, and PDF/A-4.
651657
pub fn colorants(&mut self) -> TypedDict<'_, Dict> {
652658
self.dict.insert(Name(b"Colorants")).dict().typed()
653659
}
@@ -1234,7 +1240,7 @@ impl SeparationInfo<'_> {
12341240
/// Writer for an _output intent dictionary_. PDF 1.4+.
12351241
///
12361242
/// This describes the output conditions under which the document may be
1237-
/// rendered.
1243+
/// rendered. Encouraged by PDF/A.
12381244
pub struct OutputIntent<'a> {
12391245
dict: Dict<'a>,
12401246
}
@@ -1289,6 +1295,8 @@ impl OutputIntent<'_> {
12891295
/// Required if `/OutputConditionIdentifier` does not contain a well-known
12901296
/// identifier for the output condition.
12911297
/// Must reference an [ICC profile](IccProfile) stream.
1298+
///
1299+
/// Required for PDF/A. The profile must have the `prtr` or `mntr` tag.
12921300
pub fn dest_output_profile(&mut self, profile: Ref) -> &mut Self {
12931301
self.dict.pair(Name(b"DestOutputProfile"), profile);
12941302
self
@@ -1300,6 +1308,8 @@ pub enum OutputIntentSubtype<'a> {
13001308
/// `GTS_PDFX`
13011309
PDFX,
13021310
/// `GTS_PDFA1`
1311+
///
1312+
/// This is the right value for PDF/A-1 through PDF/A-4.
13031313
PDFA,
13041314
/// `ISO_PDFE1`
13051315
PDFE,

src/content.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,7 @@ impl Content {
876876
}
877877
}
878878

879-
// TODO: Inline images.
879+
// TODO: Inline images. Also check clause 6.1.10 of PDF/A-2 spec.
880880

881881
/// XObjects.
882882
impl Content {
@@ -992,6 +992,8 @@ impl<'a> PropertyList<'a> {
992992
deref!('a, PropertyList<'a> => Dict<'a>, dict);
993993

994994
/// Writer for an _actifact property list dictionary_. PDF 1.4+.
995+
///
996+
/// Required for marking up pagination artifacts in some PDF/A profiles.
995997
pub struct Artifact<'a> {
996998
dict: Dict<'a>,
997999
}
@@ -1342,6 +1344,8 @@ impl<'a> ExtGraphicsState<'a> {
13421344

13431345
/// Write the `OPM` attribute to set the overprint mode for components that
13441346
/// have been zeroed out. PDF 1.3+.
1347+
///
1348+
/// Note that this attribute is restricted by PDF/A.
13451349
pub fn overprint_mode(&mut self, mode: OverprintMode) -> &mut Self {
13461350
self.pair(Name(b"OPM"), mode.to_int());
13471351
self
@@ -1385,6 +1389,8 @@ impl<'a> ExtGraphicsState<'a> {
13851389
}
13861390

13871391
/// Write the `TR` attribute to set the transfer function.
1392+
///
1393+
/// Note that this key is illegal in PDF/A.
13881394
pub fn transfer(&mut self, func: Ref) -> &mut Self {
13891395
self.pair(Name(b"TR"), func);
13901396
self
@@ -1398,6 +1404,8 @@ impl<'a> ExtGraphicsState<'a> {
13981404
}
13991405

14001406
/// Write the `HT` attribute to set the halftone.
1407+
///
1408+
/// Note that this value may be ignored in PDF/A.
14011409
pub fn halftone(&mut self, ht: Ref) -> &mut Self {
14021410
self.pair(Name(b"HT"), ht);
14031411
self
@@ -1411,6 +1419,8 @@ impl<'a> ExtGraphicsState<'a> {
14111419
}
14121420

14131421
/// Write the `FL` attribute to set the flatness tolerance. PDF 1.3+.
1422+
///
1423+
/// Note that this key may be ignored in PDF/A.
14141424
pub fn flatness(&mut self, tolerance: f32) -> &mut Self {
14151425
self.pair(Name(b"FL"), tolerance);
14161426
self
@@ -1429,30 +1439,40 @@ impl<'a> ExtGraphicsState<'a> {
14291439
}
14301440

14311441
/// Write the `BM` attribute to set the blend mode. PDF 1.4+.
1442+
///
1443+
/// Note that this key is restricted in PDF/A-1.
14321444
pub fn blend_mode(&mut self, mode: BlendMode) -> &mut Self {
14331445
self.pair(Name(b"BM"), mode.to_name());
14341446
self
14351447
}
14361448

14371449
/// Start writing the `SMask` attribute. PDF 1.4+.
1450+
///
1451+
/// Note that this key is forbidden in PDF/A-1.
14381452
pub fn soft_mask(&mut self) -> SoftMask<'_> {
14391453
self.insert(Name(b"SMask")).start()
14401454
}
14411455

14421456
/// Write the `SMask` attribute using a name. PDF 1.4+.
1457+
///
1458+
/// Note that this key is forbidden in PDF/A-1.
14431459
pub fn soft_mask_name(&mut self, mask: Name) -> &mut Self {
14441460
self.pair(Name(b"SMask"), mask);
14451461
self
14461462
}
14471463

14481464
/// Write the `CA` attribute to set the stroking alpha constant. PDF 1.4+.
1465+
///
1466+
/// Note that this key is restricted in PDF/A-1.
14491467
pub fn stroking_alpha(&mut self, alpha: f32) -> &mut Self {
14501468
self.pair(Name(b"CA"), alpha);
14511469
self
14521470
}
14531471

14541472
/// Write the `ca` attribute to set the non-stroking alpha constant. PDF
14551473
/// 1.4+.
1474+
///
1475+
/// Note that this key is restricted in PDF/A-1.
14561476
pub fn non_stroking_alpha(&mut self, alpha: f32) -> &mut Self {
14571477
self.pair(Name(b"ca"), alpha);
14581478
self
@@ -1529,6 +1549,9 @@ pub enum OverprintMode {
15291549
/// An overprint operation will only discard the underlying colorant
15301550
/// component (e.g. cyan in CMYK) if the new corresponding colorant is
15311551
/// non-zero.
1552+
///
1553+
/// Note that this value is forbidden by PDF/A for ICCBased color spaces
1554+
/// when overprinting is enabled.
15321555
IgnoreZeroChannel,
15331556
}
15341557

src/files.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ impl<'a> FileSpec<'a> {
5454
///
5555
/// This only sets an embedded file for the `F` attribute corresponding to
5656
/// the [`path`](Self::path) method. You will need to write this dictionary
57-
/// manually if you need to set `UF`.
57+
/// manually if you need to set `UF` which is required in PDF/A-3.
58+
///
59+
/// Note that this key is forbidden in PDF/A-1 and restricted in PDF/A-2 and
60+
/// PDF/A-4.
5861
pub fn embedded_file(&mut self, id: Ref) -> &mut Self {
5962
self.insert(Name(b"EF")).dict().pair(Name(b"F"), id);
6063
self

0 commit comments

Comments
 (0)