Skip to content

Add PDF document viewer component with outline, pages, zoom, search, and print#626

Merged
petebachant merged 2 commits into
mainfrom
pub-view
Jun 3, 2026
Merged

Add PDF document viewer component with outline, pages, zoom, search, and print#626
petebachant merged 2 commits into
mainfrom
pub-view

Conversation

@petebachant

Copy link
Copy Markdown
Member

Resolves #625

image

Did not use the embedded viewer so we could retain highlighting/commenting, but this should provide the desired features.

@petebachant

Copy link
Copy Markdown
Member Author

Does this appear to be missing anything @rebeccamccabe?

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR replaces basic <embed>-based PDF rendering with a shared PdfDocumentViewer component (built on react-pdf-highlighter / pdf.js) to give Publications and Files the richer PDF navigation experience already available elsewhere (outline/sections, page jump, zoom, search, print, open/download) while preserving annotation/highlighting support.

Changes:

  • Added PdfDocumentViewer with toolbar controls (outline, paging, zoom, search, print, open/download) and optional highlight/selection integration.
  • Switched Publications and Files PDF rendering from <embed> to PdfDocumentViewer.
  • Refactored PdfAnnotator to delegate PDF rendering/navigation to PdfDocumentViewer while keeping comment/highlight behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
frontend/src/components/Publications/PublicationView.tsx Uses shared PDF viewer instead of <embed> for publication PDFs.
frontend/src/components/Publications/PdfAnnotator.tsx Delegates PDF rendering/navigation to the shared viewer; keeps annotation integration via props.
frontend/src/components/Files/FileContent.tsx Uses shared PDF viewer for PDF files instead of <embed>.
frontend/src/components/Common/PdfDocumentViewer.tsx New shared PDF viewer implementing outline, paging, zoom, search, print, and open/download + optional highlighting.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +155 to +169
<Text
fontSize="xs"
py={0.5}
noOfLines={2}
cursor={node.pageNumber ? "pointer" : "default"}
color={
node.pageNumber && node.pageNumber === currentPage
? "ui.main"
: undefined
}
_hover={node.pageNumber ? { color: "ui.main" } : undefined}
onClick={() => node.pageNumber && onSelect(node.pageNumber)}
>
{node.title}
</Text>
Comment on lines +643 to +645
}, [pdfDocument])

const runSearch = useCallback(
Comment on lines +646 to +670
async (q: string) => {
const term = q.trim().toLowerCase()
if (!term) {
setMatchPages([])
setMatchIdx(0)
return
}
setSearching(true)
try {
const pages = await ensureTextIndex()
const hits: number[] = []
pages.forEach((text, i) => {
if (text.includes(term)) hits.push(i + 1)
})
setMatchPages(hits)
setMatchIdx(0)
if (hits.length > 0) goToPage(hits[0])
mixpanel.track("Searched PDF", {
source,
query_length: term.length,
num_matching_pages: hits.length,
})
} finally {
setSearching(false)
}
@petebachant petebachant merged commit fc39d9e into main Jun 3, 2026
4 checks passed
@petebachant petebachant deleted the pub-view branch June 3, 2026 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Publications should show PDFs in same navigator as All Files

2 participants