IText 7 添加带有渐变的文本颜色

问题描述 投票:0回答:0

是否可以使用 itext 7+ 添加具有渐变颜色的文本?

我试过这样做但没有帮助

AbstractLinearGradientBuilder gradientBuilder = new LinearGradientBuilder()
            .setGradientVector(A6.getLeft(), A6.getLeft(), A6.getRight(), A6.getRight())
            .addColorStop(new GradientColorStop(COLOR_PURPLE.getColorValue()))
            .addColorStop(new GradientColorStop(COLOR_RED.getColorValue()));
BackgroundImage backgroundImage = new BackgroundImage.Builder()
            .setLinearGradientBuilder(gradientBuilder)
            .build();
Text text = new Text(code);
text.setProperty(Property.BACKGROUND_IMAGE, List.of(backgroundImage));
java itext itext7
© www.soinside.com 2019 - 2024. All rights reserved.