Skip to content

BUG Inverted characters #164

@nicwest

Description

@nicwest

Describe the bug
When adding text to an existing PDF the characters are inverted.

To Reproduce

  1. download this PDF https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/1145516/sa800man_2023.pdf
  2. rename to SA800.pdf
  3. put it in the same directory as the following script
  4. run the script
from borb.pdf import Paragraph
from borb.pdf import PDF
from borb.pdf.canvas.geometry.rectangle import Rectangle
from decimal import Decimal


def main():
    with open("SA800.pdf", "rb") as in_file_handle:
        doc = PDF.loads(in_file_handle)

    page = doc.get_page(0)

    r = Rectangle(Decimal(0), Decimal(0), Decimal(200), Decimal(200))
    Paragraph("Hello World!", font="Courier").paint(page, r)

    with open("output.pdf", "wb") as pdf_file_handle:
        PDF.dumps(pdf_file_handle, doc)


if __name__ == "__main__":
    main()

Expected behaviour
I would expect this to render "Hello World!" somewhere near the top of the page

Screenshots

Screenshot 2023-05-12 at 13 19 42

Desktop (please complete the following information):

  • OS: mac
  • borb version 2.1.12
  • input PDF: see steps to reproduce

Additional context
The coordinates of the rectangle aren't behaving as I would expect either, increasing the width seemingly makes the rectangle taller, and visa versa.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions