[reportlab-users] Embedding JavaScript in PDF and a bug report

Andy Robinson andy at reportlab.com
Thu Apr 5 08:06:50 EDT 2012


Andrew, thanks for this - we will give it a try and roll into our code soon!

Andy Robinson
ReportLab

On 5 Apr 2012, at 06:56, Andrew Cutler <andrew at adlibre.com.au> wrote:


> Quite a few people have asked how to embed JavaScript in ReportLab

> generated PDF's (links #1 #2 #3 below) and I thought I'd post this

> here for the benefit of others.

>

> The solution is quite simple, so it seems. To force a PDF to

> automatically print, embed the following JavaScript:

>

> from reportlab.pdfbase import pdfdoc

> pdfdoc.PDFCatalog.OpenAction =

> '<</S/JavaScript/JS(this.print\({bUI:true,bSilent:false,bShrinkToFit:true}\);)>>'

>

> Now the bug report:

>

> ReportLab 2.5 Has a typo. "OpenActions" should be "OpenAction" as per

> ISO 32000-1:2008.

>

> diff -r tmp/lib/python2.7/site-packages/reportlab/pdfbase/pdfdoc.py

> lib/python2.7/site-packages/reportlab/pdfbase/pdfdoc.py

> 1022c1022

> < Dests Outlines Pages Threads AcroForm Names OpenAction PageMode URI

> ---

>> Dests Outlines Pages Threads AcroForm Names OpenActions PageMode URI

>

> I've also covered this on my blog. Link #4

>

> [#1] http://two.pairlist.net/pipermail/reportlab-users/2008-September/007313.html

> [#2] http://two.pairlist.net/pipermail/reportlab-users/2008-October/007539.html

> [#3] http://two.pairlist.net/pipermail/reportlab-users/2010-February/009309.html

> [#4] http://blog.adlibre.org/2012/04/05/automatically-print-pdf-generated-reportlab/

>

> Cheers,

> --

> Andrew Cutler

> _______________________________________________

> reportlab-users mailing list

> reportlab-users at lists2.reportlab.com

> http://two.pairlist.net/mailman/listinfo/reportlab-users



More information about the reportlab-users mailing list