[reportlab-users] linking a pdf to another pdf

Jesse Andrews reportlab-users@reportlab.com
Thu Nov 11 19:55:16 EST 2004


In acrobat, I wanted my links to load another pdf in acrobat without
it trying to download/...

Here is my code, which I got with help from others on the mailing list
before and then analyzing a pdf created in acrobat pro for the final
info...

def FileLink( canv, url, rect, border=[0,0,0] ):
   """
   url is url to link to, rect is [x1,y1,x2,y2]
   where (x1,y1) is lower left and (x2,y2) upper right corners
   of the annotation rectangle respectively.
   """

   A = PDFDictionary()
   A["S"] = PDFName("Launch")
   A["F"] = PDFString(url)

   ann = PDFDictionary()
   ann["Type"] = PDFName("Annot")
   ann["Subtype"] = PDFName("Link")
   ann["Rect"] = PDFArray(rect) 
   ann["Border"] = PDFArray(border)
   ann["H"] = PDFName("I")    
   ann["A"] = A
   
   canv._addAnnotation(ann)


Hopefully this helps someone, and is this something we should make
report lab do (not that my way is perfect, but it works!)

Jesse



More information about the reportlab-users mailing list