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

Error: Invalid number at 1: % (code: 37) #33

Closed
thakurakhilesh opened this issue Oct 14, 2020 · 3 comments
Closed

Error: Invalid number at 1: % (code: 37) #33

thakurakhilesh opened this issue Oct 14, 2020 · 3 comments
Labels
bug Something isn't working pdfjs This is propably an iss in pdfjs

Comments

@thakurakhilesh
Copy link

thakurakhilesh commented Oct 14, 2020

Environment
Ubuntu 18.04.3 LTS
NodeJs: 12.0.0
pdfj": "^2.4.1"
pdf-merger-js: "^3.0.5"

I am getting below issue:

Error: Invalid number at 1: % (code: 37)
    at Lexer._error (/var/www/html/auditpro/avantha-audit-pro-api/node_modules/pdfjs/lib/parser/lexer.js:128:11)
    at Lexer.readNumber (/var/www/html/auditpro/avantha-audit-pro-api/node_modules/pdfjs/lib/parser/lexer.js:156:16)
    at Function.parse (/var/www/html/auditpro/avantha-audit-pro-api/node_modules/pdfjs/lib/object/object.js:43:22)
    at parseObject (/var/www/html/auditpro/avantha-audit-pro-api/node_modules/pdfjs/lib/object/reference.js:84:31)
    at PDFReference.get [as object] (/var/www/html/auditpro/avantha-audit-pro-api/node_modules/pdfjs/lib/object/reference.js:15:17)
    at ExternalDocument._countPagesRecursively (/var/www/html/auditpro/avantha-audit-pro-api/node_modules/pdfjs/lib/external.js:31:24)
    at ExternalDocument._countPagesRecursively (/var/www/html/auditpro/avantha-audit-pro-api/node_modules/pdfjs/lib/external.js:34:18)
    at ExternalDocument._countPagesRecursively (/var/www/html/auditpro/avantha-audit-pro-api/node_modules/pdfjs/lib/external.js:34:18)
    at new ExternalDocument (/var/www/html/auditpro/avantha-audit-pro-api/node_modules/pdfjs/lib/external.js:26:27)
    at PDFMerger._addEntireDocument (/var/www/html/auditpro/avantha-audit-pro-api/node_modules/pdf-merger-js/index.js:29:15)
    at PDFMerger.add (/var/www/html/auditpro/avantha-audit-pro-api/node_modules/pdf-merger-js/index.js:11:12)
    at LoansController.mergePdfFilesPoc (/var/www/html/auditpro/avantha-audit-pro-api/dist/loans/loans.controller.js:68:20)
    at /var/www/html/auditpro/avantha-audit-pro-api/node_modules/@nestjs/core/router/router-execution-context.js:37:29
    at InterceptorsConsumer.transformDeffered (/var/www/html/auditpro/avantha-audit-pro-api/node_modules/@nestjs/core/interceptors/interceptors-consumer.js:30:28)
    at /var/www/html/auditpro/avantha-audit-pro-api/node_modules/@nestjs/core/interceptors/interceptors-consumer.js:14:48
    at Observable._subscribe (/var/www/html/auditpro/avantha-audit-pro-api/node_modules/rxjs/internal/observable/defer.js:10:21)

passed pdf is valid. correctly opening in browser. I am using "is-pdf-valid": "^0.0.1" package to check pdf is valid or not. This package returns true that means pdf is valid.

Please guide me, how I solve this issue?

@mojoaxel mojoaxel added bug Something isn't working pdfjs This is propably an iss in pdfjs labels Oct 14, 2020
@mojoaxel
Copy link
Collaborator

mojoaxel commented Oct 14, 2020

This is an issue in the pdfjs library. Please create an issue over there with the pdf file attached.

@nicoschtein
Copy link

@thakurakhilesh have you solved it yet?

@GabrielSchambakler
Copy link

@nicoschtein i solved this using the pdf-flatten package (https://www.npmjs.com/package/pdf-flatten)

var pdfMerger = new PDFMerger();
let fileBuffer = fs.readFileSync(pdfPath);
fileBuffer = await flattener.flatten(fileBuffer);
pdfMerger.add(fileBuffer);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pdfjs This is propably an iss in pdfjs
Projects
None yet
Development

No branches or pull requests

4 participants