docpdf 0.1.6 → 0.1.7
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/CHANGELOG.md +6 -0
- data/lib/docpdf/adapters/stampers/hexapdf.rb +15 -3
- data/lib/docpdf/font_files.rb +2 -0
- data/lib/docpdf/input_normalizer.rb +2 -0
- data/lib/docpdf/version.rb +1 -1
- data/lib/docpdf/watermarker.rb +2 -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: 4fa01d67dead11a1f62eb4ff7f6f387599b97ec99d0c91bd5644e60e98fd26a6
|
|
4
|
+
data.tar.gz: 1dc447f55133af1a3ff94ad3aaaeca8014a1560cdd6db5cf2d85ab30220afa1e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3cfa330a65d41f8c24866b04da28d15a795df5c826f2459a9ae1c46c86c470147e92c6ff75952579d3bfd3b6fd4804747a712b868fc829102fab3ece963d0a2d
|
|
7
|
+
data.tar.gz: aa22481e4dfbb0966c9f95b1ecd5924680c491729a3c0ac8b873d2aca03c49b4889a936ce57400a3681594c5ac18078da66c8fa78b20cbed9da211316115f883
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.1.7] - 2026-10-08
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- The HexaPDF stamper raised `ConversionError` on PDFs with spec violations HexaPDF cannot correct, even though viewers render them fine. One example is a tagged PDF exported from Canva with a structure element missing its parent. The stamper now corrects what HexaPDF can and writes the rest as it came in, the way the `hexapdf` CLI does.
|
|
7
|
+
- `DocPDF.convert` raised `NameError: uninitialized constant DocPDF::InputNormalizer::Pathname` on Ruby 3.3 and 3.4 when nothing else had loaded `pathname`. Bundler and Rails both load it, so only plain Ruby scripts were affected. `DocPDF.watermark` with a file path and `font_file` given as a hash hit the same error. DocPDF now requires `pathname` itself.
|
|
8
|
+
|
|
3
9
|
## [0.1.6] - 2026-09-18
|
|
4
10
|
|
|
5
11
|
### Added
|
|
@@ -22,7 +22,7 @@ module DocPDF
|
|
|
22
22
|
page.canvas(type: :overlay).xobject(stamp_form, at: [0, 0]) if page_indices.nil? || page_indices.include?(idx)
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
write_to_string_leniently(doc)
|
|
26
26
|
rescue HexaPDF::Error, Errno::ENOENT => e
|
|
27
27
|
raise ConversionError, "HexaPDF failed to stamp PDF: #{e.message}"
|
|
28
28
|
end
|
|
@@ -125,11 +125,23 @@ module DocPDF
|
|
|
125
125
|
doc.config["font.map"] = (doc.config["font.map"] || {}).merge(name => map)
|
|
126
126
|
end
|
|
127
127
|
|
|
128
|
-
def write_to_string(doc)
|
|
128
|
+
def write_to_string(doc, **write_options)
|
|
129
129
|
io = StringIO.new
|
|
130
|
-
doc.write(io)
|
|
130
|
+
doc.write(io, **write_options)
|
|
131
131
|
io.string
|
|
132
132
|
end
|
|
133
|
+
|
|
134
|
+
# The caller's PDF may break the spec in ways HexaPDF cannot repair, like a
|
|
135
|
+
# tagged PDF whose structure elements have no parent. Viewers open those
|
|
136
|
+
# fine, so correct what can be corrected and write the rest as it came in,
|
|
137
|
+
# the way the hexapdf CLI does. Objects are validated one at a time because
|
|
138
|
+
# Document#validate stops at the first one it cannot correct, and the stamp
|
|
139
|
+
# form only becomes an indirect object when validation reaches its page.
|
|
140
|
+
def write_to_string_leniently(doc)
|
|
141
|
+
doc.trailer.validate(auto_correct: true)
|
|
142
|
+
doc.each { |obj| obj.validate(auto_correct: true) }
|
|
143
|
+
write_to_string(doc, validate: false)
|
|
144
|
+
end
|
|
133
145
|
end
|
|
134
146
|
end
|
|
135
147
|
end
|
data/lib/docpdf/font_files.rb
CHANGED
data/lib/docpdf/version.rb
CHANGED
data/lib/docpdf/watermarker.rb
CHANGED