Closed tbrowder closed 1 day ago
The unexpected operation
warnings has a silly bug, which I've just fixed with PDF::Content 0.8.6, it was reporting two operators, back, rather than the immediately preceding operator. Please upgrade. You will still get the warning, but the message should hopefully be informative, and less misleading.
These checks can be disabled by calling page.gfx(:!strict)
before adding any graphics to the page.
The PDF standard does have a recommended order of operations. In practice, a lot of drivers don't follow this, and get away with it, but it's good to keep the checks in place if possible.
Strict checking can also be done later using the PDF::Class script pdf-checker.raku --render --strict my.pdf
Also, the running the script pdf-content-dump.raku
might help with tracking done the error. warning For example:
raku -I. `which pdf-content-dump.raku` --raku /tmp/tst.pdf
# **** Page 1 ****
.Save();
.BeginText();
.SetFont("F1", 16);
.ShowText("xxx");
.SetTextLeading(17.6);
.TextNextLine();
.EndText();
Unexpected operation 'h' (ClosePath) used in Page context, following 'ET' (EndText)
in block at /home/david/git/PDF-Content-raku/lib/PDF/Content/Ops.rakumod (PDF::Content::Ops) line 1039
.ClosePath();
Unexpected operation 'S' (Stroke) used in Page context, following 'h' (ClosePath)
in block at /home/david/git/PDF-Content-raku/lib/PDF/Content/Ops.rakumod (PDF::Content::Ops) line 1039
.Stroke();
.Restore();
On Thu, Sep 5, 2024 at 15:18 David Warring @.***> wrote:
Also, the running the script pdf-content-dump.raku --raku my.pdf might help with tracking done the error. For example:
...
Thanks very much, David!
Best regards,
-Tom
Thanks to your 'pdf-content-dump.raku. script I found the problem.
I had used ".Fill; .Stroke" instead of ".FillStroke" and, by using the correct alias, the warnings disappeared.
Closing this.
I'm trying to track down where the warnings are originating, but the page prints fine. I am using nested graphics subroutines on a PDF page object, and that may be confusing the parser because I cannot find any obvious graphics outside a block except calling a sub within a graphics block.
If it's just a warning (which the Ops.rakumod file says it is), maybe you could enable an option to quell such warnings.
First set of warning lines from STDERR:
From the current code, here's an example of one sub called inside another in a graphics block:
Finally, here is a simplified call tree, starting from the top entry in a script, then calling subs in a module: