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

Barcode reading issue with huge zoomed #3

Open
UbikZ opened this issue Aug 20, 2021 · 0 comments
Open

Barcode reading issue with huge zoomed #3

UbikZ opened this issue Aug 20, 2021 · 0 comments

Comments

@UbikZ
Copy link

UbikZ commented Aug 20, 2021

Hi there,

I have notice some issue within the repository code (and the blog thus the blog documentation https://www.pdftron.com/blog/annotation/stamp-and-read-barcode-on-pdfs-with-pdftron-sdk). I have tried to find some solution but nothing relevant since I would like to handle this properly.

The issues is not really associated to the barcode reading, but the extract zone from pageCanvas.

  1. First, I think the canvas multiplier is missing on x and y coordinates :
        const x = (annotation.X * zoom - leftOffset)  * canvasMultiplier;
        const y = (annotation.Y * zoom - topOffset)  * canvasMultiplier;
        const width = annotation.Width * zoom * canvasMultiplier;
        const height = annotation.Height * zoom * canvasMultiplier;
  1. Secondly, the main issue is about the "pageCanvas" part. Regarding the document, a zoom threshold turns the pageCanvas from a "complete" render to a "partial" render. It's pretty obvious, it's to avoid getting a too much complexe canvas and to only keep what we see. But in our zone "extraction", we do not consider this behavior thus what we extract is wrong.

I have checked the API and I have found nothing to solve this issue.

I had the idea at the moment to use the DocViewer.getScrollViewElement() to get scrollLeft and scrollTop in order to substract this numbers from the x and y... But I have not found and event which could tell me that the canva is only one part of the initial document.

To reproduce it's pretty simple, just need to create a stamp which minimize in the bottom right of the document. We zoom at 500% for exemple and we try to read the barcode.
I hava added this code at the end in order to see draw and see the extracted zone.

            const pageCanvasCtx = pageCanvas.getContext('2d');
            pageCanvasCtx.strokeStyle = 'red';
            pageCanvasCtx.strokeRect(x, y, width, height);
            console.log(copyCanvas.toDataURL('image/png'));

Thank's for the help.

Gabriel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant