origami-docspring 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +70 -0
  3. data/COPYING.LESSER +165 -0
  4. data/README.md +115 -0
  5. data/bin/config/pdfcop.conf.yml +236 -0
  6. data/bin/pdf2pdfa +87 -0
  7. data/bin/pdf2ruby +333 -0
  8. data/bin/pdfcop +474 -0
  9. data/bin/pdfdecompress +97 -0
  10. data/bin/pdfdecrypt +91 -0
  11. data/bin/pdfencrypt +113 -0
  12. data/bin/pdfexplode +223 -0
  13. data/bin/pdfextract +277 -0
  14. data/bin/pdfmetadata +144 -0
  15. data/bin/pdfsh +12 -0
  16. data/bin/shell/console.rb +128 -0
  17. data/bin/shell/hexdump.rb +59 -0
  18. data/bin/shell/irbrc +69 -0
  19. data/examples/README.md +34 -0
  20. data/examples/attachments/attachment.rb +38 -0
  21. data/examples/attachments/nested_document.rb +51 -0
  22. data/examples/encryption/encryption.rb +28 -0
  23. data/examples/events/events.rb +72 -0
  24. data/examples/flash/flash.rb +37 -0
  25. data/examples/flash/helloworld.swf +0 -0
  26. data/examples/forms/javascript.rb +54 -0
  27. data/examples/forms/xfa.rb +115 -0
  28. data/examples/javascript/hello_world.rb +22 -0
  29. data/examples/javascript/js_emulation.rb +54 -0
  30. data/examples/loop/goto.rb +32 -0
  31. data/examples/loop/named.rb +33 -0
  32. data/examples/signature/signature.rb +65 -0
  33. data/examples/uri/javascript.rb +56 -0
  34. data/examples/uri/open-uri.rb +21 -0
  35. data/examples/uri/submitform.rb +47 -0
  36. data/lib/origami/3d.rb +364 -0
  37. data/lib/origami/acroform.rb +321 -0
  38. data/lib/origami/actions.rb +318 -0
  39. data/lib/origami/annotations.rb +711 -0
  40. data/lib/origami/array.rb +242 -0
  41. data/lib/origami/boolean.rb +90 -0
  42. data/lib/origami/catalog.rb +418 -0
  43. data/lib/origami/collections.rb +144 -0
  44. data/lib/origami/compound.rb +161 -0
  45. data/lib/origami/destinations.rb +252 -0
  46. data/lib/origami/dictionary.rb +192 -0
  47. data/lib/origami/encryption.rb +1085 -0
  48. data/lib/origami/extensions/fdf.rb +347 -0
  49. data/lib/origami/extensions/ppklite.rb +422 -0
  50. data/lib/origami/filespec.rb +197 -0
  51. data/lib/origami/filters/ascii.rb +211 -0
  52. data/lib/origami/filters/ccitt/tables.rb +267 -0
  53. data/lib/origami/filters/ccitt.rb +357 -0
  54. data/lib/origami/filters/crypt.rb +38 -0
  55. data/lib/origami/filters/dct.rb +54 -0
  56. data/lib/origami/filters/flate.rb +69 -0
  57. data/lib/origami/filters/jbig2.rb +57 -0
  58. data/lib/origami/filters/jpx.rb +47 -0
  59. data/lib/origami/filters/lzw.rb +170 -0
  60. data/lib/origami/filters/predictors.rb +292 -0
  61. data/lib/origami/filters/runlength.rb +129 -0
  62. data/lib/origami/filters.rb +364 -0
  63. data/lib/origami/font.rb +196 -0
  64. data/lib/origami/functions.rb +79 -0
  65. data/lib/origami/graphics/colors.rb +230 -0
  66. data/lib/origami/graphics/instruction.rb +98 -0
  67. data/lib/origami/graphics/path.rb +182 -0
  68. data/lib/origami/graphics/patterns.rb +174 -0
  69. data/lib/origami/graphics/render.rb +62 -0
  70. data/lib/origami/graphics/state.rb +149 -0
  71. data/lib/origami/graphics/text.rb +225 -0
  72. data/lib/origami/graphics/xobject.rb +918 -0
  73. data/lib/origami/graphics.rb +38 -0
  74. data/lib/origami/header.rb +75 -0
  75. data/lib/origami/javascript.rb +713 -0
  76. data/lib/origami/linearization.rb +330 -0
  77. data/lib/origami/metadata.rb +172 -0
  78. data/lib/origami/name.rb +135 -0
  79. data/lib/origami/null.rb +65 -0
  80. data/lib/origami/numeric.rb +181 -0
  81. data/lib/origami/obfuscation.rb +245 -0
  82. data/lib/origami/object.rb +760 -0
  83. data/lib/origami/optionalcontent.rb +183 -0
  84. data/lib/origami/outline.rb +54 -0
  85. data/lib/origami/outputintents.rb +85 -0
  86. data/lib/origami/page.rb +722 -0
  87. data/lib/origami/parser.rb +269 -0
  88. data/lib/origami/parsers/fdf.rb +56 -0
  89. data/lib/origami/parsers/pdf/lazy.rb +176 -0
  90. data/lib/origami/parsers/pdf/linear.rb +122 -0
  91. data/lib/origami/parsers/pdf.rb +118 -0
  92. data/lib/origami/parsers/ppklite.rb +57 -0
  93. data/lib/origami/pdf.rb +1108 -0
  94. data/lib/origami/reference.rb +134 -0
  95. data/lib/origami/signature.rb +702 -0
  96. data/lib/origami/stream.rb +705 -0
  97. data/lib/origami/string.rb +444 -0
  98. data/lib/origami/template/patterns.rb +56 -0
  99. data/lib/origami/template/widgets.rb +151 -0
  100. data/lib/origami/trailer.rb +190 -0
  101. data/lib/origami/tree.rb +62 -0
  102. data/lib/origami/version.rb +23 -0
  103. data/lib/origami/webcapture.rb +100 -0
  104. data/lib/origami/xfa/config.rb +453 -0
  105. data/lib/origami/xfa/connectionset.rb +146 -0
  106. data/lib/origami/xfa/datasets.rb +49 -0
  107. data/lib/origami/xfa/localeset.rb +42 -0
  108. data/lib/origami/xfa/package.rb +59 -0
  109. data/lib/origami/xfa/pdf.rb +73 -0
  110. data/lib/origami/xfa/signature.rb +42 -0
  111. data/lib/origami/xfa/sourceset.rb +43 -0
  112. data/lib/origami/xfa/stylesheet.rb +44 -0
  113. data/lib/origami/xfa/template.rb +1691 -0
  114. data/lib/origami/xfa/xdc.rb +42 -0
  115. data/lib/origami/xfa/xfa.rb +146 -0
  116. data/lib/origami/xfa/xfdf.rb +43 -0
  117. data/lib/origami/xfa/xmpmeta.rb +43 -0
  118. data/lib/origami/xfa.rb +62 -0
  119. data/lib/origami/xreftable.rb +557 -0
  120. data/lib/origami.rb +47 -0
  121. data/test/dataset/calc.pdf +85 -0
  122. data/test/dataset/crypto.pdf +82 -0
  123. data/test/dataset/empty.pdf +49 -0
  124. data/test/test_actions.rb +27 -0
  125. data/test/test_annotations.rb +68 -0
  126. data/test/test_forms.rb +30 -0
  127. data/test/test_native_types.rb +83 -0
  128. data/test/test_object_tree.rb +33 -0
  129. data/test/test_pages.rb +60 -0
  130. data/test/test_pdf.rb +20 -0
  131. data/test/test_pdf_attachment.rb +34 -0
  132. data/test/test_pdf_create.rb +24 -0
  133. data/test/test_pdf_encrypt.rb +95 -0
  134. data/test/test_pdf_parse.rb +134 -0
  135. data/test/test_pdf_parse_lazy.rb +69 -0
  136. data/test/test_pdf_sign.rb +97 -0
  137. data/test/test_streams.rb +184 -0
  138. data/test/test_xrefs.rb +67 -0
  139. metadata +243 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: bd7d27578057971751df78c314604a899a3151bf8f0aa025b064817a97967ca5
4
+ data.tar.gz: e4520d83ea3373cdb6057cf44bbb77b17730bf357866e08f582ff5f741347e40
5
+ SHA512:
6
+ metadata.gz: 7242805e8acc6dd14a17eb738b52d89b485667086d77f93ec9245cd93c14c2a3812a90c83c30ef5ec95dfe1b5abcfa24a5083c3489ac9ba9897be451769860f1
7
+ data.tar.gz: b7b6a4301a9e00bd23d28886bde075849fbff44766ad4d9b2a7fb534b63040e7a6e0da2111ad73b098b4e104716a1d08f22c2b9bcc02ff0c41abf465ec74f367
data/CHANGELOG.md ADDED
@@ -0,0 +1,70 @@
1
+ 2.1.0
2
+ -----
3
+ * Moved pdfwalker to a separate gem
4
+
5
+ 2.0.0
6
+ -----
7
+ * Code reindented to 4 spaces.
8
+ * Code base refactored for Ruby 2.x (requires at least 2.1).
9
+ * Support for Crypt filters.
10
+ * The parser now supports a lazy mode.
11
+ * Fixed all Ruby warnings.
12
+ * Better type propagation.
13
+ * Use namespace refinements to protect the standard namespace.
14
+ * PDF#each_* methods can return Enumerators.
15
+ * Use the colorize gem for console output.
16
+ * Faster loading of objects in pdfwalker.
17
+ * Better handling of cross-references in pdfwalker.
18
+ * Many bug fixes.
19
+
20
+ 1.2.0 (2011-09-29)
21
+ -----
22
+ * Support for JavaScript emulation based on V8 (requires therubyracer gem).
23
+
24
+ 1.1.0 (2011-09-14)
25
+ -----
26
+ * Support for standard security handler revision 6.
27
+
28
+ 1.0.2 (2011-05-25)
29
+ -----
30
+ * Added a Rakefile to run unit tests, build rdoc and build gem.
31
+ * Added a Ruby shell for Origami.
32
+ * Added a bin folder, with some useful command-line tools.
33
+ * Can now be installed as a RubyGem.
34
+ * AESV3 support (AES256 encryption/decryption).
35
+ * Encryption/decryption can be achieved with or without openssl.
36
+ * Changed PDF#encrypt prototype.
37
+ * Support for G3 unidimensional encoding/decoding of CCITTFax filter.
38
+ * Support for TIFF stream predictor functions.
39
+ * Name trees lookup methods.
40
+ * Renamed PDF#saveas to PDF#save.
41
+ * Lot of bug fixes.
42
+
43
+ beta3 (2010-08-26)
44
+ -----
45
+ * Faster decryption process.
46
+ * Properly parse objects with no endobj token.
47
+ * Image viewer in pdfwalker.
48
+
49
+ beta2 (2010-04-01)
50
+ -----
51
+ * Support for Flash/RichMedia integration.
52
+ * XFA forms.
53
+ * Search feature for pdfwalker.
54
+ * Fixed various bugs.
55
+
56
+ beta1 (2009-09-15)
57
+ -----
58
+ * Basic support for graphics drawing as lines, colors, shading, shapes...
59
+ * Support for numerical functions.
60
+ * Support for date strings.
61
+ * Added PDF#insert_page(index, page) method.
62
+ * Added a forms widgets template.
63
+ * Ability to delinearize documents.
64
+ * Fixed various bugs.
65
+
66
+ beta0 (2009-07-06)
67
+ -----
68
+ * Support for XRef streams.
69
+ * Support for Object streams creation.
70
+ * Support for PNG stream predictor functions.
data/COPYING.LESSER ADDED
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
data/README.md ADDED
@@ -0,0 +1,115 @@
1
+ Origami
2
+ =====
3
+ [![Gem Version](https://badge.fury.io/rb/origami.svg)](https://rubygems.org/gems/origami)
4
+ [![Downloads](https://img.shields.io/gem/dt/origami.svg)](https://rubygems.org/gems/origami)
5
+ [![Build Status](https://secure.travis-ci.org/gdelugre/origami.svg?branch=master)](https://travis-ci.org/gdelugre/origami)
6
+ [![License: LGPL v3](https://img.shields.io/badge/License-LGPL%20v3-blue.svg)](https://www.gnu.org/licenses/lgpl-3.0)
7
+
8
+ Overview
9
+ --------
10
+
11
+ Origami is a framework written in pure Ruby to manipulate PDF files.
12
+
13
+ It offers the possibility to parse the PDF contents, modify and save the PDF
14
+ structure, as well as creating new documents.
15
+
16
+ Origami supports some advanced features of the PDF specification:
17
+
18
+ * Compression filters with predictor functions
19
+ * Encryption using RC4 or AES, including the undocumented Revision 6 derivation algorithm
20
+ * Digital signatures and Usage Rights
21
+ * File attachments
22
+ * AcroForm and XFA forms
23
+ * Object streams
24
+
25
+ Origami is able to parse PDF, FDF and PPKLite (Adobe certificate store) files.
26
+
27
+ Requirements
28
+ ------------
29
+
30
+ As of version 2, the minimal version required to run Origami is Ruby 2.1.
31
+
32
+ Some optional features require additional gems:
33
+
34
+ * [therubyracer][the-ruby-racer] for JavaScript emulation of PDF scripts
35
+
36
+ Quick start
37
+ -----------
38
+
39
+ First install Origami using the latest gem available:
40
+
41
+ $ gem install origami
42
+
43
+ Then import Origami with:
44
+
45
+ ```ruby
46
+ require 'origami'
47
+ ```
48
+
49
+ To process a PDF document, you can use the ``PDF.read`` method:
50
+
51
+ ```ruby
52
+ pdf = Origami::PDF.read "something.pdf"
53
+
54
+ puts "This document has #{pdf.pages.size} page(s)"
55
+ ```
56
+
57
+ The default behavior is to parse the entire contents of the document at once. This can be changed by passing the ``lazy`` flag to parse objects on demand.
58
+
59
+ ```ruby
60
+ pdf = Origami::PDF.read "something.pdf", lazy: true
61
+
62
+ pdf.each_page do |page|
63
+ page.each_font do |name, font|
64
+ # ... only parse the necessary bits
65
+ end
66
+ end
67
+ ```
68
+
69
+ You can also create documents directly by instanciating a new PDF object:
70
+
71
+ ```ruby
72
+ pdf = Origami::PDF.new
73
+
74
+ pdf.append_page
75
+ pdf.pages.first.write "Hello", size: 30
76
+
77
+ pdf.save("example.pdf")
78
+
79
+ # Another way of doing it
80
+ Origami::PDF.write("example.pdf") do |pdf|
81
+ pdf.append_page do |page|
82
+ page.write "Hello", size: 30
83
+ end
84
+ end
85
+ ```
86
+
87
+ Take a look at the [examples](examples) and [bin](bin) directories for some examples of advanced usage.
88
+
89
+ Tools
90
+ -----
91
+
92
+ Origami comes with a set of tools to manipulate PDF documents from the command line.
93
+
94
+ * [pdfcop](bin/pdfcop): Runs some heuristic checks to detect dangerous contents.
95
+ * [pdfdecompress](bin/pdfdecompress): Strips compression filters out of a document.
96
+ * [pdfdecrypt](bin/pdfdecrypt): Removes encrypted contents from a document.
97
+ * [pdfencrypt](bin/pdfencrypt): Encrypts a PDF document.
98
+ * [pdfexplode](bin/pdfexplode): Explodes a document into several documents, each of them having one deleted resource. Useful for reduction of crash cases after a fuzzing session.
99
+ * [pdfextract](bin/pdfextract): Extracts binary resources of a document (images, scripts, fonts, etc.).
100
+ * [pdfmetadata](bin/pdfmetadata): Displays the metadata contained in a document.
101
+ * [pdf2ruby](bin/pdf2ruby): Converts a PDF into an Origami script rebuilding an equivalent document (experimental).
102
+ * [pdfsh](bin/pdfsh): An IRB shell running inside the Origami namespace.
103
+
104
+ **Note**: Since version 2.1, [pdfwalker][pdfwalker-gem] has been moved to a [separate repository][pdfwalker-repo].
105
+
106
+ License
107
+ -------
108
+
109
+ Origami is distributed under the [LGPL](COPYING.LESSER) license.
110
+
111
+ Copyright © 2019 Guillaume Delugré.
112
+
113
+ [the-ruby-racer]: https://rubygems.org/gems/therubyracer
114
+ [pdfwalker-gem]: https://rubygems.org/gems/pdfwalker
115
+ [pdfwalker-repo]: https://github.com/gdelugre/pdfwalker
@@ -0,0 +1,236 @@
1
+ ---
2
+ POLICY_NONE:
3
+
4
+ #
5
+ # General features.
6
+ #
7
+ allowParserErrors: true
8
+ allowAttachments: true
9
+ allowEncryption: true
10
+ allowFormCalc: true
11
+ allowJSAtOpening: true
12
+ allowJS: true
13
+ allowAcroForms: true
14
+ allowXFAForms: true
15
+
16
+ #
17
+ # Page annotations.
18
+ #
19
+ allowAnnotations: true
20
+ allow3DAnnotation: true
21
+ allowFileAttachmentAnnotation: true
22
+ allowMovieAnnotation: true
23
+ allowRichMediaAnnotation: true
24
+ allowScreenAnnotation: true
25
+ allowSoundAnnotation: true
26
+
27
+ #
28
+ # PDF Actions.
29
+ #
30
+ allowChainedActions: true
31
+ allowOpenAction: true
32
+ allowGoTo3DAction: true
33
+ allowGoToAction: true
34
+ allowGoToEAction: true
35
+ allowGoToRAction: true
36
+ allowImportDataAction: true
37
+ allowJSAction: true
38
+ allowLaunchAction: true
39
+ allowMovieAction: true
40
+ allowNamedAction: true
41
+ allowRenditionAction: true
42
+ allowRichMediaAction: true
43
+ allowSoundAction: true
44
+ allowSubmitFormAction: true
45
+ allowURIAction: true
46
+
47
+ #
48
+ # Stream filters.
49
+ #
50
+ allowASCII85Filter: true
51
+ allowASCIIHexFilter: true
52
+ allowCCITTFaxFilter: true
53
+ allowCryptFilter: true
54
+ allowDCTFilter: true
55
+ allowFlateFilter: true
56
+ allowJBIG2Filter: true
57
+ allowJPXFilter: true
58
+ allowLZWFilter: true
59
+ allowRunLengthFilter: true
60
+
61
+ POLICY_STANDARD:
62
+
63
+ #
64
+ # General features.
65
+ #
66
+ allowParserErrors: false
67
+ allowAttachments: false
68
+ allowAcroForms: true
69
+ allowEncryption: true
70
+ allowFormCalc: true
71
+ allowJS: true
72
+ allowJSAtOpening: false
73
+ allowXFAForms: true
74
+
75
+ #
76
+ # Page annotations.
77
+ #
78
+ allowAnnotations: true
79
+ allow3DAnnotation: false
80
+ allowFileAttachmentAnnotation: false
81
+ allowMovieAnnotation: false
82
+ allowRichMediaAnnotation: false
83
+ allowScreenAnnotation: false
84
+ allowSoundAnnotation: false
85
+
86
+ #
87
+ # PDF Actions.
88
+ #
89
+ allowChainedActions: true
90
+ allowOpenAction: true
91
+ allowGoTo3DAction: false
92
+ allowGoToAction: true
93
+ allowGoToEAction: false
94
+ allowGoToRAction: false
95
+ allowImportDataAction: false
96
+ allowJSAction: true
97
+ allowLaunchAction: false
98
+ allowMovieAction: false
99
+ allowNamedAction: false
100
+ allowRenditionAction: false
101
+ allowRichMediaAction: false
102
+ allowSoundAction: false
103
+ allowSubmitFormAction: true
104
+ allowURIAction: true
105
+
106
+ #
107
+ # Stream filters.
108
+ #
109
+ allowASCII85Filter: false
110
+ allowASCIIHexFilter: false
111
+ allowCCITTFaxFilter: true
112
+ allowCryptFilter: true
113
+ allowDCTFilter: true
114
+ allowFlateFilter: true
115
+ allowJBIG2Filter: false
116
+ allowJPXFilter: false
117
+ allowLZWFilter: false
118
+ allowRunLengthFilter: false
119
+
120
+ POLICY_STRONG:
121
+
122
+ #
123
+ # General features.
124
+ #
125
+ allowParserErrors: false
126
+ allowAttachments: false
127
+ allowAcroForms: false
128
+ allowEncryption: true
129
+ allowFormCalc: true
130
+ allowJS: false
131
+ allowJSAtOpening: false
132
+ allowXFAForms: false
133
+
134
+ #
135
+ # Page annotations.
136
+ #
137
+ allowAnnotations: true
138
+ allow3DAnnotation: false
139
+ allowFileAttachmentAnnotation: false
140
+ allowMovieAnnotation: false
141
+ allowRichMediaAnnotation: false
142
+ allowScreenAnnotation: false
143
+ allowSoundAnnotation: false
144
+
145
+ #
146
+ # PDF Actions.
147
+ #
148
+ allowChainedActions: false
149
+ allowOpenAction: true
150
+ allowGoTo3DAction: false
151
+ allowGoToAction: true
152
+ allowGoToEAction: false
153
+ allowGoToRAction: false
154
+ allowImportDataAction: false
155
+ allowJSAction: false
156
+ allowLaunchAction: false
157
+ allowMovieAction: false
158
+ allowNamedAction: false
159
+ allowRenditionAction: false
160
+ allowRichMediaAction: false
161
+ allowSoundAction: false
162
+ allowSubmitFormAction: false
163
+ allowURIAction: true
164
+
165
+ #
166
+ # Stream filters.
167
+ #
168
+ allowASCII85Filter: false
169
+ allowASCIIHexFilter: false
170
+ allowCCITTFaxFilter: false
171
+ allowCryptFilter: true
172
+ allowDCTFilter: true
173
+ allowFlateFilter: true
174
+ allowJBIG2Filter: false
175
+ allowJPXFilter: false
176
+ allowLZWFilter: false
177
+ allowRunLengthFilter: false
178
+
179
+ POLICY_PARANOID:
180
+
181
+ #
182
+ # General features.
183
+ #
184
+ allowParserErrors: false
185
+ allowAttachments: false
186
+ allowAcroForms: false
187
+ allowEncryption: false
188
+ allowFormCalc: false
189
+ allowJS: false
190
+ allowJSAtOpening: false
191
+ allowXFAForms: false
192
+
193
+ #
194
+ # Page annotations.
195
+ #
196
+ allowAnnotations: true
197
+ allow3DAnnotation: false
198
+ allowFileAttachmentAnnotation: false
199
+ allowMovieAnnotation: false
200
+ allowRichMediaAnnotation: false
201
+ allowScreenAnnotation: false
202
+ allowSoundAnnotation: false
203
+
204
+ #
205
+ # PDF Actions.
206
+ #
207
+ allowChainedActions: false
208
+ allowOpenAction: false
209
+ allowGoTo3DAction: false
210
+ allowGoToAction: true
211
+ allowGoToEAction: false
212
+ allowGoToRAction: false
213
+ allowImportDataAction: false
214
+ allowJSAction: false
215
+ allowLaunchAction: false
216
+ allowMovieAction: false
217
+ allowNamedAction: false
218
+ allowRenditionAction: false
219
+ allowRichMediaAction: false
220
+ allowSoundAction: false
221
+ allowSubmitFormAction: false
222
+ allowURIAction: false
223
+
224
+ #
225
+ # Stream filters.
226
+ #
227
+ allowASCII85Filter: false
228
+ allowASCIIHexFilter: false
229
+ allowCCITTFaxFilter: false
230
+ allowCryptFilter: false
231
+ allowDCTFilter: true
232
+ allowFlateFilter: true
233
+ allowJBIG2Filter: false
234
+ allowJPXFilter: false
235
+ allowLZWFilter: false
236
+ allowRunLengthFilter: false
data/bin/pdf2pdfa ADDED
@@ -0,0 +1,87 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ =begin
4
+
5
+ = Info
6
+ Enforces a document to be rendered as PDF/A.
7
+ This will disable multimedia features and JavaScript execution in Adobe Reader.
8
+
9
+ = License
10
+ Copyright (C) 2016 Guillaume Delugré.
11
+
12
+ Origami is free software: you can redistribute it and/or modify
13
+ it under the terms of the GNU Lesser General Public License as published by
14
+ the Free Software Foundation, either version 3 of the License, or
15
+ (at your option) any later version.
16
+
17
+ Origami is distributed in the hope that it will be useful,
18
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
+ GNU Lesser General Public License for more details.
21
+
22
+ You should have received a copy of the GNU Lesser General Public License
23
+ along with Origami. If not, see <http://www.gnu.org/licenses/>.
24
+
25
+ =end
26
+
27
+ begin
28
+ require 'origami'
29
+ rescue LoadError
30
+ $: << File.join(__dir__, '../lib')
31
+ require 'origami'
32
+ end
33
+ include Origami
34
+
35
+ require 'optparse'
36
+
37
+ class OptParser
38
+ BANNER = <<USAGE
39
+ Usage: #{$0} [<PDF-file>] [-o <output-file>]
40
+ Enforces a document to be rendered as PDF/A.
41
+ This will disable multimedia features and JavaScript execution in Adobe Reader.
42
+ Bug reports or feature requests at: http://github.com/gdelugre/origami
43
+
44
+ Options:
45
+ USAGE
46
+
47
+ def self.parser(options)
48
+ OptionParser.new do |opts|
49
+ opts.banner = BANNER
50
+
51
+ opts.on("-o", "--output FILE", "Output PDF file (stdout by default)") do |o|
52
+ options[:output] = o
53
+ end
54
+
55
+ opts.on_tail("-h", "--help", "Show this message") do
56
+ puts opts
57
+ exit
58
+ end
59
+ end
60
+ end
61
+
62
+ def self.parse(args)
63
+ options =
64
+ {
65
+ output: STDOUT,
66
+ }
67
+
68
+ self.parser(options).parse!(args)
69
+
70
+ options
71
+ end
72
+ end
73
+
74
+ begin
75
+ @options = OptParser.parse(ARGV)
76
+
77
+ target = (ARGV.empty?) ? STDIN : ARGV.shift
78
+ params =
79
+ {
80
+ verbosity: Parser::VERBOSE_QUIET,
81
+ }
82
+
83
+ PDF.read(target, params).save(@options[:output], intent: 'PDF/A', noindent: true)
84
+
85
+ rescue
86
+ abort "#{$!.class}: #{$!.message}"
87
+ end