origami 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. data/COPYING.LESSER +165 -0
  2. data/README +77 -0
  3. data/VERSION +1 -0
  4. data/bin/config/pdfcop.conf.yml +237 -0
  5. data/bin/gui/about.rb +46 -0
  6. data/bin/gui/config.rb +132 -0
  7. data/bin/gui/file.rb +385 -0
  8. data/bin/gui/hexdump.rb +74 -0
  9. data/bin/gui/hexview.rb +91 -0
  10. data/bin/gui/imgview.rb +72 -0
  11. data/bin/gui/menu.rb +392 -0
  12. data/bin/gui/properties.rb +132 -0
  13. data/bin/gui/signing.rb +635 -0
  14. data/bin/gui/textview.rb +107 -0
  15. data/bin/gui/treeview.rb +409 -0
  16. data/bin/gui/walker.rb +282 -0
  17. data/bin/gui/xrefs.rb +79 -0
  18. data/bin/pdf2graph +121 -0
  19. data/bin/pdf2ruby +353 -0
  20. data/bin/pdfcocoon +104 -0
  21. data/bin/pdfcop +455 -0
  22. data/bin/pdfdecompress +104 -0
  23. data/bin/pdfdecrypt +95 -0
  24. data/bin/pdfencrypt +112 -0
  25. data/bin/pdfextract +221 -0
  26. data/bin/pdfmetadata +123 -0
  27. data/bin/pdfsh +13 -0
  28. data/bin/pdfwalker +7 -0
  29. data/bin/shell/.irbrc +104 -0
  30. data/bin/shell/console.rb +136 -0
  31. data/bin/shell/hexdump.rb +83 -0
  32. data/origami.rb +36 -0
  33. data/origami/3d.rb +239 -0
  34. data/origami/acroform.rb +321 -0
  35. data/origami/actions.rb +299 -0
  36. data/origami/adobe/fdf.rb +259 -0
  37. data/origami/adobe/ppklite.rb +489 -0
  38. data/origami/annotations.rb +775 -0
  39. data/origami/array.rb +187 -0
  40. data/origami/boolean.rb +101 -0
  41. data/origami/catalog.rb +486 -0
  42. data/origami/destinations.rb +213 -0
  43. data/origami/dictionary.rb +188 -0
  44. data/origami/docmdp.rb +96 -0
  45. data/origami/encryption.rb +1293 -0
  46. data/origami/export.rb +283 -0
  47. data/origami/file.rb +222 -0
  48. data/origami/filters.rb +250 -0
  49. data/origami/filters/ascii.rb +189 -0
  50. data/origami/filters/ccitt.rb +515 -0
  51. data/origami/filters/crypt.rb +47 -0
  52. data/origami/filters/dct.rb +61 -0
  53. data/origami/filters/flate.rb +112 -0
  54. data/origami/filters/jbig2.rb +63 -0
  55. data/origami/filters/jpx.rb +53 -0
  56. data/origami/filters/lzw.rb +195 -0
  57. data/origami/filters/predictors.rb +276 -0
  58. data/origami/filters/runlength.rb +117 -0
  59. data/origami/font.rb +209 -0
  60. data/origami/functions.rb +93 -0
  61. data/origami/graphics.rb +33 -0
  62. data/origami/graphics/colors.rb +191 -0
  63. data/origami/graphics/instruction.rb +126 -0
  64. data/origami/graphics/path.rb +154 -0
  65. data/origami/graphics/patterns.rb +180 -0
  66. data/origami/graphics/state.rb +164 -0
  67. data/origami/graphics/text.rb +224 -0
  68. data/origami/graphics/xobject.rb +493 -0
  69. data/origami/header.rb +90 -0
  70. data/origami/linearization.rb +318 -0
  71. data/origami/metadata.rb +114 -0
  72. data/origami/name.rb +170 -0
  73. data/origami/null.rb +75 -0
  74. data/origami/numeric.rb +188 -0
  75. data/origami/obfuscation.rb +233 -0
  76. data/origami/object.rb +527 -0
  77. data/origami/outline.rb +59 -0
  78. data/origami/page.rb +559 -0
  79. data/origami/parser.rb +268 -0
  80. data/origami/parsers/fdf.rb +45 -0
  81. data/origami/parsers/pdf.rb +27 -0
  82. data/origami/parsers/pdf/linear.rb +113 -0
  83. data/origami/parsers/ppklite.rb +86 -0
  84. data/origami/pdf.rb +1144 -0
  85. data/origami/reference.rb +113 -0
  86. data/origami/signature.rb +474 -0
  87. data/origami/stream.rb +575 -0
  88. data/origami/string.rb +416 -0
  89. data/origami/trailer.rb +173 -0
  90. data/origami/webcapture.rb +87 -0
  91. data/origami/xfa.rb +3027 -0
  92. data/origami/xreftable.rb +447 -0
  93. data/templates/patterns.rb +66 -0
  94. data/templates/widgets.rb +173 -0
  95. data/templates/xdp.rb +92 -0
  96. data/tests/dataset/test.dummycrt +28 -0
  97. data/tests/dataset/test.dummykey +27 -0
  98. data/tests/tc_actions.rb +32 -0
  99. data/tests/tc_annotations.rb +85 -0
  100. data/tests/tc_pages.rb +37 -0
  101. data/tests/tc_pdfattach.rb +24 -0
  102. data/tests/tc_pdfencrypt.rb +110 -0
  103. data/tests/tc_pdfnew.rb +32 -0
  104. data/tests/tc_pdfparse.rb +98 -0
  105. data/tests/tc_pdfsig.rb +37 -0
  106. data/tests/tc_streams.rb +129 -0
  107. data/tests/ts_pdf.rb +45 -0
  108. metadata +193 -0
@@ -0,0 +1,173 @@
1
+ =begin
2
+
3
+ = File
4
+ widgets.rb
5
+
6
+ = Info
7
+ This file is part of Origami, PDF manipulation framework for Ruby
8
+ Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org>
9
+ All right reserved.
10
+
11
+ Origami is free software: you can redistribute it and/or modify
12
+ it under the terms of the GNU Lesser General Public License as published by
13
+ the Free Software Foundation, either version 3 of the License, or
14
+ (at your option) any later version.
15
+
16
+ Origami is distributed in the hope that it will be useful,
17
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
18
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
+ GNU Lesser General Public License for more details.
20
+
21
+ You should have received a copy of the GNU Lesser General Public License
22
+ along with Origami. If not, see <http://www.gnu.org/licenses/>.
23
+
24
+ =end
25
+
26
+ module Origami
27
+
28
+ module Template
29
+
30
+ class Button < Annotation::Widget::PushButton
31
+
32
+ def initialize(x,y,width,height, caption, id = nil)
33
+ super()
34
+
35
+ set_indirect(true)
36
+
37
+ self.H = Annotation::Widget::Highlight::INVERT
38
+ self.Rect = [ x, y, x+width, y+height ]
39
+ self.F = Annotation::Flags::PRINT
40
+ self.T = id
41
+
42
+ appstm = Annotation::AppearanceStream.new.setFilter(:FlateDecode)
43
+ appstm.BBox = [ 0, 0, width, height ]
44
+ appstm.Matrix = [ 1, 0, 0, 1, 0, 0 ]
45
+
46
+ appstm.draw_rectangle(0, 0, width, height,
47
+ :fill => true, :stroke => false, :fill_color => Graphics::Color::RGB.new(0xE6, 0xE6, 0xFA))
48
+
49
+ appstm.draw_polygon([[1,1],[1,height-1],[width-1,height-1],[width-2,height-2],[2,height-2],[2,2]],
50
+ :fill => true, :stroke => false, :fill_color => Graphics::Color::GrayScale.new(1.0))
51
+
52
+ appstm.draw_polygon([[width-1,height-1],[width-1,1],[1,1],[2,2],[width-2,2],[width-2,height-2]],
53
+ :fill => true, :stroke => false, :fill_color => Graphics::Color::RGB.new(130, 130, 130))
54
+
55
+ appstm.draw_rectangle(0.5, 0.5, width-1, height-1,
56
+ :fill => false, :stroke => true, :stroke_color => Graphics::Color::GrayScale.new(0.0))
57
+
58
+ text_width = 4.75 * caption.length
59
+ appstm.write(caption,
60
+ :x => (width - text_width)/2, :y => height/2-5, :size => 10)
61
+
62
+ appstm.Resources = Resources.new
63
+ set_normal_appearance(appstm)
64
+ end
65
+
66
+ end
67
+
68
+ class Edit < Annotation::Widget::Text
69
+
70
+ def initialize(x,y,width,height, id)
71
+ super()
72
+
73
+ set_indirect(true)
74
+
75
+ self.Rect = [ x, y, x+width, y+height ]
76
+ self.F = Annotation::Flags::PRINT
77
+ self.T = id
78
+ self.DA = '/F1 12 Tf 0 g'
79
+
80
+ appstm = Annotation::AppearanceStream.new.setFilter(:FlateDecode)
81
+ appstm.BBox = [ 0, 0, width, height ]
82
+ appstm.Matrix = [ 1, 0, 0, 1, 0, 0 ]
83
+
84
+ appstm.draw_rectangle(0, 0, width, height,
85
+ :fill => false, :stroke => true, :stroke_color => Graphics::Color::GrayScale.new(0.0))
86
+
87
+ appstm.draw_polygon([[1,1],[1,height-1],[width-1,height-1],[width-2,height-2],[2,height-2],[2,2]],
88
+ :fill => true, :stroke => false, :fill_color => Graphics::Color::RGB.new(130, 130, 130))
89
+
90
+ appstm.draw_polygon([[width-1,height-1],[width-1,1],[1,1],[2,2],[width-2,2],[width-2,height-2]],
91
+ :fill => true, :stroke => false, :fill_color => Graphics::Color::GrayScale.new(1.0))
92
+
93
+ appstm.draw_rectangle(0.5, 0.5, width-1, height-1,
94
+ :fill => false, :stroke => true, :stroke_color => Graphics::Color::GrayScale.new(0.0))
95
+
96
+ set_normal_appearance(appstm)
97
+ end
98
+
99
+ end
100
+
101
+ class MultiLineEdit < Edit
102
+
103
+ def initialize(x,y,width,height, id)
104
+
105
+ super(x,y,width,height,id)
106
+
107
+ self.Ff ||= 0
108
+ self.Ff |= Annotation::Widget::Text::Flags::MULTILINE
109
+ end
110
+
111
+ end
112
+
113
+ class RichTextEdit < MultiLineEdit
114
+
115
+ def initialize(x,y,width,height, id)
116
+
117
+ super(x,y,width,height,id)
118
+
119
+ self.F |= Annotation::Flags::READONLY
120
+ self.Ff |= (Annotation::Widget::Text::Flags::RICHTEXT | Field::Flags::READONLY)
121
+ end
122
+
123
+ end
124
+
125
+ class PasswordEdit < Edit
126
+
127
+ def initialize(x,y,width,height, id)
128
+
129
+ super(x,y,width,height,id)
130
+
131
+ self.Ff ||= 0
132
+ self.Ff |= Annotation::Widget::Text::Flags::PASSWORD
133
+
134
+ end
135
+
136
+ end
137
+
138
+ class TextPanel < Annotation::FreeText
139
+
140
+ def initialize(x,y,width,height, id)
141
+ super()
142
+
143
+ set_indirect(true)
144
+
145
+ self.Rect = [ x, y, x+width, y+height ]
146
+ self.F = Annotation::Flags::PRINT
147
+ self.NM = id
148
+ self.DA = '/F1 12 Tf 0 g'
149
+
150
+ appstm = Annotation::AppearanceStream.new.setFilter(:FlateDecode)
151
+ appstm.BBox = [ 0, 0, width, height ]
152
+ appstm.Matrix = [ 1, 0, 0, 1, 0, 0 ]
153
+
154
+ appstm.draw_rectangle(0, 0, width, height,
155
+ :fill => false, :stroke => true, :stroke_color => Graphics::Color::GrayScale.new(0.0))
156
+
157
+ appstm.draw_polygon([[1,1],[1,height-1],[width-1,height-1],[width-2,height-2],[2,height-2],[2,2]],
158
+ :fill => true, :stroke => false, :fill_color => Graphics::Color::RGB.new(130, 130, 130))
159
+
160
+ appstm.draw_polygon([[width-1,height-1],[width-1,1],[1,1],[2,2],[width-2,2],[width-2,height-2]],
161
+ :fill => true, :stroke => false, :fill_color => Graphics::Color::GrayScale.new(1.0))
162
+
163
+ appstm.draw_rectangle(0.5, 0.5, width-1, height-1,
164
+ :fill => false, :stroke => true, :stroke_color => Graphics::Color::GrayScale.new(0.0))
165
+
166
+ set_normal_appearance(appstm)
167
+ end
168
+
169
+ end
170
+
171
+ end
172
+
173
+ end
@@ -0,0 +1,92 @@
1
+ =begin
2
+
3
+ = File
4
+ xdp.rb
5
+
6
+ = Info
7
+ This file is part of Origami, PDF manipulation framework for Ruby
8
+ Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org>
9
+ All right reserved.
10
+
11
+ Origami is free software: you can redistribute it and/or modify
12
+ it under the terms of the GNU Lesser General Public License as published by
13
+ the Free Software Foundation, either version 3 of the License, or
14
+ (at your option) any later version.
15
+
16
+ Origami is distributed in the hope that it will be useful,
17
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
18
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
+ GNU Lesser General Public License for more details.
20
+
21
+ You should have received a copy of the GNU Lesser General Public License
22
+ along with Origami. If not, see <http://www.gnu.org/licenses/>.
23
+
24
+ =end
25
+
26
+ module Origami
27
+
28
+ module Template
29
+
30
+ class XMLForm < XDP::Package
31
+ def initialize(script = "")
32
+ super()
33
+
34
+ self.root.add_element(create_config_packet)
35
+ self.root.add_element(create_template_packet(script))
36
+ self.root.add_element(create_datasets_packet)
37
+ end
38
+
39
+ def create_config_packet
40
+ config = XDP::Packet::Config.new
41
+
42
+ present = config.add_element(XFA::Element.new("present"))
43
+ pdf = present.add_element(XFA::Element.new("pdf"))
44
+ interactive = pdf.add_element(XFA::Element.new("interactive"))
45
+ interactive.text = 1
46
+
47
+ config
48
+ end
49
+
50
+ def create_template_packet(script)
51
+ template = XDP::Packet::Template.new
52
+
53
+ form1 = template.add_subform(:layout => 'tb', :name => 'form1')
54
+ form1.add_pageSet
55
+ form1.add_event(:activity => 'initialize', :name => 'event__ready').
56
+ add_script(:contentType => 'application/x-formcalc').
57
+ text = script
58
+
59
+ subform = form1.add_subform
60
+
61
+ button = subform.add_field(:name => 'Button1')
62
+ button.add_ui.add_button(:highlight => 'inverted')
63
+ btncaption = button.add_caption
64
+ btncaption.add_value.add_text.text = "Send!"
65
+ btncaption.add_para(:vAlign => 'middle', :hAlign => 'center')
66
+ button.add_bind(:match => 'none')
67
+ button.add_event(:activity => 'click', :name => 'event__click').
68
+ add_script(:contentType => 'application/x-formcalc').
69
+ text = script
70
+
71
+ txtfield = subform.add_field(:name => 'TextField1')
72
+ txtfield.add_ui.add_textEdit.add_border.add_edge(:stroke => 'lowered')
73
+
74
+ template
75
+ end
76
+
77
+ def create_datasets_packet
78
+ datasets = XDP::Packet::Datasets.new
79
+ data = datasets.add_element(XDP::Packet::Datasets::Data.new)
80
+
81
+ data.
82
+ add_element(XFA::Element.new('form1')).
83
+ add_element(XFA::Element.new('TextField1')).
84
+ text = '$host.messageBox("test")'
85
+
86
+ datasets
87
+ end
88
+ end
89
+
90
+ end
91
+
92
+ end
@@ -0,0 +1,28 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIE0zCCA7ugAwIBAgIJAPsOg8mXiWmIMA0GCSqGSIb3DQEBBQUAMIGhMQswCQYD
3
+ VQQGEwJGUjEWMBQGA1UECBMNSWxlLWRlLUZyYW5jZTEOMAwGA1UEBxMFUGFyaXMx
4
+ DzANBgNVBAoTBlNvZ2V0aTENMAsGA1UECxMERVNFQzEaMBgGA1UEAxQRR3VpbGxh
5
+ dW1lIERlbHVncoIxLjAsBgkqhkiG9w0BCQEWH2RhcmtwaG9lbml4QGJpbmFyeS1y
6
+ ZXZlcnNlci5vcmcwHhcNMDgwODIwMTIyMTMxWhcNMTgwODE4MTIyMTMxWjCBoTEL
7
+ MAkGA1UEBhMCRlIxFjAUBgNVBAgTDUlsZS1kZS1Gcm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Y-----
@@ -0,0 +1,32 @@
1
+ require 'test/unit'
2
+
3
+ class TC_Actions < Test::Unit::TestCase
4
+ def setup
5
+ @target = PDF.new
6
+ @page = Page.new
7
+ @action = Action::JavaScript.new "app.alert(null);"
8
+ end
9
+
10
+ # def teardown
11
+ # end
12
+
13
+ def test_pdf_actions
14
+ @target.onDocumentOpen @action
15
+ @target.onDocumentClose @action
16
+ @target.onDocumentPrint @action
17
+
18
+ assert_equal @target.Catalog.OpenAction, @action
19
+ assert_equal @target.Catalog.AA.WC, @action
20
+ assert_equal @target.Catalog.AA.WP, @action
21
+ end
22
+
23
+ def test_page_actions
24
+
25
+ @page.onOpen @action
26
+ @page.onClose @action
27
+
28
+ assert_equal @page.AA.O, @action
29
+ assert_equal @page.AA.C, @action
30
+ end
31
+
32
+ end
@@ -0,0 +1,85 @@
1
+ require 'test/unit'
2
+ require 'stringio'
3
+
4
+ class TC_Annotations< Test::Unit::TestCase
5
+ def setup
6
+ @target = PDF.new
7
+ @page = Page.new
8
+ @action = Action::JavaScript.new "app.alert(null);"
9
+ @output = StringIO.new
10
+ end
11
+
12
+ # def teardown
13
+ # end
14
+
15
+ def test_annotations
16
+
17
+ circle = Annotation::Circle.new
18
+ square = Annotation::Square.new
19
+ text = Annotation::Text.new
20
+ link = Annotation::Link.new
21
+ file = Annotation::FileAttachment.new
22
+ screen = Annotation::Screen.new
23
+ sound = Annotation::Sound.new
24
+ pushbutton = Annotation::Widget::PushButton.new
25
+ checkbox = Annotation::Widget::CheckBox.new
26
+ radio = Annotation::Widget::Radio.new
27
+ edit = Annotation::Widget::Text.new
28
+ combo = Annotation::Widget::ComboBox.new
29
+ list = Annotation::Widget::ListBox.new
30
+ sig = Annotation::Widget::Signature.new
31
+
32
+ @target.append_page @page
33
+
34
+ assert_nothing_raised do
35
+ @page.add_annot circle
36
+ @page.add_annot square
37
+ @page.add_annot text
38
+ @page.add_annot link
39
+ @page.add_annot file
40
+ @page.add_annot screen
41
+ @page.add_annot sound
42
+ @page.add_annot pushbutton
43
+ @page.add_annot checkbox
44
+ @page.add_annot radio
45
+ @page.add_annot edit
46
+ @page.add_annot combo
47
+ @page.add_annot list
48
+ @page.add_annot sig
49
+ end
50
+
51
+ assert_nothing_raised do
52
+ @target.save(@output)
53
+ end
54
+ end
55
+
56
+ def test_annotation_actions
57
+
58
+ screen = Annotation::Screen.new
59
+
60
+ @page.add_annot screen
61
+
62
+ screen.onMouseOver @action
63
+ screen.onMouseOut @action
64
+ screen.onMouseDown @action
65
+ screen.onMouseUp @action
66
+ screen.onFocus @action
67
+ screen.onBlur @action
68
+ screen.onPageOpen @action
69
+ screen.onPageClose @action
70
+ screen.onPageVisible @action
71
+ screen.onPageInvisible @action
72
+
73
+ assert_equal screen.AA.E, @action
74
+ assert_equal screen.AA.X, @action
75
+ assert_equal screen.AA.D, @action
76
+ assert_equal screen.AA.U, @action
77
+ assert_equal screen.AA.Fo, @action
78
+ assert_equal screen.AA.Bl, @action
79
+ assert_equal screen.AA.PO, @action
80
+ assert_equal screen.AA.PC, @action
81
+ assert_equal screen.AA.PV, @action
82
+ assert_equal screen.AA.PI, @action
83
+ end
84
+
85
+ end
@@ -0,0 +1,37 @@
1
+ require 'test/unit'
2
+ require 'stringio'
3
+
4
+ class TC_Pages < Test::Unit::TestCase
5
+ def setup
6
+ @target = PDF.new
7
+ @output = StringIO.new
8
+ end
9
+
10
+ # def teardown
11
+ # end
12
+
13
+ def test_appendpage
14
+ p1, p2, p3 = Page.new, Page.new, Page.new
15
+
16
+ assert_nothing_raised do
17
+ @target.append_page p1, p2, p3
18
+ end
19
+
20
+ assert_equal @target.pages.size, 3
21
+
22
+ assert_equal @target.pages[0], p1
23
+ assert_equal @target.pages[1], p2
24
+ assert_equal @target.pages[2], p3
25
+
26
+ assert_equal @target.Catalog.Pages, p1.Parent
27
+ assert_equal @target.Catalog.Pages, p2.Parent
28
+ assert_equal @target.Catalog.Pages, p3.Parent
29
+
30
+ assert_nothing_raised do
31
+ @target.save(@output)
32
+ end
33
+
34
+ assert_equal @target.Catalog.Pages.Count, 3
35
+ end
36
+
37
+ end