Code Monkey home page Code Monkey logo

merge-pdfs's Introduction

@condorhero/merge-pdfs

NPM version NPM Downloads GitHub stars LICENSE

Merging PDF (with Outline).

Node.js > 18.5.0.Technical support provided by pypdf.

motive

In the Javascript world, when merging multiple PDFs with outlines, the outline will be automatically lost. Neither pdf-lib nor pdfjs solve this problem, and even the PDFCPU that processes PDFs in the GO language world does not support this feature. The reason is that the outline and page are not within the same object of the PDF specification, making copying the outline more complex. However, this feature can be achieved, such as pypdf in the Python language world.

Installation

npm install -D @condorhero/merge-pdfs

Usage

# The default export file name is merged-pdf.pdf
merge-pdfs 1.pdf 2.pdf

# Customize to Export File Name
merge-pdfs 1.pdf 2.pdf -o custom.pdf

# glob: merge some pdf
merge-pdfs pdf/*.pdf -o merged-pdf.pdf

License

MIT

merge-pdfs's People

Contributors

condorheroblog avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

merge-pdfs's Issues

use pnpm has a error: cannot find module `.pnpm/[email protected]/node_modules/pyodide/pyodide.asm.js`

But npm is ok:

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/Users/tom/i/vuepress-plugin/packages/vuepress-plugin-export-pdf-v2/example/vuepress-next/file:/Users/tom/i/vuepress-plugin/node_modules/.pnpm/[email protected]/node_modules/pyodide/pyodide.asm.js' imported from /Users/tom/i/vuepress-plugin/node_modules/.pnpm/[email protected]/node_modules/pyodide/pyodide.mjs
    at new NodeError (node:internal/errors:393:5)
    at finalizeResolution (node:internal/modules/esm/resolve:323:11)
    at moduleResolve (node:internal/modules/esm/resolve:916:10)
    at defaultResolve (node:internal/modules/esm/resolve:1124:11)
    at nextResolve (node:internal/modules/esm/loader:163:28)
    at ESMLoader.resolve (node:internal/modules/esm/loader:841:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
    at ESMLoader.import (node:internal/modules/esm/loader:525:22)
    at importModuleDynamically (node:internal/modules/esm/translators:110:35)
    at importModuleDynamicallyCallback (node:internal/process/esm_loader:35:14) {
  code: 'ERR_MODULE_NOT_FOUND'
}

Occasional errors occur

PythonError: Traceback (most recent call last):
  File "/lib/python3.11/site-packages/micropip/_micropip.py", line 48, in _get_pypi_json
    metadata = await fetch_string(url, fetch_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.11/site-packages/micropip/_compat_in_pyodide.py", line 34, in fetch_string
    return await (await pyfetch(url, **kwargs)).string()
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python311.zip/pyodide/http.py", line 254, in pyfetch
    raise OSError(e.message) from None
OSError: fetch failed

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/lib/python3.11/site-packages/micropip/_micropip.py", line 576, in install
    await transaction.gather_requirements(requirements)
  File "/lib/python3.11/site-packages/micropip/_micropip.py", line 342, in gather_requirements
    await gather(*requirement_promises)
  File "/lib/python3.11/site-packages/micropip/_micropip.py", line 349, in add_requirement
    return await self.add_requirement_inner(Requirement(req))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.11/site-packages/micropip/_micropip.py", line 441, in add_requirement_inner
    metadata = await _get_pypi_json(req.name, self.fetch_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.11/site-packages/micropip/_micropip.py", line 50, in _get_pypi_json
    raise ValueError(
ValueError: Can't fetch metadata for 'pypdf' from PyPI. Please make sure you have entered a correct package name.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.