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

We are facing the issue were in PDF file the first page is getting duplicated. #1756

Open
3 of 4 tasks
tmkrishnareddy opened this issue Apr 8, 2024 · 1 comment
Open
3 of 4 tasks
Labels
question Further information is requested

Comments

@tmkrishnareddy
Copy link

tmkrishnareddy commented Apr 8, 2024

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

We are getting duplicate 1st page while rendering the PDF using base64 alpha numeric code.

  useEffect(() => {
    setLoading(true);
    apis
      .getPdf(location.state.pdfId)

      .then(data => {
        // // Create a Blob from the PDF Stream
        const getdata = data.content.$binary.base64;
        const contentType = 'application/pdf';
        const getdatatotal = {
          doc: `data:${contentType};base64,${getdata}`,
        };
        setPdf(getdatatotal.doc);
        setLoading(false);
      })
      .catch(() => {
        setLoading(false);
      });
  }, [location]);

HTML Code

 <div className={pdfcss['pdf-container']} onCopy={e => stopCopy(e)}>
          <button type='button' onClick={() => navigate(returnPath, { state: returnStateVal })}>
            <img alt='BackBtn' src={Back} />
            Back
          </button>
          <h3 className={pdfcss['pdf-title']}>Knowledge Article - {location.state.pdfId}</h3>
          <div className={pdfcss.controls}>
            Zoom
            <button type='button' onClick={increaseZoom} /* disabled={pageNumber === 1} */>
              +
            </button>
            {zoomLevel}
            <button type='button' onClick={desceaseZoom} /* disabled={pageNumber === numPages} */>
              -
            </button>
          </div>
          <div className={pdfcss['center-pdf']}>
            <Document
              file={`data:application/pdf;base64${addpdf}`}
              onLoadSuccess={onDocumentLoadSuccess}
              loading={<PageLoader className='loader' />}>
              <WatermarkWrapper>
                <StyledWatermark
                  text={' '}
                  style={{
                    width: 610,
                    height: 790,
                  }}
                  multiple
                  className='space-props-test'>

Steps to reproduce

NA

Expected behavior

PDF should render without duplication of first page

Actual behavior

PDF is rendering with duplication of first page.

Additional information

No response

Environment

  • Browser (if applicable): 123.0.6312.86
  • React-PDF version: 5.5.0
  • React version: 17.0.2
  • Webpack version (if applicable):
@tmkrishnareddy tmkrishnareddy added the bug Something isn't working label Apr 8, 2024
@wojtekmaj
Copy link
Owner

I don't see anything wrong with the code you've provided, but it's cut off at a crucial part where you actually render the pages, which makes me unable to help.

@wojtekmaj wojtekmaj added question Further information is requested and removed bug Something isn't working labels Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants