aboutsummaryrefslogtreecommitdiff
path: root/src/client/documents/Documents.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/documents/Documents.ts')
-rw-r--r--src/client/documents/Documents.ts17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index 1d24ff7d2..47b8ea844 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -15,6 +15,8 @@ import { Key } from "../../fields/Key"
import { Field } from "../../fields/Field";
import { KeyValueBox } from "../views/nodes/KeyValueBox"
import { KVPField } from "../../fields/KVPField";
+import { PDFField } from "../../fields/PDFField";
+import { PDFNode } from "../views/nodes/PDFNode";
export interface DocumentOptions {
x?: number;
@@ -38,7 +40,9 @@ export namespace Documents {
let webProto: Document;
let collProto: Document;
let kvpProto: Document;
+ let pdfProto: Document;
const textProtoId = "textProto";
+ const pdfProtoId = "pdfProto";
const imageProtoId = "imageProto";
const webProtoId = "webProto";
const collProtoId = "collectionProto";
@@ -92,6 +96,14 @@ export namespace Documents {
textProto = setupPrototypeOptions(textProtoId, "TEXT_PROTO", FormattedTextBox.LayoutString(),
{ x: 0, y: 0, width: 300, height: 150, layoutKeys: [KeyStore.Data] });
}
+ function GetPdfPrototype(): Document {
+ if (!pdfProto) {
+ pdfProto = setupPrototypeOptions(pdfProtoId, "PDF_PROTO", CollectionView.LayoutString("AnnotationsKey"),
+ { x: 0, y: 0, nativeWidth: 600, width: 300, layoutKeys: [KeyStore.Data, KeyStore.Annotations] });
+ pdfProto.SetText(KeyStore.BackgroundLayout, PDFNode.LayoutString());
+ }
+ return pdfProto;
+ }
function GetWebPrototype(): Document {
return webProto ? webProto :
webProto = setupPrototypeOptions(webProtoId, "WEB_PROTO", WebBox.LayoutString(),
@@ -120,6 +132,9 @@ export namespace Documents {
export function TextDocument(options: DocumentOptions = {}) {
return SetInstanceOptions(GetTextPrototype(), options, "", TextField);
}
+ export function PdfDocument(url: string, options: DocumentOptions = {}) {
+ return SetInstanceOptions(GetPdfPrototype(), options, new URL(url), PDFField);
+ }
export function WebDocument(url: string, options: DocumentOptions = {}) {
return SetInstanceOptions(GetWebPrototype(), options, new URL(url), WebField);
}
@@ -141,8 +156,6 @@ export namespace Documents {
return assignOptions(deleg, options);
}
-
-
// example of custom display string for an image that shows a caption.
function EmbeddedCaption() {
return `<div style="height:100%">