rustpdf 0.4.5-aarch64-linux → 0.4.6-aarch64-linux
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 +4 -4
- data/lib/rustpdf/editable_doc.rb +43 -6
- data/lib/rustpdf/native.rb +6 -0
- data/lib/rustpdf.rb +7 -0
- data/vendor/aarch64-linux/libpdf_ffi.so +0 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 70178a69ffe81e07690514a1c1fe8116707b848b381fbf1ae17952571c9c31ef
|
|
4
|
+
data.tar.gz: 753e07ad832d29f6d638397f10cb0888495fc2a4c56f39b2216d260edf2267b8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 10f7a53e4b0d0f3d76e51ef0aac75654b4a9efda0b355aa84415d2a81a0510079f686d116d9b7ec69ccf9637e4fe8a10349001a85a0a0aa38c238e64341eb5d0
|
|
7
|
+
data.tar.gz: 48d2852ad7d33e705c4e8dac80fb807109704799d270c93367838bc160465792535b8c2d94380e19e5f30dfb307f9624b7f52772db628bab62b56dfde62c5cb3
|
data/lib/rustpdf/editable_doc.rb
CHANGED
|
@@ -167,14 +167,51 @@ module RustPdf
|
|
|
167
167
|
# +page_index+ (0-based), using standard Helvetica at +size+ points in RGB
|
|
168
168
|
# +color+ (each 0..1, default black). +rotation_deg+ rotates the text
|
|
169
169
|
# counter-clockwise about its anchor (match the page rotation to follow a
|
|
170
|
-
# rotated page).
|
|
171
|
-
#
|
|
172
|
-
# page
|
|
173
|
-
|
|
170
|
+
# rotated page). +align+ (RustPdf::Align, default LEFT) shifts the start
|
|
171
|
+
# point along the baseline direction by the text width for RIGHT/CENTER
|
|
172
|
+
# alignment. Coordinates are in the page's VISIBLE space (origin lower-left,
|
|
173
|
+
# y up), regardless of the page's /Rotate. Returns whether the page existed.
|
|
174
|
+
def place_text(page_index, x, y, text, size = 12.0, color = [0.0, 0.0, 0.0], rotation_deg = 0.0,
|
|
175
|
+
align: Align::LEFT)
|
|
174
176
|
r, g, b = color
|
|
175
177
|
found = RustPdf.out_int do |buf|
|
|
176
|
-
Native.call("
|
|
177
|
-
size.to_f, r.to_f, g.to_f, b.to_f, rotation_deg.to_f, buf)
|
|
178
|
+
Native.call("pdf_editable_place_text_aligned", ptr, page_index, x.to_f, y.to_f, text,
|
|
179
|
+
size.to_f, r.to_f, g.to_f, b.to_f, rotation_deg.to_f, align, buf)
|
|
180
|
+
end
|
|
181
|
+
found != 0
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
# Mask a placeholder: fill an opaque background box +[x, y, x+width,
|
|
185
|
+
# y+height]+ in +bg_color+ (each 0..1, default white), then write +text+
|
|
186
|
+
# over it using standard Helvetica at +size+ points in +text_color+ (each
|
|
187
|
+
# 0..1, default black), horizontally aligned per +align+ (RustPdf::Align,
|
|
188
|
+
# default LEFT) and vertically centered within the box. Saves hand-computing
|
|
189
|
+
# the baseline when stamping a real value over a placeholder. Coordinates are
|
|
190
|
+
# in the page's VISIBLE space (origin lower-left, y up). Returns whether the
|
|
191
|
+
# page existed.
|
|
192
|
+
def masked_text(page_index, x, y, width, height, text, size = 12.0,
|
|
193
|
+
text_color = [0.0, 0.0, 0.0], bg_color = [1.0, 1.0, 1.0],
|
|
194
|
+
align: Align::LEFT)
|
|
195
|
+
tr, tg, tb = text_color
|
|
196
|
+
br, bg, bb = bg_color
|
|
197
|
+
found = RustPdf.out_int do |buf|
|
|
198
|
+
Native.call("pdf_editable_masked_text", ptr, page_index, x.to_f, y.to_f,
|
|
199
|
+
width.to_f, height.to_f, text, size.to_f,
|
|
200
|
+
tr.to_f, tg.to_f, tb.to_f, br.to_f, bg.to_f, bb.to_f, align, buf)
|
|
201
|
+
end
|
|
202
|
+
found != 0
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
# Stamp an +image+ (PNG or JPEG bytes; the core dispatches on the signature)
|
|
206
|
+
# onto page +page_index+ (0-based), with its lower-left corner at (+x+, +y+),
|
|
207
|
+
# scaled to +width+ x +height+ points and rotated +rotation_deg+ degrees
|
|
208
|
+
# counter-clockwise about that corner. Coordinates are in the page's VISIBLE
|
|
209
|
+
# space (origin lower-left, y up), regardless of the page's /Rotate. Returns
|
|
210
|
+
# whether the page existed.
|
|
211
|
+
def draw_image(page_index, image, x, y, width, height, rotation_deg = 0.0)
|
|
212
|
+
found = RustPdf.out_int do |buf|
|
|
213
|
+
Native.call("pdf_editable_draw_image", ptr, page_index, image, image.bytesize,
|
|
214
|
+
x.to_f, y.to_f, width.to_f, height.to_f, rotation_deg.to_f, buf)
|
|
178
215
|
end
|
|
179
216
|
found != 0
|
|
180
217
|
end
|
data/lib/rustpdf/native.rb
CHANGED
|
@@ -78,6 +78,7 @@ module RustPdf
|
|
|
78
78
|
"pdf_editable_save" => [[VP, VP], I],
|
|
79
79
|
|
|
80
80
|
"pdf_extract_text" => [[VP, SZ, VP, VP], I],
|
|
81
|
+
"pdf_extract_page_text" => [[VP, SZ, SZ, VP, VP], I],
|
|
81
82
|
"pdf_extract_images_to_dir" => [[VP, SZ, VP, VP], I],
|
|
82
83
|
"pdf_render_page_to_png" => [[VP, SZ, SZ, D, VP, VP], I],
|
|
83
84
|
"pdf_page_count" => [[VP, SZ, VP], I],
|
|
@@ -129,6 +130,11 @@ module RustPdf
|
|
|
129
130
|
"pdf_inspect_json" => [[VP, SZ, VP, VP], I],
|
|
130
131
|
"pdf_editable_fill_rect" => [[VP, I, D, D, D, D, D, D, D, D, VP], I],
|
|
131
132
|
"pdf_editable_place_text" => [[VP, I, D, D, VP, D, D, D, D, D, VP], I],
|
|
133
|
+
"pdf_editable_place_text_aligned" => [[VP, I, D, D, VP, D, D, D, D, D, I, VP], I],
|
|
134
|
+
"pdf_editable_masked_text" => [[VP, I, D, D, D, D, VP, D, D, D, D, D, D, D, I, VP], I],
|
|
135
|
+
# Issue #50: stamp a PNG/JPEG image onto an existing page. The image bytes
|
|
136
|
+
# cross as the (uint8_t* data, uintptr_t len) pair, like pdf_editable_load.
|
|
137
|
+
"pdf_editable_draw_image" => [[VP, I, VP, SZ, D, D, D, D, D, VP], I],
|
|
132
138
|
}.freeze
|
|
133
139
|
|
|
134
140
|
def lib
|
data/lib/rustpdf.rb
CHANGED
|
@@ -228,6 +228,13 @@ module RustPdf
|
|
|
228
228
|
.force_encoding(Encoding::UTF_8)
|
|
229
229
|
end
|
|
230
230
|
|
|
231
|
+
# Extract the text of a single 0-based +page_index+ (Unicode via ToUnicode),
|
|
232
|
+
# without building an intermediate one-page document.
|
|
233
|
+
def extract_page_text(pdf, page_index)
|
|
234
|
+
take_bytes { |pp, pn| Native.call("pdf_extract_page_text", pdf, pdf.bytesize, page_index, pp, pn) }
|
|
235
|
+
.force_encoding(Encoding::UTF_8)
|
|
236
|
+
end
|
|
237
|
+
|
|
231
238
|
# Extract every raster image into +dir+ (JPEG verbatim as .jpg, others as
|
|
232
239
|
# .png; files named page{N}_{name}.{ext}). Returns the number written.
|
|
233
240
|
def extract_images_to_dir(pdf, dir)
|
|
Binary file
|