I have app that adding texts for original pdf and generate new pdf.
All is good until i have page that contain different font, then target pdf have no glyphs(boxes instead of characters), when source_doc saved, it displays font properly.
I have tried to .add font to target_doc but it did not added(tried before and after import)
In the target_doc.fonts I can see font loaded in loaded_fonts_cache and in glyphs
Perhaps something to do with how import work but i did not found way :/
Will appreciate if you can point me in right direction ?
Here is part of code:
target_doc = HexaPDF::Document.new
source_doc = HexaPDF::Document.open("source_to_be_filled.pdf")
page = source_doc.pages[0]
canvas = page.canvas(type: :overlay)
# ... some code filling the doc
font_file = "font.ttf"
source_doc.fonts.add(font_file)
canvas.font font_file
canvas.text(text, at: [x, y])
# back to default font
canvas.font(FONT_FAMILY, size: FONT_SIZE)
source_doc.pages.each { |page| target_doc.pages << target_doc.import(page) }
target_doc.write(output_file)
I have app that adding texts for original pdf and generate new pdf. All is good until i have page that contain different font, then target pdf have no glyphs(boxes instead of characters), when
source_doc
saved, it displays font properly.I have tried to
.add
font totarget_doc
but it did not added(tried before and afterimport
) In thetarget_doc.fonts
I can see font loaded inloaded_fonts_cache
and inglyphs
Perhaps something to do with how import work but i did not found way :/
Will appreciate if you can point me in right direction ?
Here is part of code:
https://hexapdf.gettalong.org/examples/merging.html