origami 2.0.1 → 2.0.2

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.
@@ -0,0 +1,187 @@
1
+ =begin
2
+
3
+ This file is part of Origami, PDF manipulation framework for Ruby
4
+ Copyright (C) 2017 Guillaume Delugré.
5
+
6
+ Origami is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU Lesser General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ Origami is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU Lesser General Public License for more details.
15
+
16
+ You should have received a copy of the GNU Lesser General Public License
17
+ along with Origami. If not, see <http://www.gnu.org/licenses/>.
18
+
19
+ =end
20
+
21
+ module Origami
22
+
23
+ module XDP
24
+
25
+ module Packet
26
+
27
+ #
28
+ # The _connectionSet_ packet describes the connections used to initiate or conduct web services.
29
+ #
30
+ class ConnectionSet < XFA::Element
31
+ mime_type 'text/xml'
32
+
33
+ def initialize
34
+ super("connectionSet")
35
+
36
+ add_attribute 'xmlns', 'http://www.xfa.org/schema/xfa-connection-set/2.8/'
37
+ end
38
+
39
+ class EffectiveInputPolicy < XFA::Element
40
+ xfa_attribute 'id'
41
+ xfa_attribute 'name'
42
+ xfa_attribute 'use'
43
+ xfa_attribute 'usehref'
44
+
45
+ def initialize
46
+ super('effectiveInputPolicy')
47
+ end
48
+ end
49
+
50
+ class EffectiveOutputPolicy < XFA::Element
51
+ xfa_attribute 'id'
52
+ xfa_attribute 'name'
53
+ xfa_attribute 'use'
54
+ xfa_attribute 'usehref'
55
+
56
+ def initialize
57
+ super('effectiveOutputPolicy')
58
+ end
59
+ end
60
+
61
+ class Operation < XFA::Element
62
+ xfa_attribute 'id'
63
+ xfa_attribute 'input'
64
+ xfa_attribute 'name'
65
+ xfa_attribute 'output'
66
+ xfa_attribute 'use'
67
+ xfa_attribute 'usehref'
68
+
69
+ def initialize(name = "")
70
+ super('operation')
71
+
72
+ self.text = name
73
+ end
74
+ end
75
+
76
+ class SOAPAction < XFA::Element
77
+ xfa_attribute 'id'
78
+ xfa_attribute 'name'
79
+ xfa_attribute 'use'
80
+ xfa_attribute 'usehref'
81
+
82
+ def initialize(uri = "")
83
+ super('soapAction')
84
+
85
+ self.text = uri
86
+ end
87
+ end
88
+
89
+ class SOAPAddress < XFA::Element
90
+ xfa_attribute 'id'
91
+ xfa_attribute 'name'
92
+ xfa_attribute 'use'
93
+ xfa_attribute 'usehref'
94
+
95
+ def initialize(addr = "")
96
+ super('soapAddress')
97
+
98
+ self.text = addr
99
+ end
100
+ end
101
+
102
+ class WSDLAddress < XFA::Element
103
+ xfa_attribute 'id'
104
+ xfa_attribute 'name'
105
+ xfa_attribute 'use'
106
+ xfa_attribute 'usehref'
107
+
108
+ def initialize(addr = "")
109
+ super('wsdlAddress')
110
+
111
+ self.text = addr
112
+ end
113
+ end
114
+
115
+ class WSDLConnection < XFA::Element
116
+ xfa_attribute 'dataDescription'
117
+ xfa_attribute 'name'
118
+
119
+ xfa_node 'effectiveInputPolicy', ConnectionSet::EffectiveInputPolicy, 0..1
120
+ xfa_node 'effectiveOutputPolicy', ConnectionSet::EffectiveOutputPolicy, 0..1
121
+ xfa_node 'operation', ConnectionSet::Operation, 0..1
122
+ xfa_node 'soapAction', ConnectionSet::SOAPAction, 0..1
123
+ xfa_node 'soapAddress', ConnectionSet::SOAPAddress, 0..1
124
+ xfa_node 'wsdlAddress', ConnectionSet::WSDLAddress, 0..1
125
+
126
+ def initialize
127
+ super('wsdlConnection')
128
+ end
129
+ end
130
+
131
+ class URI < XFA::Element
132
+ xfa_attribute 'id'
133
+ xfa_attribute 'name'
134
+ xfa_attribute 'use'
135
+ xfa_attribute 'usehref'
136
+
137
+ def initialize(uri = "")
138
+ super('uri')
139
+
140
+ self.text = uri
141
+ end
142
+ end
143
+
144
+ class RootElement < XFA::Element
145
+ xfa_attribute 'id'
146
+ xfa_attribute 'name'
147
+ xfa_attribute 'use'
148
+ xfa_attribute 'usehref'
149
+
150
+ def initialize(root = '')
151
+ super('rootElement')
152
+
153
+ self.text = root
154
+ end
155
+ end
156
+
157
+ class XSDConnection < XFA::Element
158
+ xfa_attribute 'dataDescription'
159
+ xfa_attribute 'name'
160
+
161
+ xfa_node 'rootElement', ConnectionSet::RootElement, 0..1
162
+ xfa_node 'uri', ConnectionSet::URI, 0..1
163
+
164
+ def initialize
165
+ super('xsdConnection')
166
+ end
167
+ end
168
+
169
+ class XMLConnection < XFA::Element
170
+ xfa_attribute 'dataDescription'
171
+ xfa_attribute 'name'
172
+
173
+ xfa_node 'uri', ConnectionSet::URI, 0..1
174
+
175
+ def initialize
176
+ super('xmlConnection')
177
+ end
178
+ end
179
+
180
+ xfa_node 'wsdlConnection', ConnectionSet::WSDLConnection
181
+ xfa_node 'xmlConnection', ConnectionSet::XMLConnection
182
+ xfa_node 'xsdConnection', ConnectionSet::XSDConnection
183
+ end
184
+
185
+ end
186
+ end
187
+ end
@@ -0,0 +1,49 @@
1
+ =begin
2
+
3
+ This file is part of Origami, PDF manipulation framework for Ruby
4
+ Copyright (C) 2017 Guillaume Delugré.
5
+
6
+ Origami is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU Lesser General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ Origami is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU Lesser General Public License for more details.
15
+
16
+ You should have received a copy of the GNU Lesser General Public License
17
+ along with Origami. If not, see <http://www.gnu.org/licenses/>.
18
+
19
+ =end
20
+
21
+ module Origami
22
+
23
+ module XDP
24
+
25
+ module Packet
26
+
27
+ #
28
+ # The _datasets_ element enclosed XML data content that may have originated from an XFA form and/or
29
+ # may be intended to be consumed by an XFA form.
30
+ #
31
+ class Datasets < XFA::Element
32
+ mime_type 'text/xml'
33
+
34
+ class Data < XFA::Element
35
+ def initialize
36
+ super('xfa:data')
37
+ end
38
+ end
39
+
40
+ def initialize
41
+ super("xfa:datasets")
42
+
43
+ add_attribute 'xmlns:xfa', 'http://www.xfa.org/schema/xfa-data/1.0/'
44
+ end
45
+ end
46
+
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,42 @@
1
+ =begin
2
+
3
+ This file is part of Origami, PDF manipulation framework for Ruby
4
+ Copyright (C) 2017 Guillaume Delugré.
5
+
6
+ Origami is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU Lesser General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ Origami is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU Lesser General Public License for more details.
15
+
16
+ You should have received a copy of the GNU Lesser General Public License
17
+ along with Origami. If not, see <http://www.gnu.org/licenses/>.
18
+
19
+ =end
20
+
21
+ module Origami
22
+
23
+ module XDP
24
+
25
+ module Packet
26
+
27
+ #
28
+ # The _localeSet_ packet encloses information about locales.
29
+ #
30
+ class LocaleSet < XFA::Element
31
+ mime_type 'text/xml'
32
+
33
+ def initialize
34
+ super("localeSet")
35
+
36
+ add_attribute 'xmlns', 'http://www.xfa.org/schema/xfa-locale-set/2.7/'
37
+ end
38
+ end
39
+
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,59 @@
1
+ =begin
2
+
3
+ This file is part of Origami, PDF manipulation framework for Ruby
4
+ Copyright (C) 2017 Guillaume Delugré.
5
+
6
+ Origami is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU Lesser General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ Origami is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU Lesser General Public License for more details.
15
+
16
+ You should have received a copy of the GNU Lesser General Public License
17
+ along with Origami. If not, see <http://www.gnu.org/licenses/>.
18
+
19
+ =end
20
+
21
+ require 'rexml/document'
22
+
23
+ module Origami
24
+
25
+ module XDP
26
+
27
+ class XDP < XFA::Element
28
+ xfa_attribute 'uuid'
29
+ xfa_attribute 'timeStamp'
30
+
31
+ xfa_node 'config', Origami::XDP::Packet::Config, 0..1
32
+ xfa_node 'connectionSet', Origami::XDP::Packet::ConnectionSet, 0..1
33
+ xfa_node 'datasets', Origami::XDP::Packet::Datasets, 0..1
34
+ xfa_node 'localeSet', Origami::XDP::Packet::LocaleSet, 0..1
35
+ xfa_node 'pdf', Origami::XDP::Packet::PDF, 0..1
36
+ xfa_node 'sourceSet', Origami::XDP::Packet::SourceSet, 0..1
37
+ xfa_node 'styleSheet', Origami::XDP::Packet::StyleSheet, 0..1
38
+ xfa_node 'template', Origami::XDP::Packet::Template, 0..1
39
+ xfa_node 'xdc', Origami::XDP::Packet::XDC, 0..1
40
+ xfa_node 'xfdf', Origami::XDP::Packet::XFDF, 0..1
41
+ xfa_node 'xmpmeta', Origami::XDP::Packet::XMPMeta, 0..1
42
+
43
+ def initialize
44
+ super('xdp:xdp')
45
+
46
+ add_attribute 'xmlns:xdp', 'http://ns.adobe.com/xdp/'
47
+ end
48
+ end
49
+
50
+ class Package < REXML::Document
51
+ def initialize(package = nil)
52
+ super(package || REXML::XMLDecl.new.to_s)
53
+
54
+ add_element Origami::XDP::XDP.new if package.nil?
55
+ end
56
+ end
57
+ end
58
+
59
+ end
@@ -0,0 +1,73 @@
1
+ =begin
2
+
3
+ This file is part of Origami, PDF manipulation framework for Ruby
4
+ Copyright (C) 2017 Guillaume Delugré.
5
+
6
+ Origami is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU Lesser General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ Origami is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU Lesser General Public License for more details.
15
+
16
+ You should have received a copy of the GNU Lesser General Public License
17
+ along with Origami. If not, see <http://www.gnu.org/licenses/>.
18
+
19
+ =end
20
+
21
+ module Origami
22
+
23
+ module XDP
24
+
25
+ module Packet
26
+
27
+ #
28
+ # An XDF _pdf_ element encloses a PDF packet.
29
+ #
30
+ class PDF < XFA::Element
31
+ mime_type 'application/pdf'
32
+ xfa_attribute :href
33
+
34
+ def initialize
35
+ super("pdf")
36
+
37
+ add_attribute 'xmlns', 'http://ns.adobe.com/xdp/pdf/'
38
+ end
39
+
40
+ def enclose_pdf(pdfdata)
41
+ require 'base64'
42
+ b64data = Base64.encode64(pdfdata).chomp!
43
+
44
+ doc = elements['document'] || add_element('document')
45
+ chunk = doc.elements['chunk'] || doc.add_element('chunk')
46
+
47
+ chunk.text = b64data
48
+
49
+ self
50
+ end
51
+
52
+ def has_enclosed_pdf?
53
+ chunk = elements['document/chunk']
54
+
55
+ not chunk.nil? and not chunk.text.nil?
56
+ end
57
+
58
+ def remove_enclosed_pdf
59
+ elements.delete('document') if has_enclosed_pdf?
60
+ end
61
+
62
+ def enclosed_pdf
63
+ return nil unless has_enclosed_pdf?
64
+
65
+ require 'base64'
66
+ Base64.decode64(elements['document/chunk'].text)
67
+ end
68
+
69
+ end
70
+
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,42 @@
1
+ =begin
2
+
3
+ This file is part of Origami, PDF manipulation framework for Ruby
4
+ Copyright (C) 2017 Guillaume Delugré.
5
+
6
+ Origami is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU Lesser General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ Origami is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU Lesser General Public License for more details.
15
+
16
+ You should have received a copy of the GNU Lesser General Public License
17
+ along with Origami. If not, see <http://www.gnu.org/licenses/>.
18
+
19
+ =end
20
+
21
+ module Origami
22
+
23
+ module XDP
24
+
25
+ module Packet
26
+
27
+ #
28
+ # The _signature_ packet encloses a detached digital signature.
29
+ #
30
+ class Signature < XFA::Element
31
+ mime_type ''
32
+
33
+ def initialize
34
+ super("signature")
35
+
36
+ add_attribute 'xmlns', 'http://www.w3.org/2000/09/xmldsig#'
37
+ end
38
+ end
39
+
40
+ end
41
+ end
42
+ end