Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stamps are not rendered correctly #14105

Closed
SHartmann-Roesberg opened this issue Oct 6, 2021 · 4 comments · Fixed by #14998
Closed

stamps are not rendered correctly #14105

SHartmann-Roesberg opened this issue Oct 6, 2021 · 4 comments · Fixed by #14998
Assignees

Comments

@SHartmann-Roesberg
Copy link

PDF file:
Stamp_Problem.pdf

Configuration:

  • Web browser and its version: current Firefox, Chrome
  • Operating system and its version: Windows 10
  • PDF.js version: current (2.10.377), using viewer from demo site

Steps to reproduce the problem:
Open the attached pdf in a viewer.
If you open the pdf with Acrobat or with integrated Chrome PDF Viewer etc. it looks like in screenshot 1.
If you open it with pdf-js in Chrome, Firefox, Edge or use the integrated PDFViewer of Firefox it looks like screenshot 2.

expected behavior:

The stamps are rendered on top of the table and shown correctly

image

What went wrong:

the stamps are only visible on top of the table lines

image

@Snuffleupagus
Copy link
Collaborator

Interestingly, if you skip the regular operatorList[1] and only render the Annotations this actually works correctly!
Hence it seems that we're somehow not correctly resetting the state after the "normal" operatorList and before the Annotation-operatorLists are handled (in the src/display/canvas.js file).


[1] By replacing all of

pdf.js/src/core/document.js

Lines 346 to 355 in 2822ba4

return partialEvaluator
.getOperatorList({
stream: contentStream,
task,
resources: this.resources,
operatorList: opList,
})
.then(function () {
return opList;
});
with a return opList; line.

@calixteman
Copy link
Contributor

I think we can easily fix this in using the hasOwnCanvas flag.

@Snuffleupagus
Copy link
Collaborator

Snuffleupagus commented Jun 6, 2022

I think we can easily fix this in using the hasOwnCanvas flag.

That'd seem like a work-around, rather than a "real" fix, and it seems quite important (to me at least) that we figure out why it happens since this does suggest something being wrong w.r.t. resetting the canvas-state before rendering Annotations.

Note that these documents should obviously render correctly even if no separate AnnotationLayer is actually being used.

@calixteman
Copy link
Contributor

The last commands on the page are:

0 G 0 J 0 j 1.44 w 10 M []0 d 411.84 149.76 1.68 630.96 re W n
412.8 780.48 m 412.8 149.76 l S

So the clip region is very small (width = 1.68) and then we draw the annotations.
So drawing in a new canvas in using the hasOwnCanvas stuff is helping to have no clipping path: it's why it works.

I think that a correct fix would be to restore (in beginAnnotations) the context saved when we start to draw the page in order to have something clean before starting drawing the annotations.
I suppose it doesn't really make sense to use something which has been set during the page drawing (before the annotations rendering).
@Snuffleupagus, wdyt ?

calixteman added a commit to calixteman/pdf.js that referenced this issue Jun 7, 2022
…#14105)

- each annotation must be rendered independently of the others. So
  after having rendered each annotation, the canvas states are reset
  in order to have something clean to render the next one.
calixteman added a commit to calixteman/pdf.js that referenced this issue Jun 7, 2022
…#14105)

- each annotation must be rendered independently of the others. So
  after having rendered each annotation, the canvas states are reset
  in order to have something clean to render the next one.
Snuffleupagus added a commit that referenced this issue Jun 7, 2022
Reset all the canvas states after rendering each annotations (#14105)
rousek pushed a commit to signosoft/pdf.js that referenced this issue Aug 10, 2022
…#14105)

- each annotation must be rendered independently of the others. So
  after having rendered each annotation, the canvas states are reset
  in order to have something clean to render the next one.
@marco-c marco-c moved this to Closed in PDF.js quality Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Closed
Development

Successfully merging a pull request may close this issue.

3 participants