Coder Social home page Coder Social logo

karuppiah7890 / easy-pdf-merge Goto Github PK

View Code? Open in Web Editor NEW
85.0 3.0 37.0 23.28 MB

An npm module to merge PDFs. https://www.npmjs.com/package/easy-pdf-merge [ CURRENTLY NOT MAINTAINED ]

JavaScript 100.00%
pdf-merge pdf npm easy-pdf-merge pdf-merger nodejs node

easy-pdf-merge's Introduction

easy-pdf-merge Patreon Paypal

⚠️ CURRENTLY NOT MAINTAINED

easy-pdf-merge is a node module to merge multiple PDFs into a single PDF easily. This module uses Apache PDFBox Library 2.0.21. No special softwares are required for the module to run. But Java 6 or higher must be present.

This project is currently maintained! Contributions through PRs are welcome. I will try to add a contributing guide. If you benefit from this project, buy the original author a cup of coffee by donating through Paypal

Currently only callback style is supported. That is only Async functions are supported.

⚠️ Warning: This module was written as a side project. I don't maintain it anymore. If you are using this in production for some criticial application, do consider checking out the code - it is a very very small module.

Install :

$ npm install --save easy-pdf-merge

Usage :

const merge = require('easy-pdf-merge');

merge(source_files, dest_file_path, function (err) {
    if (err) {
        return console.log(err)
    }
    console.log('Success')
});

source_files must be an array of file paths, with two or more file paths, or the module throws an error accordingly. dest_file path is the destination path for the merged PDF to be saved.

For all files, it is recommended to give absolute paths to avoid possible path based problems in your code. Or, give paths relative to process.cwd(); , which is the current working directory of the process. But be careful when giving relative paths, to avoid bugs.

Example

Using relative file paths

merge(['File One.pdf', 'File Two.pdf'], 'File Ouput.pdf', function (err) {
    if (err) {
        return console.log(err)
    }
    console.log('Successfully merged!')
});

Using absolute file paths

merge(['/home/karuppiah/File One.pdf', '/home/karuppiah/File Two.pdf'], '/home/karuppiah/Desktop/File Ouput.pdf', function (err) {
    if (err) {
        return console.log(err)
    }
    console.log('Successfully merged!')
});

Options

You can pass some options to the merge function, like this

const opts = {
    maxBuffer: 1024 * 500, // 500kb
    maxHeap: '2g' // for setting JVM heap limits to 2GB
};

merge(['File One.pdf', 'File Two.pdf'], 'File Ouput.pdf', opts, function (err) {
    if (err) {
        return console.log(err)
    }
    console.log('Successfully merged!')
});

The default options is this

const defaultOpts = {
    maxBuffer: 1024 * 500, // 500kb
    maxHeap: '' // for setting JVM heap limits
};

maxBuffer - option passed to childprocess invoked by library to run pdfbox.jar java software. Refer here for docs

maxHeap - To pass value to -Xmx Java option, for maximum memory allocation. Check this stackoverflow answer for some details

An App based on easy-pdf-merge!

PDF Merger is a cross platform Desktop App being developed using Electron Framework and easy-pdf-merge module. You can find the source code of the App here.

Reporting Issues and Feature Requests

For reporting issues and for feature requests, go to the github issues page of the module

License - Apache License 2.0

Copyright 2016 Karuppiah N

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

easy-pdf-merge's People

Contributors

alexhughesnab avatar beatfreaker avatar bompi88 avatar dependabot[bot] avatar g0ddish avatar itsjw avatar karuppiah7890 avatar miniland1333 avatar raincal avatar tin-nguyen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

easy-pdf-merge's Issues

easy-pdf-merge output

is there a way to merge two buffers and return merged pdf files in buffer format too?

S3 pdf download and merge:-

creating a wrapper function that will download the files from s3 and merger them into one an upload again if you want it can take use of the aws-sdk present

Merging 2 pdf with each of 3 mb get error

OS: Windows 10
node : 8.12

whenever i merge 2 pdf file of each 3 mb i get below error

Command failed: java -jar "C:\nokia\pdf_production\Development\nokia-pdf-production\node_modules\easy-pdf-merge\jar\pdfbox.jar" PDFMerger "C:\nokia\pdf_production\Development\nokia-pdf-production\output/doc43_1.pdf" "C:\nokia\pdf_production\Development\nokia-pdf-production\output/doc43_2.pdf" "C:\nokia\pdf_production\Development\nokia-pdf-production\output/doc43.pdf"
Nov 03, 2018 11:29:08 PM org.apache.pdfbox.pdmodel.graphics.color.PDDeviceRGB suggestKCMS
INFO: To get higher rendering speed on java 8 oder 9,
Nov 03, 2018 11:29:08 PM org.apache.pdfbox.pdmodel.graphics.color.PDDeviceRGB suggestKCMS
INFO: use the option -Dsun.java2d.cmm=sun.java2d.cmm.kcms.KcmsServiceProvider
Nov 03, 2018 11:29:08 PM org.apache.pdfbox.pdmodel.graphics.color.PDDeviceRGB suggestKCMS
INFO: or call System.setProperty("sun.java2d.cmm", "sun.java2d.cmm.kcms.KcmsServiceProvider")
Exception in thread "main" java.lang.StackOverflowError
at java.util.HashMap.get(Unknown Source)
at org.apache.pdfbox.multipdf.PDFCloneUtility.cloneForNewDocument(PDFCloneUtility.java:78)
at org.apache.pdfbox.multipdf.PDFCloneUtility.cloneForNewDocument(PDFCloneUtility.java:101)
at org.apache.pdfbox.multipdf.PDFCloneUtility.cloneForNewDocument(PDFCloneUtility.java:140)
at org.apache.pdfbox.multipdf.PDFCloneUtility.cloneForNewDocument(PDFCloneUtility.java:101)
at org.apache.pdfbox.multipdf.PDFCloneUtility.cloneForNewDocument(PDFCloneUtility.java:140)
at org.apache.pdfbox.multipdf.PDFCloneUtility.cloneForNewDocument(PDFCloneUtility.java:101)
at org.apache.pdfbox.multipdf.PDFCloneUtility.cloneForNewDocument(PDFCloneUtility.java:140)

Check if source files exist and return appropriate error.

Currently Java throws the error, instead the JavaScript module can handle this situation before even calling the pdfbox.jar application

$ node test.js
Error: Command failed: java -jar  "/Users/karuppiahn/oss/github.com/karuppiah7890/easy-pdf-merge/jar/pdfbox.jar" PDFMerger "test/github heat sheet.pdf" "test/text_extraction.pdf" "test/Out.pdf"
Exception in thread "main" java.io.FileNotFoundException: test/github heat sheet.pdf (No such file or directory)
	at java.base/java.io.RandomAccessFile.open0(Native Method)
	at java.base/java.io.RandomAccessFile.open(RandomAccessFile.java:347)
	at java.base/java.io.RandomAccessFile.<init>(RandomAccessFile.java:261)
	at java.base/java.io.RandomAccessFile.<init>(RandomAccessFile.java:216)
	at org.apache.pdfbox.io.RandomAccessBufferedFileInputStream.<init>(RandomAccessBufferedFileInputStream.java:99)
	at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1079)
	at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1006)
	at org.apache.pdfbox.multipdf.PDFMergerUtility.legacyMergeDocuments(PDFMergerUtility.java:451)
	at org.apache.pdfbox.multipdf.PDFMergerUtility.mergeDocuments(PDFMergerUtility.java:346)
	at org.apache.pdfbox.tools.PDFMerger.merge(PDFMerger.java:70)
	at org.apache.pdfbox.tools.PDFMerger.main(PDFMerger.java:49)
	at org.apache.pdfbox.tools.PDFBox.main(PDFBox.java:81)

    at ChildProcess.exithandler (child_process.js:303:12)
    at ChildProcess.emit (events.js:310:20)
    at maybeClose (internal/child_process.js:1021:16)
    at Socket.<anonymous> (internal/child_process.js:443:11)
    at Socket.emit (events.js:310:20)
    at Pipe.<anonymous> (net.js:672:12) {
  killed: false,
  code: 1,
  signal: null,
  cmd: 'java -jar  "/Users/karuppiahn/oss/github.com/karuppiah7890/easy-pdf-merge/jar/pdfbox.jar" PDFMerger "test/github heat sheet.pdf" "test/text_extraction.pdf" "test/Out.pdf"'
}

Progress information of merging

Merge PDFs showing the progress percentage - useful while there are lots of PDFs to be merged. But this feature would mean that - callback will be called more than once. But there will be some sort of status code to ensure the end of calling callbacks

Or a different approach maybe?

Or is it not feasible? Or doesn't make sense?

Discussions and PRs are welcome!

JAVA is not recognized as an internal or external command in Window PC

I have installed node module using command: npm i easy-pdf-merge

Added code to the .js file

var pdfMerger = require('easy-pdf-merge');
exports.getPdfdemo = function (req, res, next) {
pdfMerger(['./businesscard.pdf', './TheBusinessofthe21stCenturyBook.pdf'], './finalpdf.pdf', function (err) {
if (err)
return console.log(err);
console.log('Successfully merged!');
});
};

Getting below error

{ Error: Command failed: java -jar "D:\node_projects\project_folder\node_modules\easy-pdf-merge\jar\pdfbox.jar" PDFMerger "./businesscard.pdf" "./TheBusinessofthe21stCenturyBook.pdf" "./finalpdf.pdf"
'java' is not recognized as an internal or external command,
operable program or batch file.
at ChildProcess.exithandler (child_process.js:275:12)
at emitTwo (events.js:126:13)
at ChildProcess.emit (events.js:214:7)
at maybeClose (internal/child_process.js:925:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
killed: false,
code: 1,
signal: null,
cmd: 'java -jar "D:\node_projects\project_folder\node_modules\easy-pdf-merge\jar\pdfbox.jar" PDFMerger "./businesscard.pdf" "./TheBusinessofthe21stCenturyBook.pdf" "./finalpdf.pdf"' }

Please help me to find out the issue.

recursion :_ Stackoverflow error

when running the script on pdf files with 150 pages or more
it appears it always throws an stackoverflow error
i assume it has something to do recursion

Error: Command failed: java -jar  "C:\Users\Name\node_modules\easy-pdf-merge\jar\pdfbox.jar" easy-pdf-merge "File1.pdf" 
"File2.pdf" "DestinationFile.pdf"
 Exception in thread "main" java.lang.StackOverflowError

Merge keeps merging old content in memmory

Hi,

I ran the code, and it seems like the merge keeps some kind of cache or content behind and when the function is called over time via client it merges the old contents as well..
Is there a reason/fix for this?

merging problem

I am trying to merge pdf which is inside a folder of project.
My program is :
When you upload first pdf it will store in a public/uploads folder.
and when next time you upload a pdf. it read the entire folder and merge all of them into one and so on.

It was working ok in my local windows machine.
But when i uploaded to heroku it stopped working.

I used absolute path of files.

fs.readdir('./public/uploads', (err, files) => {
files.forEach(file => {
if (file.split(".")[1] === "pdf") {
list.push(__dirname + "/public/uploads/" + file);
}
})
var outputPath = __dirname + "\public\uploads\" + "studyPdf.pdf";
pdfMerge(list.reverse(), outputPath, function (err) {
if (err) {
res.send(err);
} else {
res.send("success");
}
})
});

When i am trying to do with this it returns an object :

{"killed":false,"code":127,"signal":null,"cmd":"java -jar /app/node_modules/easy-pdf-merge/jar/pdfbox.jar PDFMerger "/app/public/uploads/studyPdf.pdf" "/app/public/uploads/a.pdf" "/app\public\uploads\studyPdf.pdf""}

and when i make the list like list.push(__dirname + "\public\uploads\" + file);

It is showing me no file exists.

also i have tried path package with resolve method. It return the same object.

i also tried with relative path. but nothing works...

Got error when merge over 7 PDF files

I got an error when I try to use easy-pdf-merge to merge over 5 PDF files

{"cmd":"java -jar "/node_modules/easy-pdf-merge/jar/pdfbox.jar" PDFMerger "/var/folders/yx/3nvjxxb128719bvl9h9jqh680000gn/T/2017-01-15_Baskin_Robbins-_Q116-_OLO_FB_PPA-_3.27-6.30_1484484678.pdf" "/var/folders/yx/3nvjxxb128719bvl9h9jqh680000gn/T/2017-01-15_Baskin_Robbins-_Q116-_OLO_FB_PPA-_3.27-6.30_1484484696.pdf" "/var/folders/yx/3nvjxxb128719bvl9h9jqh680000gn/T/2017-01-15_Baskin_Robbins-_Q116-_OLO_FB_PPA-_3.27-6.30_1484484711.pdf" "/var/folders/yx/3nvjxxb128719bvl9h9jqh680000gn/T/2017-01-15_Baskin_Robbins-_Q116-_OLO_FB_PPA-_3.27-6.30_1484484726.pdf" "/var/folders/yx/3nvjxxb128719bvl9h9jqh680000gn/T/2017-01-15_Baskin_Robbins-_Q116-_OLO_FB_PPA-_3.27-6.30_1484484741.pdf" "/var/folders/yx/3nvjxxb128719bvl9h9jqh680000gn/T/2017-01-15_Baskin_Robbins-_Q116-_OLO_FB_PPA-_3.27-6.30_1484484756.pdf" "/var/folders/yx/3nvjxxb128719bvl9h9jqh680000gn/T/2017-01-15_Baskin_Robbins-_Q116-_OLO_FB_PPA-_3.27-6.30_1484484775.pdf" "/var/folders/yx/3nvjxxb128719bvl9h9jqh680000gn/T/2017-01-15_Baskin_Robbins-_Q116-_OLO_FB_PPA-_3.27-6.30_1484484794.pdf" "/var/folders/yx/3nvjxxb128719bvl9h9jqh680000gn/T/2017-01-15_Baskin_Robbins-_Q116-_OLO_FB_PPA-_3.27-6.30_1484484813.pdf" "/var/folders/yx/3nvjxxb128719bvl9h9jqh680000gn/T/2017-01-15_Baskin_Robbins-_Q116-_OLO_FB_PPA-_3.27-6.30_1484484831.pdf" "/var/folders/yx/3nvjxxb128719bvl9h9jqh680000gn/T/2017-01-15_Baskin_Robbins-_Q116-_OLO_FB_PPA-_3.27-6.30_1484484846.pdf" "/var/folders/yx/3nvjxxb128719bvl9h9jqh680000gn/T/2017-01-15_Baskin_Robbins-_Q116-_OLO_FB_PPA-_3.27-6.30_1484484861.pdf" "/var/folders/yx/3nvjxxb128719bvl9h9jqh680000gn/T/2017-01-15_Baskin_Robbins-_Q116-_OLO_FB_PPA-_3.27-6.30_1484484879.pdf" "/var/folders/yx/3nvjxxb128719bvl9h9jqh680000gn/T/2017-01-15_Baskin_Robbins-_Q116-_OLO_FB_PPA-_3.27-6.30_1484484898.pdf" "/var/folders/yx/3nvjxxb128719bvl9h9jqh680000gn/T/2017-01-15_Baskin_Robbins-_Q116-_OLO_FB_PPA-_3.27-6.30_1484484917.pdf" "/var/folders/yx/3nvjxxb128719bvl9h9jqh680000gn/T/2017-01-15_Baskin_Robbins-_Q116-_OLO_FB_PPA-_3.27-6.30_1484484923.pdf""}

Do we have a limitation on merging?

Merging problem error with java -jar

Error when merging is

Unhandled error for request GET /api/survey/roadmapPdf?surveyId=60928c68791bbf2fee0317e1&access_token=3sk1enF2m1QX2jbjW2Eirq7j3Qu2Rm2pv43LeIiyfPOpdf6nSnzpDUt26TJ0Sc7A: Error: Command failed: java -jar /Users/ashwanthmadhav/Documents/projects/ongoing/dne/udx-china/node_modules/easy-pdf-merge/jar/pdfbox.jar PDFMerger "/tmp/dne/60928c68791bbf2fee0317e1/j440wf9avl.pdf" "/tmp/dne/60928c68791bbf2fee0317e1/60928c68791bbf2fee0317e1_roadMapGenerated.pdf" "/tmp/dne/60928c68791bbf2fee0317e1/7filimby30.pdf"
Exception in thread "main" java.io.IOException: Error: End-of-File, expected line
at org.apache.pdfbox.pdfparser.BaseParser.readLine(BaseParser.java:1103)
at org.apache.pdfbox.pdfparser.COSParser.parseHeader(COSParser.java:2581)
at org.apache.pdfbox.pdfparser.COSParser.parsePDFHeader(COSParser.java:2560)
at org.apache.pdfbox.pdfparser.PDFParser.parse(PDFParser.java:219)
at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1099)
at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1082)
at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1006)
at org.apache.pdfbox.multipdf.PDFMergerUtility.legacyMergeDocuments(PDFMergerUtility.java:451)
at org.apache.pdfbox.multipdf.PDFMergerUtility.mergeDocuments(PDFMergerUtility.java:346)
at org.apache.pdfbox.tools.PDFMerger.merge(PDFMerger.java:70)
at org.apache.pdfbox.tools.PDFMerger.main(PDFMerger.java:49)
at org.apache.pdfbox.tools.PDFBox.main(PDFBox.java:81)

at ChildProcess.exithandler (child_process.js:308:12)
at ChildProcess.emit (events.js:315:20)
at ChildProcess.EventEmitter.emit (domain.js:467:12)
at maybeClose (internal/child_process.js:1048:16)
at Socket.<anonymous> (internal/child_process.js:439:11)
at Socket.emit (events.js:315:20)
at Socket.EventEmitter.emit (domain.js:467:12)
at Pipe.<anonymous> (net.js:673:12)

ALready installed java and it was working fine beofre some months ago.

Now getting this error.

gives error when trying to run node app.

SyntaxError: Unexpected token ILLEGAL
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)

Missing root object specification in trailer.

I think this error happens, because there are a few pdfs with different versions and those are not mergable. I'm not sure at all and didn't have time to try it, maybe someone else has a clue.

Exception in thread "main" java.io.IOException: Missing root object specification in trailer.
at org.apache.pdfbox.pdfparser.COSParser.parseTrailerValuesDynamically(COSParser.java:2876)
at org.apache.pdfbox.pdfparser.PDFParser.initialParse(PDFParser.java:175)
at org.apache.pdfbox.pdfparser.PDFParser.parse(PDFParser.java:226)
at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1070)
at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:991)
at org.apache.pdfbox.multipdf.PDFMergerUtility.legacyMergeDocuments(PDFMergerUtility.java:451)
at org.apache.pdfbox.multipdf.PDFMergerUtility.mergeDocuments(PDFMergerUtility.java:346)
at org.apache.pdfbox.tools.PDFMerger.merge(PDFMerger.java:70)
at org.apache.pdfbox.tools.PDFMerger.main(PDFMerger.java:49)
at org.apache.pdfbox.tools.PDFBox.main(PDFBox.java:81)

{ Error: Command failed: java -jar "E:\pdf-service\node_modules\easy-pdf-merge\jar\pdfbox.jar" PDFMerger "src/res/files/19dcdc5f-0a0d-48a9-9ce7-479627236df2/pdfs/c05e8e53-4be5-43c0-bae6-b66977640bec.pdf" "src/res/files/19dcdc5f-0a0d-48a9-9ce7-479627236df2/p dfs/7a865998-5557-4329-b51a-69cc3c0644a3.pdf" "src/res/files/19dcdc5f-0a0d-48a9-9ce7-479627236df2/downloads/3fb99db2-5a7b-4117-a62a-5f6124ae912a.pdf" "src/res/files/19dcdc5f-0a0d-48a9-9ce7-479627236df2/downloads/8da4147a-93ea-452b-95a4-44c58f84b000.pdf" "src/re s/files/19dcdc5f-0a0d-48a9-9ce7-479627236df2/pdfs/dc9a80ed-2ede-40af-90c7-51f2c193e8cd.pdf" "src/res/files/19dcdc5f-0a0d-48a9-9ce7-479627236df2/pdfs/4dba1a58-c970-4f35-98e2-eee3527d2c08.pdf" "src/res/files/19dcdc5f-0a0d-48a9-9ce7-479627236df2/pdfs/270b993c-0700 -4266-aa33-da42a3535944.pdf" "src/res/files/19dcdc5f-0a0d-48a9-9ce7-479627236df2/pdfs/ef07b229-e4f1-4e4a-b7a0-24690f3d7892.pdf" "src/res/files/19dcdc5f-0a0d-48a9-9ce7-479627236df2/downloads/bfacebfc-15c3-407d-a873-f82b09a13870.pdf" "src/res/files/19dcdc5f-0a0d- 48a9-9ce7-479627236df2/pdfs/4d02358f-00af-4348-99e9-35d25dd4c842.pdf" "src/res/files/19dcdc5f-0a0d-48a9-9ce7-479627236df2/pdfs/e7797187-1031-4f51-95df-289fb9722e48.pdf" "src/res/files/19dcdc5f-0a0d-48a9-9ce7-479627236df2/downloads/9700122c-c7b5-4bc8-bee7-b8f630 a5f1fa.pdf" "src/res/files/19dcdc5f-0a0d-48a9-9ce7-479627236df2/pdfs/07159c8c-7f97-44d6-99db-1c9a1a442fb0.pdf" "src/res/files/19dcdc5f-0a0d-48a9-9ce7-479627236df2/pdfs/0720ca5a-9963-4745-8040-00794ed244eb.pdf" "src/res/files/19dcdc5f-0a0d-48a9-9ce7-479627236df2 /pdfs/6600befc-7ce7-4326-899f-5cd3926abacd.pdf" "src/res/files/19dcdc5f-0a0d-48a9-9ce7-479627236df2/pdfs/62407c3b-22a0-4419-b9d1-17725bfb03b9.pdf" "src/res/files/19dcdc5f-0a0d-48a9-9ce7-479627236df2/pdfs/da95ef8a-59c8-4d10-a73e-d02ef361ce93.pdf" "src/res/files/ 19dcdc5f-0a0d-48a9-9ce7-479627236df2/pdfs/c74e0c9c-5576-41d1-8f1b-f4c15f2b4abf.pdf" "src/res/files/19dcdc5f-0a0d-48a9-9ce7-479627236df2/pdfs/d5a61856-6952-4138-a946-599b8ce121cf.pdf" "src/res/files/19dcdc5f-0a0d-48a9-9ce7-479627236df2/pdfs/81a04cd5-3d09-40f3-b1 30-55b0795f52af.pdf" "src/res/files/19dcdc5f-0a0d-48a9-9ce7-479627236df2/pdfs/e05ddc11-7712-4df2-b1c6-a8cd261078e8.pdf"
`

add cli option

add cli script so that i can install this module globally and can merge PDF's using command line.

if you want i can create PR for the same ?

Command failed: root cannot be null

I m getting below error while trying to merge pdfs using the package

{ Error: Command failed: java -jar  "/opt/ocr-service/node_modules/easy-pdf-merge/jar/pdfbox.jar" PDFMerger "/tmp/tesseract_dir_17ku4292IFSc57/tess_input_dir_17zzk1qPz3T7pb/P0001.pdf" "/tmp/tesseract_dir_17ku4292IFSc57/tess_input_dir_17k4Ki0xeLWNhR/P0002.pdf" "/tmp/tesseract_dir_17ku4292IFSc57/tess_input_dir_17gd2ZIeIKuaQI/P0003.pdf" "/tmp/tesseract_dir_17ku4292IFSc57/MergedPdf.pdf"
Exception in thread "main" java.lang.IllegalArgumentException: root cannot be null
	at org.apache.pdfbox.pdmodel.PDPageTree.<init>(PDPageTree.java:75)
	at org.apache.pdfbox.pdmodel.PDDocumentCatalog.getPages(PDDocumentCatalog.java:132)
	at org.apache.pdfbox.multipdf.PDFMergerUtility.appendDocument(PDFMergerUtility.java:733)
	at org.apache.pdfbox.multipdf.PDFMergerUtility.legacyMergeDocuments(PDFMergerUtility.java:381)
	at org.apache.pdfbox.multipdf.PDFMergerUtility.mergeDocuments(PDFMergerUtility.java:280)
	at org.apache.pdfbox.tools.PDFMerger.merge(PDFMerger.java:70)
	at org.apache.pdfbox.tools.PDFMerger.main(PDFMerger.java:49)
	at org.apache.pdfbox.tools.PDFBox.main(PDFBox.java:81)

    at ChildProcess.exithandler (child_process.js:294:12)
    at ChildProcess.emit (events.js:189:13)
    at ChildProcess.EventEmitter.emit (domain.js:441:20)
    at maybeClose (internal/child_process.js:970:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
  killed: false,
  code: 1,
  signal: null,
  cmd:
   'java -jar  "/opt/ocr-service/node_modules/easy-pdf-merge/jar/pdfbox.jar" PDFMerger "/tmp/tesseract_dir_17ku4292IFSc57/tess_input_dir_17zzk1qPz3T7pb/P0001.pdf" "/tmp/tesseract_dir_17ku4292IFSc57/tess_input_dir_17k4Ki0xeLWNhR/P0002.pdf" "/tmp/tesseract_dir_17ku4292IFSc57/tess_input_dir_17gd2ZIeIKuaQI/P0003.pdf" "/tmp/tesseract_dir_17ku4292IFSc57/MergedPdf.pdf"' } }

"the command line is too long"

I'm using the module to merge a lot of single page pdf's into one but when there's more than about 100, I get the error message:
Error: Command failed: java -jar "C:\Users\oem\Desktop\electrion-workspace\prints processing\node_modules\electron\dist\resources\easy-pdf-merge\jar\pdfbox.jar" PDFMerger
// a very long list of file paths//
The command line is too long.

I'm assuming I can get around this by merging smaller groups together as temp files then merging them together but that might be slower to run so before I rewrite my code I want to check if this is a bug/artificial limitation? Another command line pdf tool listed as a bug fix so I have hope.

Issue with Merging Editable PDF

Error: Command failed: java -jar /app/node_modules/easy-pdf-merge/jar/pdfbox.jar PDFMerger "/app/finalpdf/2021-27-060927GarroneDarcyRecertificationApprovedCombined/merged.pdf" "/app/finalpdf/2021-27-060927GarroneDarcyRecertificationApprovedCombined/a393g000000RaAiAAK.pdf" "/app/finalpdf/2021-27-060927GarroneDarcyRecertificationApprovedCombined/a393g000000ReDfAAK.pdf" "/app/finalpdf/2021-27-060927GarroneDarcyRecertificationApprovedCombined/a393g000000RaBbAAK.pdf" "/app/finalpdf/2021-27-060927GarroneDarcyRecertificationApprovedCombined/a393g000000RaDDAA0.pdf" "/app/finalpdf/2021-27-060927GarroneDarcyRecertificationApprovedCombined/a393g000000RaDIAA0.pdf" "/app/finalpdf/2021-27-060927GarroneDarcyRecertificationApprovedCombined/merged.pdf"
Picked up JAVA_TOOL_OPTIONS: -Xmx300m -Xss512k -XX:CICompilerCount=2 -Dfile.encoding=UTF-8 -javaagent:/app/.heroku/bin/heroku-metrics-agent.jar
Aug 06, 2021 1:27:56 PM org.apache.pdfbox.pdmodel.font.FileSystemFontProvider loadDiskCache
WARNING: New fonts found, font cache will be re-built
Aug 06, 2021 1:27:56 PM org.apache.pdfbox.pdmodel.font.FileSystemFontProvider
WARNING: Building on-disk font cache, this may take a while
Aug 06, 2021 1:27:56 PM org.apache.pdfbox.pdmodel.font.FileSystemFontProvider
WARNING: Finished building on-disk font cache, found 76 fonts
Exception in thread "main" java.lang.ClassCastException: org.apache.pdfbox.cos.COSName cannot be cast to org.apache.pdfbox.cos.COSString
at org.apache.pdfbox.pdmodel.interactive.form.PDVariableText.getDefaultAppearanceString(PDVariableText.java:91)
at org.apache.pdfbox.pdmodel.interactive.form.AppearanceGeneratorHelper.(AppearanceGeneratorHelper.java:114)
at org.apache.pdfbox.pdmodel.interactive.form.PDTextField.constructAppearances(PDTextField.java:263)
at org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm.refreshAppearances(PDAcroForm.java:327)
at org.apache.pdfbox.pdmodel.fixup.processor.AcroFormGenerateAppearancesProcessor.process(AcroFormGenerateAppearancesProcessor.java:54)
at org.apache.pdfbox.pdmodel.fixup.AcroFormDefaultFixup.apply(AcroFormDefaultFixup.java:56)
at org.apache.pdfbox.pdmodel.PDDocumentCatalog.getAcroForm(PDDocumentCatalog.java:132)
at org.apache.pdfbox.pdmodel.PDDocumentCatalog.getAcroForm(PDDocumentCatalog.java:113)
at org.apache.pdfbox.multipdf.PDFMergerUtility.appendDocument(PDFMergerUtility.java:519)
at org.apache.pdfbox.multipdf.PDFMergerUtility.legacyMergeDocuments(PDFMergerUtility.java:459)
at org.apache.pdfbox.multipdf.PDFMergerUtility.mergeDocuments(PDFMergerUtility.java:346)
at org.apache.pdfbox.tools.PDFMerger.merge(PDFMerger.java:70)
at org.apache.pdfbox.tools.PDFMerger.main(PDFMerger.java:49)
at org.apache.pdfbox.tools.PDFBox.main(PDFBox.java:81)

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.