Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
345 views
in Technique[技术] by (71.8m points)

python - Link Text for Watermark Using ReportLab

Currently I am writing a watermark to PDF documents using ReportLab and PyPDF2.

I have the following code which generates the watermark text:

self.packet = StringIO.StringIO()
self.canvas = canvas.Canvas(self.packet, pagesize=letter)

self.canvas.setFont('Helvetica', 6)
self.canvas.drawString(150, 5, self.text)
self.canvas.save()
self.packet.seek(0)

return PdfFileReader(self.packet)

Once it returns the watermark, it merges it into each page of the original pdf "file" using the following:

pdf_reader = PdfFileReader(file)
pdf_writer = PdfFileWriter()
for page in range(pdf_reader.numPages):
    page_object = self.add_watermark(pdf_reader.getPage(page))
    pdf_writer.addPage(page_object)

I'm wondering how I can modify this to write a clickable link to the document, rather than just text.

question from:https://stackoverflow.com/questions/65877602/link-text-for-watermark-using-reportlab

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...