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

The scale is not updated at the first download #494

Open
katefadeeva opened this issue Aug 28, 2024 · 0 comments
Open

The scale is not updated at the first download #494

katefadeeva opened this issue Aug 28, 2024 · 0 comments

Comments

@katefadeeva
Copy link

katefadeeva commented Aug 28, 2024

I need to adjust the scale according to the screen size. To achieve this, during the initial rendering, I calculate the scale based on the block's offsetWidth. The scale variable changes, but the PDF is still displayed with the previous scale. Could you please advise what might be causing this issue?

    const [scale, setScale] = useState(1);
    const { pdfDocument } = usePdf({
        file: path,
        page,
        canvasRef,
        scale,
    });
    
     useEffect(() => {
        if (modalRef.current) {
            setScale(+(modalRef.current?.offsetWidth / 595 - 0.02).toFixed(2));
        }

    }, [modalRef.current?.offsetWidth]);

595 is the default width of the pdf document, this is indicated if you set scale = 1

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