danfickle / openhtmltopdf

An HTML to PDF library for the JVM. Based on Flying Saucer and Apache PDF-BOX 2. With SVG image support. Now also with accessible PDF support (WCAG, Section 508, PDF/UA)!
https://danfickle.github.io/pdf-templates/index.html
Other
1.93k stars 359 forks source link

PDF about CMYK #893

Closed Mr-Vincent closed 1 year ago

Mr-Vincent commented 1 year ago

I generate a pdf file with my html template for printer,but the color mode of output file was not supported for printer.especially the black color which presented in css was '#000000' ,but the cmyk color is not the pure black. 08255589fa902795fcbd6fbb08932be i can't figure it out.How can i output pdf file with cmyk color mode?

Mr-Vincent commented 1 year ago

i figure it out. Cause my pdf page didn't have any other color except black and white,so i modify source code like this

@Override
public void setColor(FSColor color) {
//        if (color instanceof FSRGBColor) {
//             this._desiredPageState.fillColor = color;
//             this._desiredPageState.strokeColor = color;
//        } else if (color instanceof FSCMYKColor) {
//            this._desiredPageState.fillColor = color;
//            this._desiredPageState.strokeColor = color;
//        } else {
//            assert(color instanceof FSRGBColor || color instanceof FSCMYKColor);
//        }
        // todo 这里强制使用黑色
        FSCMYKColor fscmykColor = new FSCMYKColor(0,0,0,1);
        this._desiredPageState.fillColor = fscmykColor;
        this._desiredPageState.strokeColor = fscmykColor;
    }