0

Im using borb librarie to attach a xlsx file into a pdf and it works well, but now i want to add an annotation link in some page of the pdf to get into the xlsx file attached

Here is my code that attaches the xlsx file into a pdf:

from borb.pdf import Document
from borb.pdf import PDF
import typing



doc: typing.Optional[Document] = None
with open("input.pdf", "rb") as fh:
    doc = PDF.loads(fh)

# read the xlsx file and embed its contents in the PDF
with open("example.xlsx", "rb") as xlsx_file:
    xlsx_contents = xlsx_file.read()
    doc.add_embedded_file("example.xlsx", xlsx_contents)


# store
with open("output.pdf", "wb") as fh:
    PDF.dumps(fh, doc)

I hope could you help me to create a link to get into the xlsx file.

1 Answers1

0

Unknown if Borb has such abilities but such actions should generally be avoided, normally considered Potentially Unwanted Program (Trojan-PUP) behaviour even if PDF/A-3+XYZ will allow them.

So such hyperlinks, whilst possible are not recommended, as either may not function (many scratched heads) OR more certainly should trigger security responses.

Thus the general approach is simply do the "pdfattach" and remind users how to extract safely into their operating system for AntiVirus testing before running.

Normal permission without any click on page actionability (link is unseen, and inoperable thus file is 100% safe against exploitation) enter image description here

Link is present but not usually actionable in other Readers like Acrobat, MS Edge, Foxit and others. But can be scripted to trigger (re)Action warning of potential Run exploitation.

enter image description here enter image description here

Link runs and Auto replaces PDF Undesired outcome.

enter image description here

K J
  • 8,045
  • 3
  • 14
  • 36