origamindee 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +89 -0
- data/COPYING.LESSER +165 -0
- data/README.md +131 -0
- data/bin/config/pdfcop.conf.yml +236 -0
- data/bin/pdf2pdfa +87 -0
- data/bin/pdf2ruby +333 -0
- data/bin/pdfcop +476 -0
- data/bin/pdfdecompress +97 -0
- data/bin/pdfdecrypt +91 -0
- data/bin/pdfencrypt +113 -0
- data/bin/pdfexplode +223 -0
- data/bin/pdfextract +277 -0
- data/bin/pdfmetadata +143 -0
- data/bin/pdfsh +12 -0
- data/bin/shell/console.rb +128 -0
- data/bin/shell/hexdump.rb +59 -0
- data/bin/shell/irbrc +69 -0
- data/examples/README.md +34 -0
- data/examples/attachments/attachment.rb +38 -0
- data/examples/attachments/nested_document.rb +51 -0
- data/examples/encryption/encryption.rb +28 -0
- data/examples/events/events.rb +72 -0
- data/examples/flash/flash.rb +37 -0
- data/examples/flash/helloworld.swf +0 -0
- data/examples/forms/javascript.rb +54 -0
- data/examples/forms/xfa.rb +115 -0
- data/examples/javascript/hello_world.rb +22 -0
- data/examples/javascript/js_emulation.rb +54 -0
- data/examples/loop/goto.rb +32 -0
- data/examples/loop/named.rb +33 -0
- data/examples/signature/signature.rb +65 -0
- data/examples/uri/javascript.rb +56 -0
- data/examples/uri/open-uri.rb +21 -0
- data/examples/uri/submitform.rb +47 -0
- data/lib/origami/3d.rb +364 -0
- data/lib/origami/acroform.rb +321 -0
- data/lib/origami/actions.rb +318 -0
- data/lib/origami/annotations.rb +711 -0
- data/lib/origami/array.rb +242 -0
- data/lib/origami/boolean.rb +90 -0
- data/lib/origami/catalog.rb +418 -0
- data/lib/origami/collections.rb +144 -0
- data/lib/origami/compound.rb +161 -0
- data/lib/origami/destinations.rb +252 -0
- data/lib/origami/dictionary.rb +192 -0
- data/lib/origami/encryption.rb +1084 -0
- data/lib/origami/extensions/fdf.rb +347 -0
- data/lib/origami/extensions/ppklite.rb +422 -0
- data/lib/origami/filespec.rb +197 -0
- data/lib/origami/filters/ascii.rb +211 -0
- data/lib/origami/filters/ccitt/tables.rb +267 -0
- data/lib/origami/filters/ccitt.rb +357 -0
- data/lib/origami/filters/crypt.rb +38 -0
- data/lib/origami/filters/dct.rb +54 -0
- data/lib/origami/filters/flate.rb +69 -0
- data/lib/origami/filters/jbig2.rb +57 -0
- data/lib/origami/filters/jpx.rb +47 -0
- data/lib/origami/filters/lzw.rb +170 -0
- data/lib/origami/filters/predictors.rb +292 -0
- data/lib/origami/filters/runlength.rb +129 -0
- data/lib/origami/filters.rb +364 -0
- data/lib/origami/font.rb +196 -0
- data/lib/origami/functions.rb +79 -0
- data/lib/origami/graphics/colors.rb +230 -0
- data/lib/origami/graphics/instruction.rb +98 -0
- data/lib/origami/graphics/path.rb +182 -0
- data/lib/origami/graphics/patterns.rb +174 -0
- data/lib/origami/graphics/render.rb +62 -0
- data/lib/origami/graphics/state.rb +149 -0
- data/lib/origami/graphics/text.rb +225 -0
- data/lib/origami/graphics/xobject.rb +918 -0
- data/lib/origami/graphics.rb +38 -0
- data/lib/origami/header.rb +75 -0
- data/lib/origami/javascript.rb +713 -0
- data/lib/origami/linearization.rb +330 -0
- data/lib/origami/metadata.rb +172 -0
- data/lib/origami/name.rb +135 -0
- data/lib/origami/null.rb +65 -0
- data/lib/origami/numeric.rb +181 -0
- data/lib/origami/obfuscation.rb +245 -0
- data/lib/origami/object.rb +760 -0
- data/lib/origami/optionalcontent.rb +183 -0
- data/lib/origami/outline.rb +54 -0
- data/lib/origami/outputintents.rb +85 -0
- data/lib/origami/page.rb +722 -0
- data/lib/origami/parser.rb +269 -0
- data/lib/origami/parsers/fdf.rb +56 -0
- data/lib/origami/parsers/pdf/lazy.rb +176 -0
- data/lib/origami/parsers/pdf/linear.rb +122 -0
- data/lib/origami/parsers/pdf.rb +118 -0
- data/lib/origami/parsers/ppklite.rb +57 -0
- data/lib/origami/pdf.rb +1108 -0
- data/lib/origami/reference.rb +134 -0
- data/lib/origami/signature.rb +702 -0
- data/lib/origami/stream.rb +705 -0
- data/lib/origami/string.rb +444 -0
- data/lib/origami/template/patterns.rb +56 -0
- data/lib/origami/template/widgets.rb +151 -0
- data/lib/origami/trailer.rb +190 -0
- data/lib/origami/tree.rb +62 -0
- data/lib/origami/version.rb +23 -0
- data/lib/origami/webcapture.rb +100 -0
- data/lib/origami/xfa/config.rb +453 -0
- data/lib/origami/xfa/connectionset.rb +146 -0
- data/lib/origami/xfa/datasets.rb +49 -0
- data/lib/origami/xfa/localeset.rb +42 -0
- data/lib/origami/xfa/package.rb +59 -0
- data/lib/origami/xfa/pdf.rb +73 -0
- data/lib/origami/xfa/signature.rb +42 -0
- data/lib/origami/xfa/sourceset.rb +43 -0
- data/lib/origami/xfa/stylesheet.rb +44 -0
- data/lib/origami/xfa/template.rb +1691 -0
- data/lib/origami/xfa/xdc.rb +42 -0
- data/lib/origami/xfa/xfa.rb +146 -0
- data/lib/origami/xfa/xfdf.rb +43 -0
- data/lib/origami/xfa/xmpmeta.rb +43 -0
- data/lib/origami/xfa.rb +62 -0
- data/lib/origami/xreftable.rb +557 -0
- data/lib/origami.rb +47 -0
- data/test/dataset/calc.pdf +85 -0
- data/test/dataset/crypto.pdf +36 -0
- data/test/dataset/empty.pdf +49 -0
- data/test/test_actions.rb +27 -0
- data/test/test_annotations.rb +68 -0
- data/test/test_forms.rb +30 -0
- data/test/test_native_types.rb +83 -0
- data/test/test_object_tree.rb +33 -0
- data/test/test_pages.rb +60 -0
- data/test/test_pdf.rb +20 -0
- data/test/test_pdf_attachment.rb +34 -0
- data/test/test_pdf_create.rb +24 -0
- data/test/test_pdf_encrypt.rb +102 -0
- data/test/test_pdf_parse.rb +134 -0
- data/test/test_pdf_parse_lazy.rb +69 -0
- data/test/test_pdf_sign.rb +97 -0
- data/test/test_streams.rb +184 -0
- data/test/test_xrefs.rb +67 -0
- metadata +280 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 593f3f22174161d77e20e75ff2a7a9ae577662861a59881073f78f2c51ac89df
|
4
|
+
data.tar.gz: fe531fa4cc790be0639dcc9703c782bb4f64d9f38ff29a468950fbc131369e52
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 92eb2ab3d99b12da581091ecc5958ac21e3a692294d1c41cca586aa38be18f9d0c91a667cdaeee40be40cd3bd8f593747b03bf6528c675d9dd5df91fa671a4b0
|
7
|
+
data.tar.gz: 9aef422a383150380c49a548429d48cd34905982fae8ef1a0a88f782e5103f5d95944f0c22b037ea2c9781575314f73e84a0f6a780b1164047806a79177cba9d
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
3.0.0
|
2
|
+
-----
|
3
|
+
* Replaced Colorize with Rainbow for LGPL compatibility
|
4
|
+
* Default PDF encryption is now AES-256
|
5
|
+
* Fixes for Ruby 3.0 and 3.1
|
6
|
+
* Updated dependencies
|
7
|
+
* Includes all work done by **Guillaume Delugré** done after 2.1.0:
|
8
|
+
* **Many, many fixes!**
|
9
|
+
* bin/pdfmetadata: switch to output to JSON
|
10
|
+
* header: added Header#version
|
11
|
+
* signature: support for adbe.x509.rsa_sha1
|
12
|
+
* signature: new options introduced for PDF#verify
|
13
|
+
* pdf: method PDF#loaded?
|
14
|
+
* Image with height support
|
15
|
+
* object: remove operator <=>
|
16
|
+
* page: use lazy page enumerator for get_page
|
17
|
+
* test: added test cases to test_pdf_parse
|
18
|
+
* parser: parse methods now accept a String argument
|
19
|
+
|
20
|
+
2.1.0
|
21
|
+
-----
|
22
|
+
* Moved pdfwalker to a separate gem
|
23
|
+
|
24
|
+
2.0.0
|
25
|
+
-----
|
26
|
+
* Code reindented to 4 spaces.
|
27
|
+
* Code base refactored for Ruby 2.x (requires at least 2.1).
|
28
|
+
* Support for Crypt filters.
|
29
|
+
* The parser now supports a lazy mode.
|
30
|
+
* Fixed all Ruby warnings.
|
31
|
+
* Better type propagation.
|
32
|
+
* Use namespace refinements to protect the standard namespace.
|
33
|
+
* PDF#each_* methods can return Enumerators.
|
34
|
+
* Use the colorize gem for console output.
|
35
|
+
* Faster loading of objects in pdfwalker.
|
36
|
+
* Better handling of cross-references in pdfwalker.
|
37
|
+
* Many bug fixes.
|
38
|
+
|
39
|
+
1.2.0 (2011-09-29)
|
40
|
+
-----
|
41
|
+
* Support for JavaScript emulation based on V8 (requires therubyracer gem).
|
42
|
+
|
43
|
+
1.1.0 (2011-09-14)
|
44
|
+
-----
|
45
|
+
* Support for standard security handler revision 6.
|
46
|
+
|
47
|
+
1.0.2 (2011-05-25)
|
48
|
+
-----
|
49
|
+
* Added a Rakefile to run unit tests, build rdoc and build gem.
|
50
|
+
* Added a Ruby shell for Origami.
|
51
|
+
* Added a bin folder, with some useful command-line tools.
|
52
|
+
* Can now be installed as a RubyGem.
|
53
|
+
* AESV3 support (AES256 encryption/decryption).
|
54
|
+
* Encryption/decryption can be achieved with or without openssl.
|
55
|
+
* Changed PDF#encrypt prototype.
|
56
|
+
* Support for G3 unidimensional encoding/decoding of CCITTFax filter.
|
57
|
+
* Support for TIFF stream predictor functions.
|
58
|
+
* Name trees lookup methods.
|
59
|
+
* Renamed PDF#saveas to PDF#save.
|
60
|
+
* Lot of bug fixes.
|
61
|
+
|
62
|
+
beta3 (2010-08-26)
|
63
|
+
-----
|
64
|
+
* Faster decryption process.
|
65
|
+
* Properly parse objects with no endobj token.
|
66
|
+
* Image viewer in pdfwalker.
|
67
|
+
|
68
|
+
beta2 (2010-04-01)
|
69
|
+
-----
|
70
|
+
* Support for Flash/RichMedia integration.
|
71
|
+
* XFA forms.
|
72
|
+
* Search feature for pdfwalker.
|
73
|
+
* Fixed various bugs.
|
74
|
+
|
75
|
+
beta1 (2009-09-15)
|
76
|
+
-----
|
77
|
+
* Basic support for graphics drawing as lines, colors, shading, shapes...
|
78
|
+
* Support for numerical functions.
|
79
|
+
* Support for date strings.
|
80
|
+
* Added PDF#insert_page(index, page) method.
|
81
|
+
* Added a forms widgets template.
|
82
|
+
* Ability to delinearize documents.
|
83
|
+
* Fixed various bugs.
|
84
|
+
|
85
|
+
beta0 (2009-07-06)
|
86
|
+
-----
|
87
|
+
* Support for XRef streams.
|
88
|
+
* Support for Object streams creation.
|
89
|
+
* 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,131 @@
|
|
1
|
+
[![License: LGPL](https://img.shields.io/github/license/mindee/origamindee)](https://www.gnu.org/licenses/lgpl-3.0)
|
2
|
+
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/mindee/origamindee/test.yml)](https://github.com/mindee/origamindee)
|
3
|
+
[![Gem Version](https://img.shields.io/gem/v/origamindee)](https://rubygems.org/gems/origamindee)
|
4
|
+
[![Downloads](https://img.shields.io/gem/dt/origamindee.svg)](https://rubygems.org/gems/origamindee)
|
5
|
+
|
6
|
+
Origamindee
|
7
|
+
===========
|
8
|
+
[Mindee](https://mindee.com/)'s fork of the popular Origami library.
|
9
|
+
|
10
|
+
Overview
|
11
|
+
--------
|
12
|
+
Origami is a framework written in pure Ruby to manipulate PDF files.
|
13
|
+
|
14
|
+
It offers the possibility to parse the PDF contents, modify and save the PDF
|
15
|
+
structure, as well as creating new documents.
|
16
|
+
|
17
|
+
Origami supports some advanced features of the PDF specification:
|
18
|
+
|
19
|
+
* Compression filters with predictor functions
|
20
|
+
* Encryption using RC4 (now obsolete) or AES, including the undocumented Revision 6 derivation algorithm
|
21
|
+
* Digital signatures and Usage Rights
|
22
|
+
* File attachments
|
23
|
+
* AcroForm and XFA forms
|
24
|
+
* Object streams
|
25
|
+
|
26
|
+
Origami is able to parse PDF, FDF and PPKLite (Adobe certificate store) files.
|
27
|
+
|
28
|
+
Requirements
|
29
|
+
------------
|
30
|
+
The following Ruby versions are tested and supported: 2.6, 2.7, 3.0, 3.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
|
+
First install Origamindee (this fork) using the latest gem available:
|
39
|
+
|
40
|
+
$ gem install origamindee
|
41
|
+
|
42
|
+
You'll need to import it under the original name:
|
43
|
+
```ruby
|
44
|
+
require 'origami'
|
45
|
+
```
|
46
|
+
|
47
|
+
To process a PDF document, you can use the ``PDF.read`` method:
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
pdf = Origami::PDF.read "something.pdf"
|
51
|
+
|
52
|
+
puts "This document has #{pdf.pages.size} page(s)"
|
53
|
+
```
|
54
|
+
|
55
|
+
The default behavior is to parse the entire contents of the document at once.
|
56
|
+
This can be changed by passing the ``lazy`` flag to parse objects on demand.
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
pdf = Origami::PDF.read "something.pdf", lazy: true
|
60
|
+
|
61
|
+
pdf.each_page do |page|
|
62
|
+
page.each_font do |name, font|
|
63
|
+
# ... only parse the necessary bits
|
64
|
+
end
|
65
|
+
end
|
66
|
+
```
|
67
|
+
|
68
|
+
You can also create documents directly by instantiating a new PDF object:
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
pdf = Origami::PDF.new
|
72
|
+
|
73
|
+
pdf.append_page
|
74
|
+
pdf.pages.first.write "Hello", size: 30
|
75
|
+
|
76
|
+
pdf.save("example.pdf")
|
77
|
+
|
78
|
+
# Another way of doing it
|
79
|
+
Origami::PDF.write("example.pdf") do |pdf|
|
80
|
+
pdf.append_page do |page|
|
81
|
+
page.write "Hello", size: 30
|
82
|
+
end
|
83
|
+
end
|
84
|
+
```
|
85
|
+
|
86
|
+
Take a look at the [examples](examples) and [bin](bin) directories for some examples of advanced usage.
|
87
|
+
|
88
|
+
Tools
|
89
|
+
-----
|
90
|
+
Origami comes with a set of tools to manipulate PDF documents from the command line.
|
91
|
+
|
92
|
+
* [pdfcop](bin/pdfcop): Runs some heuristic checks to detect dangerous contents.
|
93
|
+
* [pdfdecompress](bin/pdfdecompress): Strips compression filters out of a document.
|
94
|
+
* [pdfdecrypt](bin/pdfdecrypt): Removes encrypted contents from a document.
|
95
|
+
* [pdfencrypt](bin/pdfencrypt): Encrypts a PDF document.
|
96
|
+
* [pdfexplode](bin/pdfexplode): Explodes a document into several documents, each of them having one deleted resource.
|
97
|
+
Useful for reduction of crash cases after a fuzzing session.
|
98
|
+
* [pdfextract](bin/pdfextract): Extracts binary resources of a document (images, scripts, fonts, etc.).
|
99
|
+
* [pdfmetadata](bin/pdfmetadata): Displays the metadata contained in a document.
|
100
|
+
* [pdf2ruby](bin/pdf2ruby): Converts a PDF into an Origami script rebuilding an equivalent document (experimental).
|
101
|
+
* [pdfsh](bin/pdfsh): An IRB shell running inside the Origami namespace.
|
102
|
+
|
103
|
+
**Note**: Since version 2.1, [pdfwalker][pdfwalker-gem] has been moved to a [separate repository][pdfwalker-repo].
|
104
|
+
|
105
|
+
Motivation
|
106
|
+
----------
|
107
|
+
We were using the excellent Origami library for our [Ruby OCR client library](https://github.com/mindee/mindee-api-ruby).
|
108
|
+
|
109
|
+
Unfortunately, it seems the Origami project is now inactive, and as we needed to add Ruby 3.0 support, the decision was made
|
110
|
+
to fork Origami.
|
111
|
+
|
112
|
+
We also noticed that the `colorize` library is licensed under GPL, meaning that Origami cannot be licensed under the LGPL.
|
113
|
+
It was therefore replaced by `Rainbow` which has similar functionality, and is licensed under MIT.
|
114
|
+
|
115
|
+
Furthermore, we are now in a better position to fix any problems related to PDF parsing that are encountered by our users.
|
116
|
+
|
117
|
+
As such it is our intention to support functionalities within the scope of our client library.
|
118
|
+
|
119
|
+
**We do not claim to be an official successor to Origami.**
|
120
|
+
|
121
|
+
License
|
122
|
+
-------
|
123
|
+
Origami is distributed under the [LGPL](COPYING.LESSER) license.
|
124
|
+
|
125
|
+
Copyright © 2019 Guillaume Delugré
|
126
|
+
|
127
|
+
Copyright © 2022 Mindee, SA
|
128
|
+
|
129
|
+
[the-ruby-racer]: https://rubygems.org/gems/therubyracer
|
130
|
+
[pdfwalker-gem]: https://rubygems.org/gems/pdfwalker
|
131
|
+
[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
|