Silent error on parse semi-transparent content

Đang mở
#157 6 bình luận 2 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
28/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
javascript
Lĩnh vực
backend

Hướng nghiên cứu

Tái hiện lỗi với Declaration.pdf hoặc lệnh pdf2json.js được hiển thị trong issue, sau đó kiểm tra /base/core/jpg.js quanh các dòng 832-833 và đường dẫn xử lý pdfParser_dataError. Xác minh cách các JPEG bốn thành phần được xử lý và đảm bảo quá trình phân tích cú pháp báo cáo một lỗi hữu ích hoặc hoàn tất mà không âm thầm dừng lại; kiểm thử lại tài liệu được báo cáo và lệnh mẫu hiện có.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Hello, recently I found bug with parsing some .pdf files. If file have symbols colored in semi-transparent color, a program just stops without any error messages. Here's code which stops silent (declaration.pdf - "unparsable" document):

let fs = require('fs'),
    PDFParser = require("pdf2json");

let pdfParser = new PDFParser(this, 1);

pdfParser.on("pdfParser_dataError", errData => console.error(errData.parserError) );
pdfParser.on("pdfParser_dataReady", pdfData => {
    fs.writeFile("./content.txt", pdfParser.getRawTextContent());
});

pdfParser.loadPDF("./Declaration.pdf");

So, after I tried to parse document directly with pdf2json:
node pdf2json.js "../../documents/whitepaper/47/WP_En.pdf" "../../"
And I got some errors:

Warning: Unhandled rejection: Error: JPEG error: Unsupported color mode (4 components)
Error: JPEG error: Unsupported color mode (4 components)
    at error (eval at <anonymous> (app\node_modules\pdf2json\lib\pdf.js:64:1), <anonymous>:195:9)
    at JpegStream_ensureBuffer [as ensureBuffer] (eval at <anonymous> (app\node_modules\pdf2json\lib\pdf.js:64:1), <anonymous>:25571:7)
    at JpegStream.DecodeStream_getBytes [as getBytes] (eval at <anonymous> (app\node_modules\pdf2json\lib\pdf.js:64:1), <anonymous>:24875:14)
    at PDFImage_getImageBytes [as getImageBytes] (eval at <anonymous> (app\node_modules\pdf2json\lib\pdf.js:64:1), <anonymous>:21009:25)
    at PDFImage_fillRgbaBuffer [as fillRgbaBuffer] (eval at <anonymous> (app\node_modules\pdf2json\lib\pdf.js:64:1), <anonymous>:20941:27)
    at PDFImage_getImageData [as getImageData] (eval at <anonymous> (app\node_modules\pdf2json\lib\pdf.js:64:1), <anonymous>:21004:12)
    at eval (eval at <anonymous> (app\node_modules\pdf2json\lib\pdf.js:64:1), <anonymous>:7125:34)
    at Object.eval [as onResolve] (eval at <anonymous> (app\node_modules\pdf2json\lib\pdf.js:64:1), <anonymous>:20657:7)
    at Object.runHandlers (eval at <anonymous> (app\node_modules\pdf2json\lib\pdf.js:64:1), <anonymous>:864:35)
    at ontimeout (timers.js:466:11)

In a nutshell, my solution was to comment 2 lines(832-833) in /base/core/jpg.js:

if (!this.adobe)
    throw 'Unsupported color mode (4 components)';

After that I successfully parsed my document.

So, @modesty, can you fix this or just remove?

Ngôn ngữ chính
Java
Star
2.2k
Fork
396
Merge trung bình
9 ngày 19 giờ
Pull request đã merge (30 ngày)
3

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của modesty/pdf2json

Tất cả issue của modesty/pdf2json

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.