Skip to content

Commit

Permalink
👋geektime docs
Browse files Browse the repository at this point in the history
  • Loading branch information
zkep committed Feb 23, 2025
1 parent 0f66a86 commit 0df4c8a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 5 additions & 0 deletions compress.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ def compress(source: str, target: str, power: int = 0):
:param str source: source PDF file
:param str target: target location to save the compressed PDF
:param int power: power of the compression. Default value is 0. This can be 0: default, 1: prepress, 2: printer, 3: ebook, 4: screen
screen 低画质
ebook 中等画质
printer 打印机画质
prepress 最大画质
defaul 默认画质
"""

quality = {
Expand Down
6 changes: 2 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,7 @@ def make_all_pdf(source, output, timeout, compress, power, port):
webdriver_options.add_experimental_option("prefs", webdriver_prefs)
webdriver_options.add_experimental_option("excludeSwitches", ['enable-automation'])

http_client = requests.Session()
download_manager = WDMDownloadManager(http_client=http_client)
download_manager = WDMDownloadManager(http_client=reqsession)
service = Service(ChromeDriverManager(download_manager=download_manager).install())
host = f"http://127.0.0.1:{port}/"
for dirname, _, file_lst in os.walk(source):
Expand Down Expand Up @@ -399,8 +398,7 @@ def make_pdf(source, output, timeout, compress, power, port):
webdriver_options.add_argument("--disable-dev-shm-usage")
webdriver_options.experimental_options["prefs"] = webdriver_prefs

http_client = requests.Session()
download_manager = WDMDownloadManager(http_client=http_client)
download_manager = WDMDownloadManager(http_client=reqsession)
service = Service(ChromeDriverManager(download_manager=download_manager).install())
host = f"http://127.0.0.1:{port}/"
source = os.path.abspath(source)
Expand Down

0 comments on commit 0df4c8a

Please sign in to comment.