Hi,
What you did isn't what I wrote, and your code applies to drawing an
object, but the thing that makes trouble happens when drawing a line (or
rather, a small rectangle):
0 0 0 rg
* /GS0 gs*
q
1 0 0 1 0 252.8705 cm
0 0 m
710.598 0 l
710.598 0.8 l
0 0.8 l
0 0 l
h
0 0 m
710.598 0 l
710.598 0 l
0 0 l
0 0 l
h
f*
Q
So I modified SetGraphicsStateParameters.java as described (although I
moved my two lines after the null check) and the printed file is no
longer rasterized on the second page.
https://drive.google.com/file/d/1U6X0ZqQeJtdaZqAXEnXFK7F8F5_rtffv/view?usp=sharing
Tilman
On 19.05.2023 05:51, Tres Finocchiaro wrote:
Thanks.
I've added the code to our existing custom "process()" function.... it
looks like this:
public void process(Operator operator, List<COSBase> operands) throws
IOException {
if (operands.isEmpty()) {
throw new MissingOperandException(operator, operands);
} else {
COSBase base0 = operands.get(0);
if (base0 instanceof COSName) {
COSName objectName = (COSName)base0;
*// Disable alpha for lines, etc PDExtendedGraphicsState gs
= context.getResources().getExtGState(objectName); if(gs !=
null) { gs.setNonStrokingAlphaConstant(1f);
gs.setStrokingAlphaConstant(1f); }*
... Unfortunately, it doesn't seem to have the same effect as the
brute-force approach of "hard-coded them to always set/return '1' in
PDGraphicsState". Do you have any suspicions as to why?
This is reproducible using the following steps:
1. Windows 11, Java 11
2. PDF from original email in this thread
3. XPS Document Writer, DPI set to 300
4. Custom form size: 4x6
P.S. This rasterization seems specific to Windows.
-tres.finocchi...@gmail.com
On Thu, May 18, 2023 at 1:30 AM Tilman Hausherr<thaush...@t-online.de>
wrote:
Hi,
I looked again and I see my advice was wrong, the protected method I
looked at is final, and the other one is private.
The next thing that you could try is to create your own
SetGraphicsStateParameters class, and call addOperator(new
SetGraphicsStateParameters()); in your own drawer.
The new class should be like the old class but with this modification
PDExtendedGraphicsState gs =
context.getResources().getExtGState(graphicsName); // existing line
gs.setNonStrokingAlphaConstant(1f);
gs.setStrokingAlphaConstant(1f);
Tilman
On 17.05.2023 22:28, Tres Finocchiaro wrote:
What you could try is to extend *getNonStrokingPaint* and
*getStrokingPaint*
and set both values to 1 (that is the default if no ca/CA entry
exists)
with *setAlphaConstant*() and *setNonStrokeAlphaConstant*().
Thanks. Do you mind offering a pointer on how to perform this? For
example, *getNonStrokingPaint*() and *getStrokingPaint*() return Paint
objects. Should I be forcing *setAlphaConstant*() and
*setNonStrokeAlphaConstant*() like this code example?
https://github.com/apache/pdfbox/blob/f7ac68e7b367a43e36e74e1ec915c25b117304cb/pdfbox/src/main/java/org/apache/pdfbox/contentstream/PDFStreamEngine.java#L237-L238
As a quick test, I hard-coded them to always set/return "1" in
*PDGraphicsState * and it appears to fix the rasterization of the
second page, but I'd like to be able to make this toggleable.
Here's my current code:
https://github.com/qzind/tray/pull/1108/files#diff-aba44d09ef8de16a001d790ae7671bea33941071306f549b8dc290504e3e1d1b,
which is largely based on a conversation here:
https://issues.apache.org/jira/browse/PDFBOX-4123?focusedCommentId=17529733&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-17529733
<
https://issues.apache.org/jira/browse/PDFBOX-4123?focusedCommentId=17529733&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-17529733
.
image.png
-tres.finocchi...@gmail.com