Skip to content

Large image in pdf not displayed in IOS #16680

Closed as not planned
Closed as not planned

Description

@gabifuse

Hello! I have a pdf file that consist only of a large image (4000px4000px).
When loading the page:

const pdf = await pdfjs.getDocument(data }.promise;
const canvas = document.createElement('canvas');
const page = await pdf.getPage(0);
 viewport = page.getViewport({ scale: 1 });
const context = canvas.getContext('2d');
canvas.height = viewport.height;
canvas.width = viewport.width;
await page.render({ canvasContext: context, viewport }).promise;
const pageAsImage = canvas.toDataURL()

I get the following error in IOS

Canvas area exceeds the maximum limit (width * height > 16777216)

I understand the error but how i can display the page any way?

What im trying to achieve at the end of day is displaying the pdf page to the client.
Btw the same error happens i use react-pdf.
How i can handle this?

Thanks in advance,
Gabi.

Activity

  1. Snuffleupagus commented on Jul 12, 2023

    @Snuffleupagus
    Collaborator

    I get the following error in IOS
    Canvas area exceeds the maximum limit (width * height > 16777216)

    Please note that this is a limitation of the browser itself.

    Furthermore, beginning with PDF.js version 3.5.141 we're attempting to downsize large images. However this depends on OffscreenCanvas being available in the browser, and Safari was (comparatively) slow at implementing this; see https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas#browser_compatibility


    For future reference: When opening an issue, please provide all of the information requested in https://github.com/mozilla/pdf.js/blob/master/.github/ISSUE_TEMPLATE.md since as-is this isn't really actionable/valid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions