Open nnnikolay opened 6 years ago
Do you mind also attach your source PDFs here for test?
@chunyenHuang unfortunately, I can't share it here. Is there any way to find out what is wrong with it? I'm pretty sure that the problem is in the file, but I've no idea what exactly wrong with it. This is what "CMD + I" shows me in that file:
this is the input-3.pdf from my source code
and this is inspector window from Preview
Can the encryption cause such issue?
Thanks
Well, I actually dont need your input (sry). segmentation fault
is usually caused by unsolved path. So I highly recommend to simply your code and file paths, and then test again.
var hummus = require('hummus')
var path = require('path');
// put in the same directory and test first.
var output = path.join(__dirname, 'data/output.pdf');
var inputA = path.join(__dirname, 'data/input-3.pdf');
var inputB = path.join(__dirname, 'data/input-8.pdf');
var pdfWriter = hummus.createWriter(__dirname + '/../data/output.pdf');
var page = pdfWriter.createPage(0,0,595,842);
pdfWriter.mergePDFPagesToPage(page, inputA,
{
type:hummus.eRangeTypeSpecific,
specificRanges:[[0,0]]
});
pdfWriter.mergePDFPagesToPage(page, inputBm
{
type:hummus.eRangeTypeSpecific,
specificRanges:[[0,0]]
});
pdfWriter.writePage(page).end();
If not, you may try check isEncrypted()
and take look HERE, Xcryption.js
Thanks for the suggestions, I've tried all of them and came to the conclusion that the issue is in the file.
If I use another file everything is fine. But with that file, even the following code is crashing 99% times:
var pdfReader = hummus.createReader(path.join(__dirname, 'input-3.pdf'));
console.log(pdfReader.getPagesCount());
I'm pretty much sure that it is a bad pdf file, I've tried many different files what I was able to find out and all of them are working good so far.
If the input file can help you to find out what is the problem I can send you it via email?
Well, all I can tell you now is that the hummus.createReader
does not handle the permission userProtectionFlag for this pdf well.
So the easy fix for you for now is to hummus.recrypt
and use the new recrypted pdf file. This will require a PR to fix the reader issue.
I had an issue where Node exited with code 139 when I evoked pdfWriter.getFontForFile()
with a non-existent file. Fixed the path and it worked fine afterwards.
Hi Gal,
First of all, thanks for your package. But I'm experiencing a segfault, and not every time.
I've node v8.9.1 and node-gyp v3.6.2.
this is my code
this is my execution flow
as you can see I'm running the same code multiple times and receive sometimes positive result sometimes segfault.
meanwhile running all your tests multiple times does not raise any segfault. It looks like that the problem is in the pdf files (my pdf files)?
with the segfault-handler module I was able to catch the log (if it's useful):