swftools-common
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Swftools-common] Help to use gfx and rfx in python


From: kgart
Subject: [Swftools-common] Help to use gfx and rfx in python
Date: Sat, 26 Jun 2010 15:11:48 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100423 Thunderbird/3.0.4

Hi,

    I'm a beginner with python and so with swftools python modules.
I would like to make a "pdf2swf" python script that do the same thing than the pdf2swf command. This will be a great example of use of gfx and SWF module for python, and a good start to make a custom output of a swf file.
    But I have no idea how to use these modules.

   I don't find enough Documentation to help me so I try the mailing-list.
At the end of the mail the initial script that correctly run but build an empty swf.

I have understood that i have to do swf.tags += SWF.someNewTag(parameters=value), but where to find a description of the parameter for each tag ? And what are the type of each parameters of every method of the "PassThrough" object ?


Many thanks.

I have this start : (By the way : drawChar is writing drawchar (lower c) in the gfx tutorial, and it make segmentation fault.)

import gfx
import SWF


class CustomOutPut:
    def __init__(self,swf1):
        self.swf=swf1

    def setparameter(self,key,value):
        print "setparameter" ,key,value

    def startclip(self,outline):
        print "startclip"

    def endclip(self):
        print "endclip"

def stroke(self,outline, width, color, capstyle, jointstyle, miterLimit):
        print "stroke"

    def fill(self,outline, color):
        print "fill"

    def fillbitmap(self,outline, image, matrix, colortransform):
        print "fillbitmap"

    def fillgradient(self,outline, gradient, gradienttype, matrix):
        print "fillgradient"

    def addfont(self,font):
        print "addfont "

    def drawChar(self,font, glyph, color, matrix):
        print "drawchar"

    def drawlink(self,outline, url):
        print "drawlink"


gfx.verbose(0)
doc = gfx.open("pdf", "somepdf.pdf")

for pagenr in range(1,doc.pages+1):
    page = doc.getPage(pagenr)
    swf = SWF.create(version=8, bbox=(0,0,page.width,page.width), fps=12)

    output = gfx.PassThrough(CustomOutPut(swf))


    page.render(output)
    print "end"
    swf.save("someswf.swf")






reply via email to

[Prev in Thread] Current Thread [Next in Thread]