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

PDFViewer fails to render Document many times, when updating arrays of items in react #1878

Open
4 tasks done
albjeremias opened this issue Sep 15, 2024 · 1 comment
Open
4 tasks done
Labels
bug Something isn't working

Comments

@albjeremias
Copy link

Before you start - checklist

  • I followed instructions in documentation written for my React-PDF version
  • I have checked if this bug is not already reported
  • I have checked if an issue is not listed in Known issues
  • If I have a problem with PDF rendering, I checked if my PDF renders properly in PDF.js demo

Description

I'd like to known if its possible to only show the PDFViewer if the Document was finished rendering.! Thanks! :)

   <PDFViewer style={{ width: '100%', height: '500px' }}>
<Document>
      <Page size="A4" style={styles.page}>
        <View style={styles.mainHeader}>
          <Image
            style={styles.networkLogo}
            src={makeImageUrl(selectedNetwork.image)}
          />
          <Text style={styles.networkName}>
            {t('bulletin.pdfNetworkTitle', [
              selectedNetwork.name,
              readableDate(dateTime),
            ])}
          </Text>
          <ButtonRows buttons={buttons} buttonTypes={buttonTypes} />
        </View>
      </Page>
    </Document>
          </PDFViewer>

the whole source code is here:
https://github.com/helpbuttons/helpbuttons/blob/dev/web/src/pages/Bulletin/index.tsx#L149

Steps to reproduce

write code to generate and render a PDF in react on-the-fly

Expected behavior

I expected to have a way to known how the pdf is being loaded, so that PDFViewer won't fail to load

Actual behavior

it fails to load the pdf sometimes.

An error occurred while loading the PDF.

PDF.js v4.5.252 (build: e44e4db52)
Message: 2152398850 [viewer.mjs:12081:13](resource://pdf.js/web/viewer.mjs)
    _otherError resource://pdf.js/web/viewer.mjs:12081
    _documentError resource://pdf.js/web/viewer.mjs:12058
    windowMessage resource://pdf.js/web/viewer.mjs:2039
    (Async: EventListener.handleEvent)
    initPassiveLoading resource://pdf.js/web/viewer.mjs:2001
    run resource://pdf.js/web/viewer.mjs:11812
    webViewerLoad resource://pdf.js/web/viewer.mjs:13633

Additional information

No response

Environment

  • Browser (if applicable): firefox
  • React-PDF version: ^3.4.4"
  • React version: 18.2.0
  • Bundler name and version (if applicable):
@albjeremias albjeremias added the bug Something isn't working label Sep 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants
@albjeremias and others