Skip to content

How to : create a ink annotation from a string #1982

@pulse-mind

Description

@pulse-mind

Hello,

I am trying to convert a string to an ink annotation using a a font.

Why :

  • Because it is not possible to use any font with free text
  • Because stamps annotation does not support image (otherwise I would create an image from text

I created a SVG from text using Cairo :

with cairo.SVGSurface(svg_file_path, 200, 50) as surface:
            # creating a cairo context object for SVG surface
            # using Context method
            Context = cairo.Context(surface)
            # setting color of the context
            Context.set_source_rgb(1, 0, 0)
            # approximate text height
            Context.set_font_size(30)
            # Font Style
            Context.select_font_face("Arial", cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL)
            # position for the text
            Context.move_to(35, 45)
            # displays the text
            Context.text_path("Lorem ipsum")
            # Width of outline
            Context.set_line_width(1)
            # stroke out the color and width property
            Context.fill()

Then I get the SVG path to create a list of list of points :D (as described here https://pymupdf.readthedocs.io/en/latest/recipes-annotations.html#how-to-use-ink-annotations) and I used annot = page.add_ink_annot(all_pixels_svg).
But at the end I have a stroke SVG.
pdf_signed_for_proto_annotations_annot_pdf

Do you have any suggestion, others solutions ?
My goal is to write like an ink signature from a given string.

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