Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Support replacement_font flag #89

Merged
merged 3 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ pdftk.fill_form '/path/to/form.pdf', 'myform.pdf', {foo: 'bar'}, encrypt: true,

# you can also protect the PDF even from opening by specifying an additional user_pw option:
pdftk.fill_form '/path/to/form.pdf', 'myform.pdf', {foo: 'bar'}, encrypt: true, encrypt_options: 'user_pw secret'

# if you are facing font issues with your pdf, you can specify :replacement_font option:
pdftk.fill_form '/path/to/form.pdf', 'myform.pdf', {foo: 'bar'}, replacement_font: '/path/to/font'
```

Any options shown above can also be set when initializing the PdfForms
Expand All @@ -103,7 +106,8 @@ In case your form's field names contain HTML entities (like

### Non-ASCII Characters (UTF8 etc) are not displayed in the filled out PDF

First, check if the field value has been stored properly in the output PDF using `pdftk output.pdf dump_data_fields_utf8`.
First, try to use the `replacement_font` option and specify the font that's not being displayed.
If it doesn't work, check if the field value has been stored properly in the output PDF using `pdftk output.pdf dump_data_fields_utf8`.

If it has been stored but is not rendered, your input PDF lacks the proper font for your kind of characters. Re-create it and embed any necessary fonts.
If the value has not been stored, there is a problem with filling out the form, either on your side, of with this gem.
Expand Down
3 changes: 3 additions & 0 deletions lib/pdf_forms/pdftk_wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ def append_options(args, local_options = {})
encrypt_options = encrypt_options.split if String === encrypt_options
args << ['encrypt_128bit', 'owner_pw', encrypt_pass, encrypt_options]
end
if option_or_global(:replacement_font, local_options)
args << ['replacement_font', option_or_global(:replacement_font, local_options)]
end
args.flatten!
args.compact!
args
Expand Down