Skip to content

ENH: Add writer.pdf_header property (getter and setter)#1038

Merged
MartinThoma merged 10 commits intomainfrom
pdf-version-writer
Jun 29, 2022
Merged

ENH: Add writer.pdf_header property (getter and setter)#1038
MartinThoma merged 10 commits intomainfrom
pdf-version-writer

Conversation

@MartinThoma
Copy link
Copy Markdown
Member

Closes #162

@MartinThoma MartinThoma changed the title ENH: Add writer.pdf_header attribute (getter and setter) ENH: Add writer.pdf_header property (getter and setter) Jun 28, 2022
@codecov
Copy link
Copy Markdown

codecov bot commented Jun 28, 2022

Codecov Report

Merging #1038 (34dfda1) into main (a89ff74) will increase coverage by 0.02%.
The diff coverage is 95.65%.

@@            Coverage Diff             @@
##             main    #1038      +/-   ##
==========================================
+ Coverage   89.59%   89.62%   +0.02%     
==========================================
  Files          24       24              
  Lines        4441     4462      +21     
  Branches      917      922       +5     
==========================================
+ Hits         3979     3999      +20     
  Misses        314      314              
- Partials      148      149       +1     
Impacted Files Coverage Δ
PyPDF2/_reader.py 91.74% <ø> (ø)
PyPDF2/_writer.py 88.75% <92.30%> (+0.04%) ⬆️
PyPDF2/_utils.py 98.14% <100.00%> (+0.12%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0215cc7...34dfda1. Read the comment docs.

Copy link
Copy Markdown
Member

@MasterOdin MasterOdin left a comment

Choose a reason for hiding this comment

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

From the linked issue, should we take the max of version between writer and new page automatically as part of _add_page function, to make usage of this a bit more transparent to users? Simple test for this new functionality could then be:

def test_pdf_header():
    writer = PdfWriter()
    assert writer.pdf_header == b"%PDF-1.3"
    reader = PdfReader(os.path.join(RESOURCE_ROOT, "crazyones.pdf"))
    writer.add_page(reader.pages[0])
    assert writer.pdf_header == b"%PDF-1.5"
    writer.pdf_header = b"%PDF-1.6"
    assert writer.pdf_header == b"%PDF-1.6"

@MartinThoma MartinThoma merged commit eedf0e0 into main Jun 29, 2022
@MartinThoma MartinThoma deleted the pdf-version-writer branch June 29, 2022 20:13
MartinThoma added a commit that referenced this pull request Jun 30, 2022
New Features (ENH):
-  Add writer.pdf_header property (getter and setter) (#1038)

Performance Improvements (PI):
-  Remove b_ call in FloatObject.write_to_stream (#1044)
-  Check duplicate objects in writer._sweep_indirect_references (#207)

Documentation (DOC):
-  How to surppress exceptions/warnings/log messages (#1037)
-  Remove hyphen from lossless (#1041)
-  Compression of content streams (#1040)
-  Fix inconsistent variable names in add-watermark.md (#1039)
-  File size reduction
-  Add CHANGELOG to the rendered docs (#1023)

Maintenance (MAINT):
-  Handle XML error when reading XmpInformation (#1030)
-  Deduplicate Code / add mutmut config (#1022)

Code Style (STY):
-  Use unnecessary one-line function / class attribute (#1043)
-  Docstring formatting (#1033)

Full Changelog: 2.4.0...2.4.1
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.

Allow specifying the PDF file version

2 participants