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

Sel fontinfields #2064

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from
Draft

Sel fontinfields #2064

wants to merge 18 commits into from

Conversation

pubpub-zz
Copy link
Collaborator

@pubpub-zz pubpub-zz commented Aug 4, 2023

add capability to change font and size
closes #2253

@codecov
Copy link

codecov bot commented Aug 4, 2023

Codecov Report

Patch coverage: 81.81% and project coverage change: -0.02% ⚠️

Comparison is base (c04a6bb) 94.17% compared to head (defdcd4) 94.16%.
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2064      +/-   ##
==========================================
- Coverage   94.17%   94.16%   -0.02%     
==========================================
  Files          41       41              
  Lines        7333     7370      +37     
  Branches     1442     1456      +14     
==========================================
+ Hits         6906     6940      +34     
- Misses        266      267       +1     
- Partials      161      163       +2     
Files Changed Coverage Δ
pypdf/_writer.py 87.83% <80.48%> (+0.02%) ⬆️
pypdf/_cmap.py 94.40% <100.00%> (+0.06%) ⬆️

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pubpub-zz pubpub-zz marked this pull request as draft August 13, 2023 07:45
@pubpub-zz
Copy link
Collaborator Author

@MartinThoma

I still tring to find a way to add capability to introduce full range TTF into the pdf

@pubpub-zz
Copy link
Collaborator Author

@Lucas-C
Can you have a look on this PR : I'm having troubles to append the TTF font. help/advices would be welcomed

@MartinThoma MartinThoma added the help wanted We appreciate help everywhere - this one might be an easy start! label Sep 24, 2023
@pubpub-zz
Copy link
Collaborator Author

@Lucas-C
do you have any advices?

@Lucas-C
Copy link
Member

Lucas-C commented Oct 13, 2023

Hi @pubpub-zz!

Unless one of the other maintainers answers you over the week-end,
I'll get back to you on Monday.

Comment on lines +933 to +934
# for x in range(32):
# enc = enc.replace(bytes((x,)),b"\%03o"%x)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe those debug lines should be removed before merging this PR?

font_full_rev.get(c, c.encode("utf-16-be")) for c in line
]
if any(len(c) >= 2 for c in enc_line):
ap_stream += b"<" + (b"".join(enc_line)).hex().encode() + b"> Tj\n"
Copy link
Member

Choose a reason for hiding this comment

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

Codecov reports that this line is never evaluated in pypdf test suite:
do you think a unit test could be added to cover this case?

@@ -934,8 +988,14 @@ def update_page_form_field_values(
Args:
page: Page reference from PDF writer where the
annotations and field data will be updated.
fields: a Python dictionary of field names (/T) and text
values (/V)
fields: a Python dictionary of :
Copy link
Member

Choose a reason for hiding this comment

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

Maybe the type of the fields parameter on line 978 should reflect those options?

Copy link
Member

@Lucas-C Lucas-C left a comment

Choose a reason for hiding this comment

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

I made a few comments, but overall this seems like a great PR to me!

Maybe you should also include a mention of this change in CHANGELOG.md
& add an extra example in docs/user/forms.md?

writer = PdfWriter(clone_from=RESOURCE_ROOT / "FormTestFromOo.pdf")
writer.update_page_form_field_values(
writer.pages[0],
{"Text1": ("Text", "", 5), "Text2": ("Text", "/F1", 15)},
Copy link
Member

Choose a reason for hiding this comment

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

I tested opening this PDF document with tow different readers:

  • with Sumatra PDF Reader, everything works well
  • with Adobe Acrobat Reader, with "all features enabled", the 2nd text is rendered as dots only:
AdobeAcrobatReader-pr-2064 I wonder if that is really normal...

@pubpub-zz
Copy link
Collaborator Author

@Lucas-C
This PR currently fails: I have not been able to properly append the TTF font. do you have any link on how the CID and GID are working and globally translated from utf . Same about widths?

@MartinThoma
Copy link
Member

@pubpub-zz There wasn't an update in this PR in a long time + there are several merge conflicts. Should we close the PR?

@pubpub-zz
Copy link
Collaborator Author

No, I will try to rework on it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted We appreciate help everywhere - this one might be an easy start!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Is it possible to set font while filling fields of for using PDFWriter class?
3 participants