コード例 #1
0
    def draw(self, pmlOp, pageNr, canvas, pe):
        # we need to adjust y position since PDF uses baseline of text as
        # the y pos, but pml uses top of the text as y pos. The Adobe
        # standard Courier family font metrics give 157 units in 1/1000
        # point units as the Descender value, thus giving (1000 - 157) =
        # 843 units from baseline to top of text.

        # http://partners.adobe.com/asn/tech/type/ftechnotes.jsp contains
        # the "Font Metrics for PDF Core 14 Fonts" document.

        x = pe.x(pmlOp.x)
        y = pe.y(pmlOp.y) - 0.843 * pmlOp.size

        if pe.doc.tocs and pmlOp.toc:
            key = "id%d" % id(pmlOp)
            canvas.bookmarkPage(key,
                                fit="XYZ",
                                left=pe.x(pmlOp.x),
                                top=pe.y(pmlOp.y))
            canvas.addOutlineEntry(pmlOp.toc.text, key)

        newFont = (pe.getFontNr(pmlOp.flags), pmlOp.size)
        if newFont != pe.currentFont:
            canvas.setFont(*newFont)
            pe.currentFont = newFont

        if pmlOp.angle is None or pmlOp.angle == 0.0:
            canvas.drawString(x, y, pmlOp.text)
        else:
            canvas.saveState()
            canvas.translate(x, y)
            canvas.rotate(pmlOp.angle)
            canvas.drawString(0, 0, pmlOp.text)
            canvas.restoreState()

        if pmlOp.flags & pml.UNDERLINED:

            undLen = fontinfo.getMetrics(pmlOp.flags).getTextWidth(
                pmlOp.text, pmlOp.size)

            # all standard PDF fonts have the underline line 100 units
            # below baseline with a thickness of 50
            undY = y - 0.1 * pmlOp.size

            canvas.setLineWidth(0.05 * pmlOp.size)
            canvas.line(x, undY, x + undLen, undY)
コード例 #2
0
ファイル: pdf.py プロジェクト: HuBandiT/trelby
    def draw(self, pmlOp, pageNr, canvas, pe):
        # we need to adjust y position since PDF uses baseline of text as
        # the y pos, but pml uses top of the text as y pos. The Adobe
        # standard Courier family font metrics give 157 units in 1/1000
        # point units as the Descender value, thus giving (1000 - 157) =
        # 843 units from baseline to top of text.

        # http://partners.adobe.com/asn/tech/type/ftechnotes.jsp contains
        # the "Font Metrics for PDF Core 14 Fonts" document.

        x = pe.x(pmlOp.x)
        y = pe.y(pmlOp.y) - 0.843 * pmlOp.size

        if pe.doc.tocs and pmlOp.toc:
            key = "id%d" % id(pmlOp)
            canvas.bookmarkPage(key,fit="XYZ",left=pe.x(pmlOp.x),top=pe.y(pmlOp.y))
            canvas.addOutlineEntry(pmlOp.toc.text,key)

        newFont = (pe.getFontNr(pmlOp.flags), pmlOp.size)
        if newFont != pe.currentFont:
            canvas.setFont(*newFont)
            pe.currentFont = newFont

	if pmlOp.angle is None or pmlOp.angle == 0.0:
            canvas.drawString(x,y,pmlOp.text)
        else:
            canvas.saveState()
            canvas.translate(x,y)
            canvas.rotate(pmlOp.angle)
            canvas.drawString(0,0,pmlOp.text)
            canvas.restoreState()

        if pmlOp.flags & pml.UNDERLINED:

            undLen = fontinfo.getMetrics(pmlOp.flags).getTextWidth(
                pmlOp.text, pmlOp.size)

            # all standard PDF fonts have the underline line 100 units
            # below baseline with a thickness of 50
            undY = y - 0.1 * pmlOp.size

            canvas.setLineWidth(0.05 * pmlOp.size)
            canvas.line(x, undY, x + undLen, undY)
コード例 #3
0
 def process(self):
     args = dict(self.getAttributeValues())
     canvas = attr.getManager(self, interfaces.ICanvasManager).canvas
     args['left'], args['top'] = canvas.absolutePosition(
         args['x'], args['y'])
     canvas.bookmarkPage(**args)
コード例 #4
0
ファイル: canvas.py プロジェクト: fanzalika/z3c.rml
 def process(self):
     args = dict(self.getAttributeValues())
     canvas = attr.getManager(self, interfaces.ICanvasManager).canvas
     args['left'], args['top'] = canvas.absolutePosition(args['x'], args['y'])
     canvas.bookmarkPage(**args)