|
@@ -21,8 +21,8 @@ import { PDFPresentationMode } from "./pdf_presentation_mode.js";
|
|
|
import annotationStore from "./annotation_store"
|
|
|
import { InkSign } from "./ink_sign"
|
|
|
import MessageHandler from "./message_handler"
|
|
|
-import JSZip from 'jszip';
|
|
|
-import Outlines from './Outlines'
|
|
|
+import JSZip from 'jszip'
|
|
|
+import Outline from './Outline'
|
|
|
|
|
|
GlobalWorkerOptions.workerSrc = './lib/pdf.worker.min.js'
|
|
|
const CMAP_URL = './cmaps/'
|
|
@@ -37,7 +37,7 @@ class ComPDFKitViewer {
|
|
|
this.printService = null
|
|
|
this.pdfSidebar = null
|
|
|
this.pdfOutlineViewer = null
|
|
|
- this.outlines = null
|
|
|
+ this.outlines = []
|
|
|
this.pdfLayerViewer = null
|
|
|
this.pdfDocument = null
|
|
|
this.downloadComplete = false
|
|
@@ -433,7 +433,7 @@ class ComPDFKitViewer {
|
|
|
|
|
|
getOutlines() {
|
|
|
if (this.outlines) {
|
|
|
- return this.outlines.getOutlines()
|
|
|
+ return this.outlines
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -770,10 +770,32 @@ class ComPDFKitViewer {
|
|
|
pdfThumbnailViewer.setDocument(pdfDocument);
|
|
|
}
|
|
|
|
|
|
- if (this.outlines) {
|
|
|
- await this.outlines.init()
|
|
|
+ const doc = this.doc
|
|
|
+ const messageHandler = this.messageHandler
|
|
|
+ const outlines = await messageHandler.sendWithPromise('GetOutlines', {
|
|
|
+ doc
|
|
|
+ })
|
|
|
+
|
|
|
+ function generateOutline(outline, index, parent) {
|
|
|
+ const outlineItem = new Outline({
|
|
|
+ outline,
|
|
|
+ index,
|
|
|
+ doc,
|
|
|
+ messageHandler,
|
|
|
+ parent
|
|
|
+ })
|
|
|
+ outline.children.forEach(function (outline, index) {
|
|
|
+ outlineItem.children.push(generateOutline(outline, index, outlineItem))
|
|
|
+ })
|
|
|
+
|
|
|
+ return outlineItem
|
|
|
}
|
|
|
|
|
|
+ outlines.forEach((outline, index) => {
|
|
|
+ const outlineItem = generateOutline(outline, index, null)
|
|
|
+ this.outlines.push(outlineItem)
|
|
|
+ })
|
|
|
+
|
|
|
firstPagePromise.then(pdfPage => {
|
|
|
let hash = null;
|
|
|
|
|
@@ -1372,14 +1394,8 @@ class ComPDFKitViewer {
|
|
|
});
|
|
|
this.pdfSidebar.onToggled = this.forceRendering.bind(this);
|
|
|
}
|
|
|
-
|
|
|
- this.outlines = new Outlines({
|
|
|
- doc: this.doc,
|
|
|
- messageHandler: this.messageHandler
|
|
|
- })
|
|
|
}
|
|
|
|
|
|
-
|
|
|
setInitialView(
|
|
|
storedHash,
|
|
|
{ rotation, sidebarView, scrollMode, spreadMode } = {}
|