How to Zoom fitz.Pixmap to precise size #1048
              
                
                  
                  
                    Answered
                  
                  by
                    JorjMcKie
                  
              
          
                  
                    
                      dmytro-balabukh
                    
                  
                
                  asked this question in
                Looking for help
              
            -
| I need my PDF page to gently fit the borders of the Reading Window. I intend to do it like, QScrollArea doesn't activate, but it's near to it, also all proportions must be saved. In Matrix, I can't give exact height, width, so what can you suggest? I'm using: | 
Beta Was this translation helpful? Give feedback.
      
      
          Answered by
          
            JorjMcKie
          
      
      
        May 12, 2021 
      
    
    Replies: 1 comment
-
| Without going into Qt details (because I am not very acquainted with it, as I mostly using wxPython): 
 if width / height < WIDTH / HEIGHT:
    zoom = HEIGHT / height
else:
    zoom = WIDTH / width
mat = fitz.Matrix(zoom, zoom)
pix = page.getPixmap(matrix=mat, alpha=False)
qimg = QImage(pix.samples, pix.width, pix.height, pix.stride, QImage.Format_RGB888) | 
Beta Was this translation helpful? Give feedback.
                  
                    0 replies
                  
                
            
      Answer selected by
        dmytro-balabukh
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Without going into Qt details (because I am not very acquainted with it, as I mostly using wxPython):
WIDTH, resp.HEIGHT, and the page's dimensionwidth, respheight(i.e.page.rect.width,page.rect.height)