#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere
TypeScript dockerhacktoberfestjavapdfpdf-converterpdf-editorpdf-manipulationpdf-mergerpdf-ocrpdf-toolspdf-web-appspdfmergerself-hosted
Fix viewer export (#5713)
Reece Brownee01734fb7df9
diff --git a/frontend/src/core/components/shared/RightRail.tsx b/frontend/src/core/components/shared/RightRail.tsxindex 08e7ed3785..78c78a1b32 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 (<div ref={sidebarRefs.rightRailRef} className="right-rail" data-sidebar="right-rail">diff --git a/frontend/src/core/components/viewer/EmbedPdfViewer.tsx b/frontend/src/core/components/viewer/EmbedPdfViewer.tsxindex 1d94347684..d1161e0c2d 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.tsxindex c8607495ce..96026972cf 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<RedactionPendingTrackerAPI>;}-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<string | null>(null);const [, setAnnotations] = useState<Array<{id: string, pageIndex: number, rect: any}>>([]);@@ -95,6 +96,17 @@ export function LocalEmbedPDF({ file, url, enableAnnotations = false, enableRedaconst 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 PDFscreatePluginRegistration(ExportPluginPackage, {- defaultFileName: 'document.pdf',+ defaultFileName: exportFileName,}),// Register print plugin for printing PDFscreatePluginRegistration(PrintPluginPackage),];- }, [pdfUrl, enableAnnotations, showBakedAnnotations]);+ }, [pdfUrl, enableAnnotations, showBakedAnnotations, fileName, file, url]);// Initialize the engine with the React hook - use local WASM for offline supportconst { engine, isLoading, error } = usePdfiumEngine({