def test_twopage():
    s = Stream()
    #s.line(0,0,100,100)
    #s.linewidth(4)
    #s.line(50,50,100,50)
    doc = Document()
    #s.polygon((10,10, 50,10, 50, 50, 10, 50 ))
    s.fgcol(0.0, 0.0, 0.0)
    s.line(0, 0, 100, 100)
    s.ellipse(0, 0, 140, 100)
    s.stroke()
    s.ellipse(100, 100, 80, 40)
    s.stroke()
    s.ellipse(160, 160, 80, 80)
    s.stroke()

    page_id1 = doc.add_page(640, 480)
    doc.add_stream(s, page_id1)
    page_id2 = doc.add_page(640, 480)

    xTest = XObject(
        "\x00\x00\xff\xff\x00\xff\xff\x00\xff\xff\x00\xff\xff\x00\xff\xff\x00\xff\xff\x00\xff\xff\x00\xff\xff\x00\xff",
        3, 3)
    xobject_id = doc.add_xobject(xTest)
    s = Stream()
    #s.line(50,50,50,0)
    s.move(10, 10)
    s.xobject(xobject_id, 0, 0, 640, 480)
    doc.add_stream(s, page_id2)
    f = open("test-twopage.pdf", 'wb')
    f.write(str(doc))
Exemple #2
0
        if len(object.keys()) > 1 :
            obj_dict = obj_dict + "\n>>\n"
        else:
            obj_dict = obj_dict + " >>\n"
        return obj_dict

    def _format_obj_data( self, obj ):
        if obj.__class__ == dict:
            return ""
        return obj.data()

if __name__ == '__main__':
    s = Stream()
    #s.line(0,0,100,100)
    #s.linewidth(4)
    #s.line(50,50,100,50)
    doc = Document()
    #s.polygon((10,10, 50,10, 50, 50, 10, 50 ))
    s.line(0,0,100,100)
    s.ellipse( 0, 0, 140, 100 )
    s.ellipse( 100, 100, 80, 40 )
    s.ellipse( 160, 160, 80, 80 )
    s.stroke()
    font_id = doc.add_font( Font("/Courier")) # Fixme
    s.text( 20, 20, 12, "Hello", 13 )
    s.fill()
    p_id = doc.add_page(640, 480)
    s_id = doc.add_stream( s, p_id )
    f = open("test.pdf", 'wb')
    f.write(str(doc))