scitex_browser.pdf
- scitex_browser.pdf.save_as_pdf(url, output_path, **kwargs)[source]
Sync wrapper for save_as_pdf_async.
- Return type:
- async scitex_browser.pdf.save_as_pdf_async(url, output_path, *, wait_seconds=3, print_background=True, format='A4', margin_top='10mm', margin_bottom='10mm', margin_left='10mm', margin_right='10mm')[source]
Navigate to URL and save page as PDF.
- Parameters:
url (str) – URL to save as PDF.
output_path (str) – Path to save the PDF file.
wait_seconds (float) – Extra seconds to wait after page load for JS rendering.
print_background (bool) – Whether to print background graphics.
format (str) – Paper format (A4, Letter, etc.).
margin_top (str) – Page margins (e.g., “10mm”, “1in”).
margin_bottom (str) – Page margins (e.g., “10mm”, “1in”).
margin_left (str) – Page margins (e.g., “10mm”, “1in”).
margin_right (str) – Page margins (e.g., “10mm”, “1in”).
- Returns:
Absolute path of the saved PDF.
- Return type:
- async scitex_browser.pdf.detect_chrome_pdf_viewer_async(page, verbose=False, func_name='detect_chrome_pdf_viewer_async')[source]
Detect if Chrome PDF viewer is present on the page.
Universal utility for detecting PDF viewer across any browser automation workflow.
NOTE: Caller should wait for networkidle BEFORE calling this function. This function does NOT wait for networkidle to avoid redundant waits.
- async scitex_browser.pdf.click_download_for_chrome_pdf_viewer_async(page, output_path, verbose=False, func_name='click_download_for_chrome_pdf_viewer_async')[source]
Click download button in Chrome PDF viewer and save the PDF file.
This function locates the download button in Chrome’s built-in PDF viewer (typically at top-right corner) and triggers the download, then saves the file to the specified path.
- Parameters:
- Returns:
True if download succeeded and file is valid (>1KB), False otherwise
- Return type:
Example
>>> await click_download_for_chrome_pdf_viewer_async( ... page, "paper.pdf", verbose=True ... ) True
Note
Expects Chrome PDF viewer to be already loaded on the page
Download button position is at approximately (95%, 3%) of viewport
Waits up to 120 seconds for download to start
Waits 10 seconds for download to complete after starting