@@ -455,6 +455,7 @@ struct PlotData<'a> {
455455/// .webdriver_port(4444)
456456/// .spawn_webdriver(true)
457457/// .offline_mode(false)
458+ /// .pdf_export_timeout(500)
458459/// .build()
459460/// .expect("Failed to build StaticExporter");
460461/// ```
@@ -465,6 +466,7 @@ struct PlotData<'a> {
465466/// - WebDriver URL: "http://localhost"
466467/// - Spawn webdriver: true (automatically manages WebDriver lifecycle)
467468/// - Offline mode: false
469+ /// - PDF export timeout: 250ms
468470/// - Browser capabilities: Default Chrome/Firefox headless options
469471/// - Automatic WebDriver detection and connection reuse
470472pub struct StaticExporterBuilder {
@@ -476,6 +478,8 @@ pub struct StaticExporterBuilder {
476478 spawn_webdriver : bool ,
477479 /// Use bundled JS libraries instead of CDN (default: false)
478480 offline_mode : bool ,
481+ /// PDF export timeout in milliseconds (default: 250)
482+ pdf_export_timeout : u32 ,
479483 /// Browser command-line flags (e.g., "--headless", "--no-sandbox")
480484 webdriver_browser_caps : Vec < String > ,
481485}
@@ -488,13 +492,15 @@ impl Default for StaticExporterBuilder {
488492 /// - WebDriver URL: "http://localhost"
489493 /// - Spawn webdriver: true
490494 /// - Offline mode: false
495+ /// - PDF export timeout: 250ms
491496 /// - Default browser capabilities for headless operation
492497 fn default ( ) -> Self {
493498 Self {
494499 webdriver_port : webdriver:: WEBDRIVER_PORT ,
495500 webdriver_url : webdriver:: WEBDRIVER_URL . to_string ( ) ,
496501 spawn_webdriver : true ,
497502 offline_mode : false ,
503+ pdf_export_timeout : 250 ,
498504 webdriver_browser_caps : {
499505 #[ cfg( feature = "chromedriver" ) ]
500506 {
@@ -596,6 +602,30 @@ impl StaticExporterBuilder {
596602 self
597603 }
598604
605+ /// Sets the PDF export timeout in milliseconds.
606+ ///
607+ /// This timeout controls how long to wait for the SVG image to load before
608+ /// proceeding with PDF generation. A longer timeout may be needed for
609+ /// complex plots or slower systems.
610+ ///
611+ /// # Examples
612+ ///
613+ /// ```rust
614+ /// use plotly_static::StaticExporterBuilder;
615+ ///
616+ /// // Set a longer timeout for complex plots
617+ /// let builder = StaticExporterBuilder::default()
618+ /// .pdf_export_timeout(500);
619+ ///
620+ /// // Use default timeout (250ms)
621+ /// let builder = StaticExporterBuilder::default()
622+ /// .pdf_export_timeout(250);
623+ /// ```
624+ pub fn pdf_export_timeout ( mut self , timeout_ms : u32 ) -> Self {
625+ self . pdf_export_timeout = timeout_ms;
626+ self
627+ }
628+
599629 /// Sets custom browser capabilities for the WebDriver.
600630 ///
601631 /// # Examples
@@ -658,6 +688,7 @@ impl StaticExporterBuilder {
658688 webdriver_url : self . webdriver_url . clone ( ) ,
659689 webdriver : wd,
660690 offline_mode : self . offline_mode ,
691+ pdf_export_timeout : self . pdf_export_timeout ,
661692 webdriver_browser_caps : self . webdriver_browser_caps . clone ( ) ,
662693 runtime,
663694 webdriver_client : None ,
@@ -735,6 +766,9 @@ pub struct StaticExporter {
735766 /// Use bundled JS libraries instead of CDN
736767 offline_mode : bool ,
737768
769+ /// PDF export timeout in milliseconds
770+ pdf_export_timeout : u32 ,
771+
738772 /// Browser command-line flags (e.g., "--headless", "--no-sandbox")
739773 webdriver_browser_caps : Vec < String > ,
740774
@@ -969,7 +1003,7 @@ impl StaticExporter {
9691003 plot. scale. into( ) ,
9701004 ] ;
9711005
972- ( pdf_export_js_script ( ) , args)
1006+ ( pdf_export_js_script ( self . pdf_export_timeout ) , args)
9731007 }
9741008 _ => {
9751009 let args = vec ! [
0 commit comments