Skip to content

defaultZoomLevel in embedpdf plugin does not accept numerical values #271

@d3cie

Description

@d3cie

Summary

The defaultZoomLevel property within the zoom plugin of the embedpdf snippet only appears to accept string values like "automatic", "fit-page", or "fit-width", and fails when a numerical value is provided to set a specific zoom ratio.

Description

The defaultZoomLevel property, when used with a numerical value (e.g., 0.75), does not correctly set the initial zoom level for the embedded PDF document. The library's type definitions suggest it supports numbers, in addition to the ZoomMode type.

This prevents developers from setting a precise, fixed initial zoom level for the PDF viewer.

Minimal Reproduction

Here is a minimal, complete, and verifiable example demonstrating the issue. The expected behavior is for the PDF to load with a zoom level of .75 , but it defaults to an unspecified or automatic level instead.

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>EmbedPDF Zoom Issue Repro</title>
    <script async type="module">
        import EmbedPDF from 'https://snippet.embedpdf.com/embedpdf.js';

        const EPDFinstance = EmbedPDF.init({
            type: 'container',
            target: document.getElementById('pdf-viewer'),
            src: 'https://snippet.embedpdf.com/ebook.pdf',
            worker: true,
            plugins: {
                zoom: {
                    // This numerical value (0.75) is being ignored.
                    defaultZoomLevel: 0.75, 
                }
            }
        });
    </script>
</head>

<body>
    <div id="pdf-viewer" style="height: 400px"></div>
</body>

</html>

Expected Behavior

When defaultZoomLevel is set to a number (e.g., 0.75), the PDF should load with the document initially rendered at that specific zoom ratio.

Actual Behavior

The numerical value provided for defaultZoomLevel is ignored, and the PDF loads using a default zoom behavior (likely equivalent to "automatic" or a standard fit setting), despite the explicit numerical configuration.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions