PDFreactor删除线颜色设置问题:自定义颜色无法渲染求助
Hey Stefan, sorry to hear you're hitting snags with custom line-through colors in PDFreactor—let's break this down and get it sorted out.
1. How to Set a Custom Line-Through Color
PDFreactor supports standard CSS properties for styling text decorations, so you have a couple of reliable ways to define a custom color for your line-through:
Method 1: Use Separate Text Decoration Properties
This is the most straightforward and widely supported approach in PDFreactor:
.custom-strike { text-decoration-line: line-through; text-decoration-style: solid; /* Optional: specifies line style (solid, dashed, etc.) */ text-decoration-color: #d62828; /* Replace with your desired color */ }
Method 2: Combine with Shorthand (with Caveats)
While the full text-decoration shorthand can include color, PDFreactor doesn't always parse it reliably. If you prefer shorthand, split the color into a separate property:
.custom-strike { text-decoration: line-through solid; text-decoration-color: cmyk(0%, 100%, 81%, 4%); /* Your CMYK color */ }
2. Why Your Original Code Didn't Work
Your line text-decoration: line-through solid cmyk(0%, 100%, 81%, 4%); likely failed because PDFreactor doesn't support including the color value directly in the full text-decoration shorthand. The engine expects color to be defined via the dedicated text-decoration-color property instead of packing it into the shorthand.
Bonus: Troubleshooting CMYK Colors
If your CMYK color still isn't rendering correctly, try adjusting the format:
- Some PDFreactor versions prefer decimal values instead of percentages:
cmyk(0, 1, 0.81, 0.04) - Verify that your target PDF profile supports CMYK (most do, but double-check your export settings)
Fallback: Simulate Line-Through with a Pseudo-Element
If the above methods still don't work, you can manually create a line-through using a pseudo-element—this is a foolproof workaround:
.custom-strike { position: relative; display: inline-block; /* Ensures the line fits the text width */ } .custom-strike::after { content: ""; position: absolute; top: 50%; left: 0; width: 100%; height: 1px; /* Adjust thickness as needed */ background-color: cmyk(0%, 100%, 81%, 4%); transform: translateY(-50%); /* Centers the line vertically */ }
Give these methods a shot—they should resolve your line-through color issues in PDFreactor!
内容的提问来源于stack exchange,提问作者Stefan Huwiler

