Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add hyperlinks#1691

Open
bluehaoran wants to merge 3 commits intoHopding:masterfrom
bluehaoran:add-hyperlinks
Open

Add hyperlinks#1691
bluehaoran wants to merge 3 commits intoHopding:masterfrom
bluehaoran:add-hyperlinks

Conversation

Copy link

bluehaoran commented Oct 22, 2024 *
edited
Loading

What?

Adds PDFPage.drawLink() so users can add hyperlinks easily.

Why?

I personally needed to add several hyperlinks to a PDF. I added createPageLinkAnnotation per the suggestion in #555, got it working in our project, and then generalised it for broader use.

See also: #555, #691 , #980

How?

This follows @Hopding 's suggestion in #555.

I dug into the PDF Specification to double-check the possible setting for Border and Colour.

I have not provided all possible options; I wanted something simple and working before adding extra options.

Testing?

Added basic Unit test in PDFPage.spec.ts.

New Dependencies?

No.

Screenshots

Suggested Reading?

Yes, read the PDF Spec.

Anything Else?

Nope.

Checklist

  • I read CONTRIBUTING.md.
  • I read MAINTAINERSHIP.md#pull-requests.
  • I added/updated unit tests for my changes.
  • [] I added/updated integration tests for my changes.
  • [] I ran the integration tests.
  • I tested my changes in Node, Deno, and the browser.
  • I viewed documents produced with my changes in Adobe Acrobat, Foxit Reader, Firefox, and Chrome.
  • I added/updated doc comments for any new/modified public APIs.
  • My changes work for both new and existing PDF files.
  • I ran the linter on my changes.

DenisVCode and iahuang reacted with heart emoji
github-actions bot added the needs-triage label Oct 22, 2024
Copy link
Author

bluehaoran commented Oct 22, 2024

PS: the CircleCI build seems to be broken.

Copy link

devNamanG commented Feb 16, 2025

Any updates on this one? It is a helpful feature, and it's been 4 months since the build was broken

folknor added a commit to folknor/pdf-lib that referenced this pull request Jan 29, 2026
Add PDFPage.drawLink() method that creates clickable link annotations.
Links can optionally have visible borders with customizable width and color.

Example usage:
```js
page.drawLink({
url: 'https://pdf-lib.js.org',
x: 50,
y: 50,
width: 200,
height: 20,
borderWidth: 1,
borderColor: rgb(0, 0, 1),
})
```

Fixes Hopding/pdf-lib#1691

Coded by an LLM.
Maxwbh pushed a commit to Maxwbh/pdf-lib that referenced this pull request Jan 31, 2026
Analyzed popular forks and pending PRs to identify potential improvements:
- SVG support (from cantoo-scribe/pdf-lib fork)
- PDF encryption/decryption (from pdf-lib-plus-encrypt fork)
- Incremental save for digital signatures (from pdf-lib-incremental-save)
- Rounded rectangles (from pdfme/pdf-lib fork)
- Hyperlinks support (PR Hopding#1691)
- Form field improvements (PRs Hopding#1748, Hopding#1758)

https://claude.ai/code/session_01T85UagjFeYdf4vUW9pzeyn
Maxwbh mentioned this pull request Jan 31, 2026
14 tasks
Maxwbh added a commit to Maxwbh/pdf-lib that referenced this pull request Jan 31, 2026
Features:
- PDF encryption/decryption (RC4-40/128, AES-128/256) with granular permissions
- Incremental save for digital signature preservation
- Hyperlink annotations (external URLs and internal page navigation)
- Node.js 22 compatibility with TypeScript 5.3, Rollup 4, Jest 29

Breaking changes: None (backward compatible with pdf-lib 1.17.1)

Based on community forks: pdf-lib-plus-encrypt, pdf-lib-incremental-save, PR Hopding#1691

All 668 tests passing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants