Skip to main content

Embed full PDF papers into a Typst document, preserving selectable text and links.

Project description

embedpaper

Embed full PDF papers into a Typst document, preserving selectable text and links.

Typst 0.15's native image() can embed PDF pages full-width with selectable text, but it drops link annotations. embedpaper restores them: a Typst function places each page and records where it landed, and a small CLI re-creates the source PDF's citation, cross-reference, and URI links on the compiled output.

Install

uvx embedpaper --help

Requires uv and the Typst CLI on your PATH.

Usage

  1. Import embedpaper.typ and call it inside a page for each PDF you want to embed:

    #import "embedpaper.typ": embedpaper
    
    #page[
      #embedpaper("papers/example.pdf", 12)
    ]
    

    pages is the PDF's page count (Typst can't query it, so pass it explicitly). Pass width: to scale the paper against the page width (default 100%).

  2. Compile, then run embedpaper to restore the links:

    typst compile document.typ
    uvx embedpaper document.typ
    

    This reads the placement metadata Typst embedded during compilation and incrementally saves document.pdf with each source link remapped onto its embedded page.

  3. Optionally, verify the result:

    uvx embedpaper document.typ --audit
    

    The audit re-derives where every link should point from the source PDFs and checks the compiled document against it — link count parity, correct destinations, and "Figure N" / "Table N" cross-references — exiting non-zero on any mismatch.

How it works

  • embedpaper.typ places each source page as an image and emits <__paperlink> metadata (filename, source page, output page, and placement rectangle) for every embedded page.
  • embedpaper embed queries that metadata with typst query, then uses PyMuPDF to copy each source page's links onto the matching output page, scaling coordinates and remapping internal destinations to their new page.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

embedpaper-0.1.0.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

embedpaper-0.1.0-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file embedpaper-0.1.0.tar.gz.

File metadata

  • Download URL: embedpaper-0.1.0.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for embedpaper-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0f6bc222ee6117020a9c7d92b630e06bee1ace1404682f36531259ef6e9258fd
MD5 f78ca7fba104b47d79d994ad4e72928d
BLAKE2b-256 0c251a3b7d713140b53bcf189414ee1b3cddf7c0a694a7190e9d860a296a1785

See more details on using hashes here.

File details

Details for the file embedpaper-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: embedpaper-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for embedpaper-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b1cd2d409820dfb637246ab1fcdb3dabfcb44eb4e7e3020bd690a4c39a736b74
MD5 1459126a9b44267d879fc1c6135b3606
BLAKE2b-256 554fbcd67066de13aedc24c1a2f00ec432d83ce8f34e842cd735d68ac96f582e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page