@@ -12,6 +12,7 @@ import { supabase } from '@/lib/supabaseClient';
1212import HighlightedText from './HighlightedText' ;
1313import AnnotationSidebar from './AnnotationSidebar' ;
1414import AnnotationToolbar from './AnnotationToolbar' ;
15+ import { generateAnnotatedPDF } from '@/services/pdfExportService' ;
1516interface DocumentViewerProps {
1617 documentId : string ;
1718}
@@ -229,6 +230,17 @@ export default function DocumentViewer({ documentId }: DocumentViewerProps) {
229230 }
230231 } ;
231232
233+ const handleExportPDF = async ( ) => {
234+ if ( ! document ) {
235+ return ;
236+ }
237+
238+ try {
239+ await generateAnnotatedPDF ( document , annotations ) ;
240+ } catch ( err ) {
241+ console . error ( 'Failed to export PDF:' , err ) ;
242+ }
243+ } ;
232244
233245 if ( loading ) {
234246 return (
@@ -303,6 +315,16 @@ export default function DocumentViewer({ documentId }: DocumentViewerProps) {
303315 < span > { formatDate ( document . created_at ) } </ span >
304316 </ div >
305317 </ div >
318+ < button
319+ onClick = { handleExportPDF }
320+ disabled = { ! document . raw_text }
321+ className = "px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 disabled:bg-gray-300 disabled:cursor-not-allowed flex items-center space-x-2 transition-colors"
322+ >
323+ < svg className = "w-5 h-5" fill = "none" stroke = "currentColor" viewBox = "0 0 24 24" >
324+ < path strokeLinecap = "round" strokeLinejoin = "round" strokeWidth = { 2 } d = "M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
325+ </ svg >
326+ < span > Export PDF</ span >
327+ </ button >
306328 </ div >
307329 </ div >
308330 </ div >
@@ -382,7 +404,6 @@ export default function DocumentViewer({ documentId }: DocumentViewerProps) {
382404
383405 { permissions . canView && (
384406 < AnnotationSidebar
385- documentId = { documentId }
386407 annotations = { annotations }
387408 selectedAnnotationId = { selectedAnnotationId }
388409 canCreate = { permissions . canCreate }
0 commit comments