Skip to content

Commit

Permalink
MAINT: Remove decimal (#1608)
Browse files Browse the repository at this point in the history
This is a preparation to completely get rid of decimal at some point. For now, I don't want to break peoples CI.
  • Loading branch information
MartinThoma authored Feb 5, 2023
1 parent 90476ef commit 430f92f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
15 changes: 5 additions & 10 deletions pypdf/_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,8 @@ def addBlankPage(

def insert_blank_page(
self,
width: Optional[decimal.Decimal] = None,
height: Optional[decimal.Decimal] = None,
width: Optional[Union[float, decimal.Decimal]] = None,
height: Optional[Union[float, decimal.Decimal]] = None,
index: int = 0,
) -> PageObject:
"""
Expand Down Expand Up @@ -513,8 +513,8 @@ def insert_blank_page(

def insertBlankPage(
self,
width: Optional[decimal.Decimal] = None,
height: Optional[decimal.Decimal] = None,
width: Optional[Union[float, decimal.Decimal]] = None,
height: Optional[Union[float, decimal.Decimal]] = None,
index: int = 0,
) -> PageObject: # deprecated
"""
Expand Down Expand Up @@ -3112,13 +3112,8 @@ def _create_outline_item(
if color:
if isinstance(color, str):
color = hex_to_rgb(color)
prec = decimal.Decimal("1.00000")
outline_item.update(
{
NameObject("/C"): ArrayObject(
[FloatObject(decimal.Decimal(c).quantize(prec)) for c in color]
)
}
{NameObject("/C"): ArrayObject([FloatObject(c) for c in color])}
)
if italic or bold:
format_flag = 0
Expand Down
2 changes: 1 addition & 1 deletion tests/test_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ def test_colors_in_outline_item():
reader = PdfReader(SAMPLE_ROOT / "004-pdflatex-4-pages/pdflatex-4-pages.pdf")
writer = PdfWriter()
writer.clone_document_from_reader(reader)
purple_rgb = (0.50196, 0.0, 0.50196)
purple_rgb = (0.5019607843137255, 0.0, 0.5019607843137255)
writer.add_outline_item("First Outline Item", page_number=2, color="800080")
writer.add_outline_item("Second Outline Item", page_number=3, color="#800080")
writer.add_outline_item("Third Outline Item", page_number=4, color=purple_rgb)
Expand Down

0 comments on commit 430f92f

Please sign in to comment.