Skip to content

Commit

Permalink
allow width to be None
Browse files Browse the repository at this point in the history
  • Loading branch information
lfoppiano committed May 12, 2024
1 parent 432f61d commit 2c73b83
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions streamlit_pdf_viewer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,15 @@ def pdf_viewer(input: Union[str, Path, bytes],
if isinstance(width, str) and width.endswith('%'):
percentage_width = float(width[:-1]) / 100
width = int(screen_width * percentage_width)
elif not isinstance(width, int):
raise TypeError("Width must be an integer or a percentage string (e.g., '70%' or 700)")
elif width is not None and not isinstance(width, int):
raise TypeError("Width must be an integer or a percentage string (e.g., '70%' or 700) or None")

if isinstance(height, str) and height.endswith('%'):
percentage_height = float(height[:-1]) / 100
height = int(screen_height * percentage_height)
elif height is not None and not isinstance(height, int):
raise TypeError("Height must be an integer, a percentage string (e.g., '70%'), or None")



# Validate width and height parameters
if width is not None and not isinstance(width, int):
raise TypeError("Width must be an integer")
if height is not None and not isinstance(height, int):
raise TypeError("Height must be an integer or None")
if not all(isinstance(page, int) for page in pages_to_render):
raise TypeError("pages_to_render must be a list of integers")

Expand Down

0 comments on commit 2c73b83

Please sign in to comment.