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

Pdfstream as cmap #283

Merged
merged 15 commits into from
Oct 12, 2019
Merged

Pdfstream as cmap #283

merged 15 commits into from
Oct 12, 2019

Conversation

fakabbir
Copy link
Contributor

Resolves #210 .
The previous work #264 maps "OneByteEncodingH/V" to default CMap initialization. It also ignores the fact that "DLIdent-H/V" is a valid encoding since it isn't mentioned in any PDF Reference the author can dig in.

While looking for the output of pdf2text.py the OneByteEncoding characters were absent denoting that default CMap encoding is ineffective to capture the glyph.

I have added the decode function for OneByteEncoding and also added DLIdent as there is a possibility of this being in many PDF.

Both OneByteEncoding and DLIdent aren't available in any PDF Reference referred.

Copy link
Member

@pietermarsman pietermarsman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a PR with batteries included:

  • new functionality
  • a bit of refactoring
  • added functional tests
  • an example pdf

Wow! Let's merge it!

@@ -140,7 +142,13 @@ def do_keyword(self, pos, token):


NIBBLES = ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.', 'e', 'e-', None, '-')

IDENTITY_ENCODER = {'Identity-H':'Identity-H',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mentioned that DLIdent-* is not in the PDF reference manual. Did you find other pdf documentation that mentions this? If so, you could add a comment that refers to it such that we do not remove DLIdent-* by accident.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't seen any pdf with DLIdent-* but have included it due to its harmless nature. Will also include code comment to avoid DLIdent-* being removed by accident.

return struct.unpack('>%dB' % n, code)
else:
return ()

## UnicodeMap
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a lot of these unnecessary code comments in cmapdb.py. Since you are editing this file anyway, could you remove those? And likewise for pdffont.py?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, Can do that.

@@ -140,12 +130,18 @@ def do_keyword(self, pos, token):


NIBBLES = ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.', 'e', 'e-', None, '-')
"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be nitpicking here: according to pep8 block comments should start with a hashtag instead of using a multi-line string.

Advantage of using hashtag: an intelligent editor can understand that it is a comment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, Done.

@fakabbir
Copy link
Contributor Author

@pietermarsman Hi, Have removed the comments. Can you please review it once again and merge if no other changes are required. :)

@pietermarsman
Copy link
Member

Hi @fakabbir, sorry for the miscommunication but I do not have commit rights right now. I do my bit by reviewing and creating PR's.

I hope to get commit rights soon though.

Copy link
Contributor

@igormp igormp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like euske/pdfminer/pull/179 with some extra features and tests. It'd be great to have this merged asap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants