How can pdfplumber process pdf on char level #1017
NewUserHa
started this conversation in
Ask for help with specific PDFs
Replies: 1 comment 2 replies
-
Hi @NewUserHa. I'm not sure I fully understand the questions here; it might help to provide the PDF, the code, and/or screenshots. But at least for the first part, you might try something like this: def adjust_bbox(char):
[your custom logic here]
return new_char
page = pdf.pages[0]
new_chars = list(map(adjust_bbox, page.chars))
text = pdfplumber.utils.extract_text(new_chars) |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Here I have a PDF with non-Unicode custom font (issue 1), and it has the wrong bbox (like 2 times than real) that already overlaps with each character (issue 2).
Currently, I'm using OCR the characters from each font to get correct maps:
to translate them (issue 1):
high_level.extract_pages()
+ walking each object recursive viacustom function
to match to replace to the correct ones.(or can also use
PDFPageInterpreter
with a custompdfminer.converter.TextConverter
class with an overriderender_char()
function)to resolve the overlaps for adding space between characters (issue 2):
LTChar
by 2 or 3 in that customrender_char()
withself.cur_item._objs[-1]
to try to triggerLAParams(word_margin=0.1, all_texts=1)
, but it didn't work.x_tolerance=-2
worked, but it added space between every character.I'm not familiar with how the
LAParams
algorithm works, but in its code, it seems that it only adds space inword_margin
level, andchar_margin
is only for group texts.Thanks
Beta Was this translation helpful? Give feedback.
All reactions