fix(web): pass pdf.js cMap/standard font URLs so CID-font PDFs render in preview (#18249)

This commit is contained in:
euvre
2026-08-14 02:08:46 -07:00
committed by GitHub
parent 24033bf199
commit ea3a2b2676
2 changed files with 12 additions and 0 deletions

View File

@@ -33,6 +33,7 @@ import { getAuthorization } from '@/utils/authorization-util';
import { useCatchDocumentError } from './hooks';
type PdfLoaderProps = React.ComponentProps<typeof PdfLoader> & {
httpHeaders?: Record<string, string>;
standardFontDataUrl?: string;
};
const Loader = PdfLoader as React.ComponentType<PdfLoaderProps>;
@@ -100,6 +101,9 @@ const PdfPreview = ({
</div>
}
workerSrc="/pdfjs-dist/pdf.worker.min.js"
cMapUrl="/pdfjs-dist/cmaps/"
cMapPacked={true}
standardFontDataUrl="/pdfjs-dist/standard_fonts/"
errorMessage={<FileError>{error}</FileError>}
>
{(pdfDocument) => {

View File

@@ -160,6 +160,14 @@ export default defineConfig(({ mode }) => {
src: 'node_modules/monaco-editor/min/vs/',
dest: './',
},
{
src: 'node_modules/pdfjs-dist/cmaps/',
dest: 'pdfjs-dist/',
},
{
src: 'node_modules/pdfjs-dist/standard_fonts/',
dest: 'pdfjs-dist/',
},
],
}),
createHtmlPlugin({