1

I am New to react, I am using pdf-viewer-reactjs to display the pdf file, I want to fix the height of the pdf, I tried with style, it is not working, even I wrapped the pdf with div and fix the height it is also not working, I tried even height props it is also not working, anyone please guide me with this thank u in advance.

import PDFViewer from 'pdf-viewer-reactjs'

<PDFViewer document={{url: url}} hideNavbar={true} scale={true} css={classes.pdfView}/>

2 Answers 2

1

By using CanvasCss we can minimize the height and width

<PDFViewer 
      document={{url:url}}
      hideNavbar={true}
      scale={0.2}
      canvasCss={classes.pdfView}
    />

style.js

pdfView:{
    height:"200px",
    overflow:"auto",
  }
Sign up to request clarification or add additional context in comments.

1 Comment

This is actually supported by the README for pdf-viewer-reactjs github.com/ansu5555/pdf-viewer-reactjs
0

Having a parent element with a fixed height and an overflow of hidden may solve the problem for you.

<div style={{ height: "500px", overflow: "hidden" }}>
    <PDFViewer 
        document={{url: url}} 
        hideNavbar={true}  
        scale={true} 
        css={classes.pdfView}
    />
</div>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.