Closed MorneL closed 10 months ago
Ah I just figured out it's because I'm setting field_value more than once. Any reason why I wouldn't be allowed to set that multiple times?
Using Field#field_value=
more than once should definitely be possible, I will take a look at it.
If you have time, could you open another issue for " I'm aware of font.on_missing_glyph but we want to completely remove the glyph as replacing it with a different glyph is giving us different strange behaviour.", i.e. what strange behaviour? - Thanks!
@MorneL I have created a small, self-contained example:
require 'hexapdf'
doc = HexaPDF::Document.new
form = doc.acro_form(create: true)
field = form.create_text_field('test')
field.create_widget(doc.pages.add, Rect: [10, 10, 100, 30])
data = "test 😬"
begin
field.field_value = data
rescue HexaPDF::MissingGlyphError => glyph_error
data = 'test'
retry
end
doc.write('gh276.pdf')
This example works as is, i.e. no error is thrown.
Could you provide a self-contained example that shows the problem? My guess is that the used PDF has something to do with the problem.
Using
Field#field_value=
more than once should definitely be possible, I will take a look at it.If you have time, could you open another issue for _" I'm aware of font.on_missingglyph but we want to completely remove the glyph as replacing it with a different glyph is giving us different strange behaviour.", i.e. what strange behaviour? - Thanks!
sure here you go: https://github.com/gettalong/hexapdf/issues/277
@MorneL I have created a small, self-contained example:
require 'hexapdf' doc = HexaPDF::Document.new form = doc.acro_form(create: true) field = form.create_text_field('test') field.create_widget(doc.pages.add, Rect: [10, 10, 100, 30]) data = "test 😬" begin field.field_value = data rescue HexaPDF::MissingGlyphError => glyph_error data = 'test' retry end doc.write('gh276.pdf')
This example works as is, i.e. no error is thrown.
Could you provide a self-contained example that shows the problem? My guess is that the used PDF has something to do with the problem.
I will look at this tomorrow again and give you an update
@MorneL Did you have the chance to look at the problem again and provide a self-contained example?
@MorneL I will close this issue for now. Feel free to open it again with more information or a self-contained example to reproduce the problem.
Hi there,
I'm currently dealing with removing emoji's from strings if the glyphs are not found, I'm aware of font.on_missing_glyph but we want to completely remove the glyph as replacing it with a different glyph is giving us different strange behaviour.
However right now I'm dealing with this issue where I get the following error ONLY when I retry in a rescue. If I run the block inside begin again after the gsub, it's fine, however if I use the retry my document for some reason gets wrapped as a stream.
undefined method `contents=' for #
The screenshot shows that further down the code it doesn't pass any stream, however it returns as a stream 🤷