pdfminer / pdfminer.six

Community maintained fork of pdfminer - we fathom PDF
https://pdfminersix.readthedocs.io
MIT License
5.95k stars 930 forks source link

There is a color difference in the non_stroking_color #1043

Open KaboChow opened 1 month ago

KaboChow commented 1 month ago

Hi Team, I am trying to use the following JS code to convert the obtained non_stoking.color into RGB color for use in HTML. `

            if(fillColor.length===1){
                return 'rgb(' + (255*(1.0-fillColor[0])).toFixed(0) + ')';
            }

            if(fillColor.length===3){
                const r = 255 * fillColor[0];
                const g = 255 * fillColor[1];
                const b = 255 * fillColor[2];
                return 'rgb(' + r.toFixed(0) + ',' + g.toFixed(0) +',' + b.toFixed(0) + ')';
            }

            if(fillColor.length===4){
                const r = 255*(1.0-(fillColor[0]+fillColor[3]));
                const g = 255*(1.0-(fillColor[1]+fillColor[3]));
                const b = 255*(1.0-(fillColor[2]+fillColor[3]));
                return 'rgb(' + r.toFixed(0) + ',' + g.toFixed(0) +',' + b.toFixed(0) + ')';
            }

`

But there are obvious color differences in the obtained colors. pdf: image html: image

This is the PDF I used for testing: TEST 5 - 48in-Height-Chef-Supplies-Banner-d4-ced6f345009972ad3e50309422be6654.pdf

Does anyone know how to solve it? thank you

jollyfish-cjy commented 3 days ago

hi, maybe you can try pymupdf.

KaboChow commented 3 days ago

hi, maybe you can try pymupdf.

Thanks!@jollyfish-cjy pymupdf looks like it has a lot more interesting features, I will give it a try