acro_that 0.1.3 → 0.1.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 56f6be44d023bdedaf254cc097d18791f284793d0c79c07847fd462c0643cc91
4
- data.tar.gz: b649d290433fac6a6113a74ca47bfde60e31687f6e93b85e30c32053ee416b3a
3
+ metadata.gz: 40016774a590828e59c4c9ea4331a8d170ccd536d7522cbdb193fefda3f28333
4
+ data.tar.gz: bade6f113359d96d1f7c1a85efd7033732350c0b19bf40dd412e104da359aa5a
5
5
  SHA512:
6
- metadata.gz: b27c5ec88a2cfdec49750d9d3316979c90c0815461eb6281b4cf602dc6533c8761c8fba7fb49407256b9ade87f2f3731e8f9d121c4ef089d08be2901107cc295
7
- data.tar.gz: f1b41cef40049564af8f081547460d72e787a721f676db4c80cd74eb21844b48364ac3b871e6ad2839505908d9e5be3b8d643c16812bd91ae6d0e858bcfb51eb
6
+ metadata.gz: 60e6c6afd93cfd8911c0b0a0d4b6b080cb2c8af85a104cf3fd09f8fc7f9ac642999a8d5694c374ad64b71d4aa769f6d8b390cc82829317abd64598aa42e7280f
7
+ data.tar.gz: 31762cf9f6f285edd78976692e9c5bab7a67cf6298a03c8d4208b02927639be29e0d1f4ca1f14c3f1c170b9f617404e0931dc8bbedd17de79fcee5c80035dd29
data/README.md CHANGED
@@ -234,6 +234,32 @@ fields.each do |field|
234
234
  end
235
235
  ```
236
236
 
237
+ #### `#list_pages`
238
+ Returns an array of `Page` objects representing all pages in the document. Each `Page` object provides page information and methods to add fields to that specific page.
239
+
240
+ ```ruby
241
+ pages = doc.list_pages
242
+ pages.each do |page|
243
+ puts "Page #{page.page_number}: #{page.width}x#{page.height}"
244
+ end
245
+
246
+ # Add fields to specific pages - the page is automatically set!
247
+ first_page = pages[0]
248
+ first_page.add_field("Name", x: 100, y: 700, width: 200, height: 20)
249
+
250
+ second_page = pages[1]
251
+ second_page.add_field("Email", x: 100, y: 650, width: 200, height: 20)
252
+ ```
253
+
254
+ **Page Object Methods:**
255
+ - `page.page_number` - Returns the page number (1-indexed)
256
+ - `page.width` - Page width in points
257
+ - `page.height` - Page height in points
258
+ - `page.ref` - Page object reference `[obj_num, gen_num]`
259
+ - `page.metadata` - Hash containing page metadata (rotation, boxes, etc.)
260
+ - `page.add_field(name, options)` - Add a field to this page (page number is automatically set)
261
+ - `page.to_h` - Convert to hash for backward compatibility
262
+
237
263
  #### `#add_field(name, options)`
238
264
  Adds a new form field to the document. Options include:
239
265
  - `value`: Default value for the field (String)
@@ -179,13 +179,14 @@ module AcroThat
179
179
  contents_refs: contents_refs
180
180
  }
181
181
 
182
- pages << {
183
- page: index + 1, # Page number starting at 1
184
- width: width,
185
- height: height,
186
- ref: ref,
187
- metadata: metadata
188
- }
182
+ pages << Page.new(
183
+ index + 1, # Page number starting at 1
184
+ width,
185
+ height,
186
+ ref,
187
+ metadata,
188
+ self # Pass document reference
189
+ )
189
190
  end
190
191
 
191
192
  pages
@@ -0,0 +1,91 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AcroThat
4
+ # Represents a page in a PDF document
5
+ class Page
6
+ attr_reader :page, :width, :height, :ref, :metadata, :document
7
+
8
+ def initialize(page, width, height, ref, metadata, document)
9
+ @page = page # Page number (1-indexed)
10
+ @width = width
11
+ @height = height
12
+ @ref = ref # [obj_num, gen_num]
13
+ @metadata = metadata # Hash with :rotate, :media_box, :crop_box, etc.
14
+ @document = document
15
+ end
16
+
17
+ # Add a field to this page
18
+ # Options are the same as Document#add_field, but :page is automatically set
19
+ def add_field(name, options = {})
20
+ # Automatically set the page number to this page
21
+ options_with_page = options.merge(page: @page)
22
+ @document.add_field(name, options_with_page)
23
+ end
24
+
25
+ # Get the page number
26
+ def page_number
27
+ @page
28
+ end
29
+
30
+ # Get the page reference [obj_num, gen_num]
31
+ def page_ref
32
+ @ref
33
+ end
34
+
35
+ # Check if page has rotation
36
+ def rotated?
37
+ !@metadata[:rotate].nil? && @metadata[:rotate] != 0
38
+ end
39
+
40
+ # Get rotation angle (0, 90, 180, 270)
41
+ def rotation
42
+ @metadata[:rotate] || 0
43
+ end
44
+
45
+ # Get MediaBox dimensions
46
+ def media_box
47
+ @metadata[:media_box]
48
+ end
49
+
50
+ # Get CropBox dimensions
51
+ def crop_box
52
+ @metadata[:crop_box]
53
+ end
54
+
55
+ # Get ArtBox dimensions
56
+ def art_box
57
+ @metadata[:art_box]
58
+ end
59
+
60
+ # Get BleedBox dimensions
61
+ def bleed_box
62
+ @metadata[:bleed_box]
63
+ end
64
+
65
+ # Get TrimBox dimensions
66
+ def trim_box
67
+ @metadata[:trim_box]
68
+ end
69
+
70
+ # String representation for debugging
71
+ def to_s
72
+ dims = width && height ? " #{width}x#{height}" : ""
73
+ rot = rotated? ? " (rotated #{rotation}°)" : ""
74
+ "#<AcroThat::Page page=#{page}#{dims}#{rot} ref=#{ref.inspect}>"
75
+ end
76
+
77
+ alias inspect to_s
78
+
79
+ # Convert to hash for backward compatibility
80
+ def to_h
81
+ {
82
+ page: @page,
83
+ width: @width,
84
+ height: @height,
85
+ ref: @ref,
86
+ metadata: @metadata
87
+ }
88
+ end
89
+ end
90
+ end
91
+
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AcroThat
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.4"
5
5
  end
data/lib/acro_that.rb CHANGED
@@ -12,6 +12,7 @@ require_relative "acro_that/objstm"
12
12
  require_relative "acro_that/pdf_writer"
13
13
  require_relative "acro_that/incremental_writer"
14
14
  require_relative "acro_that/field"
15
+ require_relative "acro_that/page"
15
16
  require_relative "acro_that/document"
16
17
 
17
18
  # Load actions
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acro_that
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Wynkoop
@@ -116,6 +116,7 @@ files:
116
116
  - lib/acro_that/incremental_writer.rb
117
117
  - lib/acro_that/object_resolver.rb
118
118
  - lib/acro_that/objstm.rb
119
+ - lib/acro_that/page.rb
119
120
  - lib/acro_that/pdf_writer.rb
120
121
  - lib/acro_that/version.rb
121
122
  - publish