[reportlab-users] links to other pdfs ...
Larry Bates
reportlab-users@reportlab.com
Thu, 24 Jun 2004 08:38:50 -0500
Below is some code that allows you to imbed any http://
link in .PDF file. This could point to .PDF (either
locally with file:// or remotely with http://.
Hope it helps.
Larry Bates
Syscon, Inc.
def URLLinkAbsolute0(canv, url, rect, border=[0,0,0], contents="click here"):
"""
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.
"""
from reportlab.pdfbase.pdfdoc import PDFDictionary, PDFName, PDFArray,
PDFString
ann = PDFDictionary()
ann["Type"] = PDFName("Annot")
ann["Subtype"] = PDFName("Link")
ann["Rect"] = PDFArray(rect) # the whole page for testing
ann["Border"] = PDFArray(border)
ann["Contents"] = PDFString(contents)
A = PDFDictionary()
#A["Type"] = PDFName("Action") # not needed?
ann["H"] = PDFName("I") # invert
A["S"] = PDFName("URI")
A["URI"] = PDFString(url)
ann["A"] = A
canv._addAnnotation(ann)
def test():
from reportlab.pdfgen import canvas
fn = "c:\\temp\\urltest.pdf"
c = canvas.Canvas(fn)
URLLinkAbsolute0(c, "http://www.alsde.edu", [72,638,256,652])
c.drawString(73,639, "http://www.alsde.edu")
c.rect(72,638,184,14)
c.save()
print "wrote", fn
if __name__=="__main__":
test()
-----Original Message-----
From: reportlab-users-admin@reportlab.com
[mailto:reportlab-users-admin@reportlab.com]On Behalf Of
reportlab-users-request@reportlab.com
Sent: Thursday, June 24, 2004 12:07 AM
To: reportlab-users@reportlab.com
Subject: reportlab-users digest, Vol 2 #142 - 1 msg
Send reportlab-users mailing list submissions to
reportlab-users@reportlab.com
To subscribe or unsubscribe via the World Wide Web, visit
http://two.pairlist.net/mailman/listinfo/reportlab-users
or, via email, send a message with subject or body 'help' to
reportlab-users-request@reportlab.com
You can reach the person managing the list at
reportlab-users-admin@reportlab.com
When replying, please edit your Subject line so it is more specific
than "Re: Contents of reportlab-users digest..."
Today's Topics:
1. links to other pdfs ... (Jesse David Andrews)
--__--__--
Message: 1
From: "Jesse David Andrews" <Jesse@uky.edu>
To: reportlab-users@reportlab.com
Date: Wed, 23 Jun 2004 02:05:18 -0400
Subject: [reportlab-users] links to other pdfs ...
Reply-To: reportlab-users@reportlab.com
Hello,
I am just starting to get to know reportlab, and it has been very good so =
far. I am just having an issue creating "links" that either switch the c=
urrent document or open another document in another adobe window. Maybe =
I am not reading the manual correctly, but it appears that this functiona=
lity isn't there yet. I don't really know PDF specs, but have programmed=
python and postscript before, so I might be able to impliment it if it c=
urrently doesn't exist (although hints about how to do it would be greatl=
y appreciated)
Thanks,
Jesse
--__--__--
_______________________________________________
reportlab-users mailing list
reportlab-users@reportlab.com
http://two.pairlist.net/mailman/listinfo/reportlab-users
End of reportlab-users Digest