[reportlab-users] Am I allowed to implement feature like pageCatcher.copyPages in ReportLab Toolkit ?

Dinu Gherman gherman at darwin.in-berlin.de
Wed Oct 8 05:08:31 EDT 2008


KLEIN Stéphane:


> I look for implement a feature like pageCatcher.copyPages in ReportLab

> library. I wonder if it's forbidden ? Why this question ? because this

> feature conflict with commercial PageCatcher feature.

>

> About implementation, I've read PyPDF (http://pybrary.net/pyPdf/)

> source

> code and I understand I need to implement read capability in

> PDFDictionnary... like PyPDF Dictionnary and other basic object. I

> need

> implement also something like pyPDF.PdfFileReader.



Funny question. I'm pretty sure some people on this list have
written their own PageCatcher-like modules. I think all of it
could be more or less simply replaced with something else, and
it surely is an interesting challenge. In fact, I'm doing it
partly for my own projects, here's a quick example (also based
on pyPdf) of some randomly layouted pages:

http://tinyurl.com/4cp3wp

which takes only a few lines of code, once you have the approp-
riate flowable installed:

[...]
srcPath = "diagradoc.pdf"
destPath = "diagradoc6rand.pdf"
imgWidth = 4*cm
miniSize = (imgWidth, imgWidth*1.4142)
canv = Canvas(destPath, pagesize=PAGESIZE)
for i in range(6):
pp = PdfPage(srcPath, i, destPath, destSize=miniSize)
x = random.random() * (PAGESIZE[0] - imgWidth)
y = random.random() * (PAGESIZE[1] - imgWidth*1.4142)
pp.drawOn(canv, x, y)
canv.showPage()
canv.save()

The nice thing, of course, is that it is a flowable which can
be used with Platypus. I have already posted an example of this
some time ago on this list.

In practice different projects have different needs and it's un-
likely somebody will come up with the grand unified solution.
Maybe this is the reason why, historically, PageCatcher has a
rather strange mix of functionality.

Regards,

Dinu



More information about the reportlab-users mailing list