diff --git a/frontend/src/core/components/shared/RightRail.tsx b/frontend/src/core/components/shared/RightRail.tsx index 08e7ed378..78c78a1b3 100644 --- a/frontend/src/core/components/shared/RightRail.tsx +++ b/frontend/src/core/components/shared/RightRail.tsx @@ -173,11 +173,14 @@ export default function RightRail() { if (currentView === 'pageEditor') { return t('rightRail.exportAll', 'Export PDF'); } + if (currentView === 'viewer') { + return terminology.download; + } if (selectedCount > 0) { return terminology.downloadSelected; } return terminology.downloadAll; - }, [currentView, selectedCount, t]); + }, [currentView, selectedCount, t, terminology]); return (
diff --git a/frontend/src/core/components/viewer/EmbedPdfViewer.tsx b/frontend/src/core/components/viewer/EmbedPdfViewer.tsx index 1d9434768..d1161e0c2 100644 --- a/frontend/src/core/components/viewer/EmbedPdfViewer.tsx +++ b/frontend/src/core/components/viewer/EmbedPdfViewer.tsx @@ -585,6 +585,11 @@ const EmbedPdfViewerContent = ({ key={currentFile && isStirlingFile(currentFile) ? currentFile.fileId : (effectiveFile.file instanceof File ? effectiveFile.file.name : effectiveFile.url)} file={effectiveFile.file} url={effectiveFile.url} + fileName={ + previewFile ? previewFile.name : + (currentFile && isStirlingFile(currentFile) ? currentFile.name : + (effectiveFile?.file instanceof File ? effectiveFile.file.name : undefined)) + } enableAnnotations={shouldEnableAnnotations} showBakedAnnotations={isAnnotationsVisible} enableRedaction={shouldEnableRedaction} diff --git a/frontend/src/core/components/viewer/LocalEmbedPDF.tsx b/frontend/src/core/components/viewer/LocalEmbedPDF.tsx index c8607495c..96026972c 100644 --- a/frontend/src/core/components/viewer/LocalEmbedPDF.tsx +++ b/frontend/src/core/components/viewer/LocalEmbedPDF.tsx @@ -60,6 +60,7 @@ const DOCUMENT_NAME = 'stirling-pdf-viewer'; interface LocalEmbedPDFProps { file?: File | Blob; url?: string | null; + fileName?: string; enableAnnotations?: boolean; enableRedaction?: boolean; isManualRedactionMode?: boolean; @@ -71,7 +72,7 @@ interface LocalEmbedPDFProps { redactionTrackerRef?: React.RefObject; } -export function LocalEmbedPDF({ file, url, enableAnnotations = false, enableRedaction = false, isManualRedactionMode = false, showBakedAnnotations = true, onSignatureAdded, signatureApiRef, annotationApiRef, historyApiRef, redactionTrackerRef }: LocalEmbedPDFProps) { +export function LocalEmbedPDF({ file, url, fileName, enableAnnotations = false, enableRedaction = false, isManualRedactionMode = false, showBakedAnnotations = true, onSignatureAdded, signatureApiRef, annotationApiRef, historyApiRef, redactionTrackerRef }: LocalEmbedPDFProps) { const { t } = useTranslation(); const [pdfUrl, setPdfUrl] = useState(null); const [, setAnnotations] = useState>([]); @@ -95,6 +96,17 @@ export function LocalEmbedPDF({ file, url, enableAnnotations = false, enableReda const rootFontSize = parseFloat(getComputedStyle(document.documentElement).fontSize); const viewportGap = rootFontSize * 3.5; + // Determine export filename - use provided fileName, or extract from file/url + let exportFileName = 'document.pdf'; + if (fileName) { + exportFileName = fileName; + } else if (file && 'name' in file) { + exportFileName = file.name; + } else if (url) { + const urlPath = url.split('/').pop() || 'document.pdf'; + exportFileName = urlPath.split('?')[0]; // Remove query params + } + return [ createPluginRegistration(DocumentManagerPluginPackage, { initialDocuments: [{ @@ -177,13 +189,13 @@ export function LocalEmbedPDF({ file, url, enableAnnotations = false, enableReda // Register export plugin for downloading PDFs createPluginRegistration(ExportPluginPackage, { - defaultFileName: 'document.pdf', + defaultFileName: exportFileName, }), // Register print plugin for printing PDFs createPluginRegistration(PrintPluginPackage), ]; - }, [pdfUrl, enableAnnotations, showBakedAnnotations]); + }, [pdfUrl, enableAnnotations, showBakedAnnotations, fileName, file, url]); // Initialize the engine with the React hook - use local WASM for offline support const { engine, isLoading, error } = usePdfiumEngine({