foliojs/pdfkit

Encryption breaks GoTo Destinations

kmeis002 opened this issue · 0 comments

Bug Report

Description of the problem

Encrypting a PDF containing a GoTo action referencing a destination breaks the link. When converting the GoTo object in object.js, the string is encrypted. However, encryption does not occur in tree.js toString() method. The GoTo object no longer has a valid destination.

I'd be happy to take a stab at a PR if you'd like.

Code sample

const PDFDocument = require('pdfkit');
const fs = require('fs');
const doc = new PDFDocument({userPassword: '123'});

doc.pipe(fs.createWriteStream('./test3.pdf'));

doc.text("testing", { goTo: "heading2" });

doc.addPage();

doc.text("page2", {destination: "heading2"});

doc.end();

Your environment

  • pdfkit version: 0.15.0
  • Node version: v18.19.0
  • Browser version (if applicable):
  • Operating System: Debian (Bookworm)