pdf2image icon indicating copy to clipboard operation
pdf2image copied to clipboard

Missing characters like "Ň č ľ 付" when converting a fillable pdf form to image

Open ae-f opened this issue 2 years ago • 6 comments

On running pdftoppm -r 200 -jpeg x.pdf out I am getting error similar to: Syntax Error: AnnotWidget::layoutText, cannot convert U+0147.

Font available on system is DejaVu and poppler-data is also installed.

OS: Ubuntu Pdf2image version: 1.16.0

ae-f avatar Feb 01 '23 05:02 ae-f

It's probably related to the version of poppler you're using. Here's the discussion on a related issue. https://gitlab.freedesktop.org/poppler/poppler/-/issues/1070

jjbiggins avatar Feb 08 '23 13:02 jjbiggins

Hello, thank you for your response. I have tried with v20.12.1 and v23.01.0-0. I am facing the issue similar issue in both the version cannot convert U+0147.

ae-f avatar Feb 08 '23 13:02 ae-f

If you share the PDF causing the issue, I can take a deeper dive investigating.

jjbiggins avatar Feb 08 '23 14:02 jjbiggins

Hello @jjbiggins, I have attached the link to flattened pdf and the output pdf using pdf2image. Please have a look at missing characters when the pdf is converted to image.

Base PDF: https://drive.google.com/file/d/19GmVt1EzuTrhZS21Xxac74Y_VM31Uwdx/view?usp=share_link

Flattened PDF: https://drive.google.com/file/d/1CnoQbkVtIywK7zTyEd0j-MtNY-C54Tw-/view?usp=share_link

Output from pdf2image (windows): https://drive.google.com/file/d/1Hwy2UVBhExXIb3cKQM8QflzL0PqhKnTz/view?usp=share_link

Please open Base PDF and Flattened PDF outside drive PDF viewer so that input fields can be seen.

ae-f avatar Feb 13 '23 05:02 ae-f

@ae-f Were you able to sort this out? I am facing a similar issue as well.

hash3liZer avatar Apr 01 '24 22:04 hash3liZer

For anyone who's stuck at this issue. After spending days on this. This is how i sorted out the problem:

Print the PDF using firefox: (FYI: tried chrome as well but the characters were jumbled up on ubuntu)

from time import sleep
 
from helium import start_firefox
from selenium.webdriver import FirefoxOptions
 
options = FirefoxOptions()
options.add_argument("--headless")
options.set_preference("print.always_print_silent", True)
options.set_preference("print.printer_Mozilla_Save_to_PDF.print_to_file", True)
options.set_preference("print_printer", "Mozilla Save to PDF")
 
driver = start_firefox("file:///path/to/firefox.pdf"), options=options)
 
driver.execute_script("window.print();")
sleep(5)  # Found that a little wait is needed for the print to be rendered otherwise the file will be corrupted
 
driver.quit()

And then use tools like pdftoppm or pdftocairo to flatten the pdf file produced by firefox.

hash3liZer avatar Apr 03 '24 12:04 hash3liZer