swftools-common
[Top][All Lists]
Advanced

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

Re: [Swftools-common] Getting PDF information


From: Ricardo Pedroso
Subject: Re: [Swftools-common] Getting PDF information
Date: Wed, 9 Dec 2009 11:53:48 +0000

On Tue, Dec 8, 2009 at 9:53 AM, Shahid Faiz <address@hidden> wrote:
> Hi,
>
> I am using swftools for converting PDF to SWF. In my case, I need to know
> number of pages and width/height of any page in PDF. Right now I execute
> pdf2swf -I command and then parse its output line by line which I feel isn't
> the right way specially for large files. Is there any other way of getting
> this information?
>

You can get info from pdf in several ways. You can use swftools or
other library.
There are many libraries to work with pdf's for many languages.

One way, using python+swftools is, for example:

import sys
import gfx

if len(sys.argv) != 2:
    print "%s <file.pdf>" % sys.argv[0]
    print "Please give me a pdf document"
    print
    sys.exit(0)

#gfx.setparameter("pages", "1")

doc = gfx.open("pdf", sys.argv[1])

npages=[]
for pagenr in range(1, doc.pages+1):
    page = doc.getPage(pagenr)
    npages.append("%dx%d" % (page.width, page.height))

# This will print the info to stdout with the following format:
#Total pages|page1 dimensions;page2 dimensions;.....;pageN dimensions
print "%d|%s" % (doc.pages, ";".join(npages))




reply via email to

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