Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not find ByteRange placeholder: /ByteRange [0 /********** /********** /**********] #27

Closed
angeltg83 opened this issue Jun 28, 2019 · 7 comments

Comments

@angeltg83
Copy link

helph!!

@vbuch
Copy link
Owner

vbuch commented Jun 29, 2019

Did you add it?

@angeltg83
Copy link
Author

I can't,
I have a pdf created with another library, this is my code,

let signer = require('node-signpdf').default;

console.log('\n\n\nsigner', signer);
let URL_PDF = "/home/xxx/Desktop/PDF_FIRMA/prueba.pdf";
let TOKEN_P12 = "/home/xx/Desktop/PDF_FIRMA/PLAN VITAL VITALPLAN S.A.P12";

var pdfBuffer = fs.readFileSync(URL_PDF);

console.log('pdfBuffer', pdfBuffer);

const signedPdf = signer.sign(
  pdfBuffer,
  fs.readFileSync(TOKEN_P12),
  { passphrase: 'pass.31', asn1StrictParsing: true, },
);

// return res.json(signer);

Screenshot from 2019-06-30 09-34-05

Please help!!

@vbuch
Copy link
Owner

vbuch commented Jul 1, 2019

.sign expects the placeholder to be there. read the readme. Also take a look here: #22

@angeltg83
Copy link
Author

use the helper of your plainAddPlaceholder library, as the code is shown

var signer = require('node-signpdf').default;
var placeholder = require('node-signpdf').plainAddPlaceholder.default;
var fs = require('fs');
var PATH_TO_PDF_FILE = "prueba.pdf";
var PATH_TO_P12_CERTIFICATE = "/pc/TOKEN.P12";

console.log('signer UUU ', placeholder);

var pdfBuffer = fs.readFileSync(PATH_TO_PDF_FILE),
  pdfBuffer = placeholder({
    pdfBuffer,
    reason: '',
    signatureLength: 1612,
  });



var signedPdf = signer.sign(
  // fs.readFileSync(PATH_TO_PDF_FILE),
  pdfBuffer,
  fs.readFileSync(PATH_TO_P12_CERTIFICATE), {
    passphrase: 'pas.311',
    asn1StrictParsing: true,
  }
);

console.log('signedPdf ', signedPdf);

fs.writeFileSync('PC/Firmando[PDF]/21820[RQ000009]FIRMADO.pdf', signedPdf);

and then show the error:

Screenshot from 2019-07-05 18-37-09

please!!, help,

@vbuch
Copy link
Owner

vbuch commented Jul 6, 2019

Well, this is not yet supported as the error says. Your pdf already contains annotations and i have not written code to handle that situation... If someone has the time to do it, a PR would be more than welcome.

@angeltg83
Copy link
Author

I already made it, edited the library and I was successful. only that the pdf when verifying it with adobe the signature is obtained inconsistent.

@vbuch
Copy link
Owner

vbuch commented Nov 5, 2019

No activity. Closing.

@vbuch vbuch closed this as completed Nov 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants