コード例 #1
0
    def sign_scale_and_locate(self, xy, page_w, page_h):

        sign_share_x, sign_share_y = xy

        sign_pdf = PageMerge().add(self.sign_page.copy())[0]
        sign_pdf.scale((self.scale) * page_w / sign_pdf.w)
        sign_pdf.y = page_h * sign_share_y - 0.5 * sign_pdf.h
        sign_pdf.x = page_w * sign_share_x

        return sign_pdf
コード例 #2
0
def make_card():
  """Render a message via the API, then composite the render on top of an
  existing template, at the correct position.
  """
  # render the message
  message_render = render_handwritten_msg(HANDWRITING_ID, MESSAGE_TO_RENDER)

  # wrap the render and the template files with pdfrw
  template_pdf = PdfReader('template.pdf')
  message_pdf = PdfReader(fdata=message_render)

  # set up our render as a "stamp" to put on the template
  stamp = PageMerge().add(message_pdf.pages[0])[0]
  # x is the distance from the left edge of the template to the left edge of the stamp:
  stamp.x = OFFSET_X_POINTS
  # y is the distance from the bottom edge of the template to the top edge of the stamp:
  stamp.y = CARD_H_POINTS - OFFSET_Y_POINTS
  pm = PageMerge(template_pdf.pages[0])
  pm.add(stamp)
  pm.render()

  PdfWriter().write('out.pdf', template_pdf)
コード例 #3
0
ファイル: TryNew.py プロジェクト: Hoclay/ForthTry
def make_card():
    """Render a message via the API, then composite the render on top of an
  existing template, at the correct position.
  """
    # render the message
    message_render = render_handwritten_msg(HANDWRITING_ID, MESSAGE_TO_RENDER)

    # wrap the render and the template files with pdfrw
    template_pdf = PdfReader('template.pdf')
    message_pdf = PdfReader(fdata=message_render)

    # set up our render as a "stamp" to put on the template
    stamp = PageMerge().add(message_pdf.pages[0])[0]
    # x is the distance from the left edge of the template to the left edge of the stamp:
    stamp.x = OFFSET_X_POINTS
    # y is the distance from the bottom edge of the template to the top edge of the stamp:
    stamp.y = CARD_H_POINTS - OFFSET_Y_POINTS
    pm = PageMerge(template_pdf.pages[0])
    pm.add(stamp)
    pm.render()

    PdfWriter().write('out.pdf', template_pdf)