From 2c73b83debd31f0643f4d96983d50e5da0e096c7 Mon Sep 17 00:00:00 2001 From: Luca Foppiano Date: Sun, 12 May 2024 09:07:42 +0900 Subject: [PATCH] allow width to be None --- streamlit_pdf_viewer/__init__.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/streamlit_pdf_viewer/__init__.py b/streamlit_pdf_viewer/__init__.py index c5605e19..639bb61c 100644 --- a/streamlit_pdf_viewer/__init__.py +++ b/streamlit_pdf_viewer/__init__.py @@ -78,8 +78,8 @@ 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 @@ -87,13 +87,6 @@ def pdf_viewer(input: Union[str, Path, bytes], 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")