(
app: AppHandle,
request: MiniAppRenderSlidePageRequest,
)
| 122 | |
| 123 | #[tauri::command] |
| 124 | pub async fn miniapp_render_slide_page( |
| 125 | app: AppHandle, |
| 126 | request: MiniAppRenderSlidePageRequest, |
| 127 | ) -> Result<String, String> { |
| 128 | let width = request.width.unwrap_or(EXPORT_VIEWPORT_WIDTH as u32); |
| 129 | let height = request.height.unwrap_or(EXPORT_VIEWPORT_HEIGHT as u32); |
| 130 | let format = request.format.trim().to_ascii_lowercase(); |
| 131 | |
| 132 | match format.as_str() { |
| 133 | "png" => { |
| 134 | with_export_webview(&app, request.html, width, height, |webview| async move { |
| 135 | take_screenshot(webview, RENDER_TIMEOUT_MS) |
| 136 | .await |
| 137 | .map_err(|error| error.message) |
| 138 | }) |
| 139 | .await |
| 140 | } |
| 141 | "pdf" => { |
| 142 | let page_width_cm = (width as f64 / 96.0) * 2.54; |
| 143 | let page_height_cm = (height as f64 / 96.0) * 2.54; |
| 144 | let options = PrintOptions { |
| 145 | orientation: Some("landscape".to_string()), |
| 146 | scale: Some(1.0), |
| 147 | background: Some(true), |
| 148 | page_width: Some(page_width_cm), |
| 149 | page_height: Some(page_height_cm), |
| 150 | margin_top: Some(0.0), |
| 151 | margin_bottom: Some(0.0), |
| 152 | margin_left: Some(0.0), |
| 153 | margin_right: Some(0.0), |
| 154 | shrink_to_fit: Some(false), |
| 155 | page_ranges: None, |
| 156 | }; |
| 157 | with_export_webview(&app, request.html, width, height, |webview| async move { |
| 158 | print_page(webview, RENDER_TIMEOUT_MS, &options) |
| 159 | .await |
| 160 | .map_err(|error| error.message) |
| 161 | }) |
| 162 | .await |
| 163 | } |
| 164 | other => Err(format!("Unsupported slide render format: {other}")), |
| 165 | } |
| 166 | } |
nothing calls this directly
no test coverage detected