aboutsummaryrefslogtreecommitdiff
path: root/src/documents/Documents.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/documents/Documents.ts')
-rw-r--r--src/documents/Documents.ts28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/documents/Documents.ts b/src/documents/Documents.ts
index 90124d36c..cca6f50e9 100644
--- a/src/documents/Documents.ts
+++ b/src/documents/Documents.ts
@@ -11,6 +11,8 @@ import { ImageField } from "../fields/ImageField";
import { ImageBox } from "../views/nodes/ImageBox";
import { CollectionFreeFormView } from "../views/collections/CollectionFreeFormView";
import { FIELD_ID } from "../fields/Field";
+import { PDFBox } from "../views/nodes/PDFBox";
+import { PDFField } from "../fields/PDFField";
interface DocumentOptions {
x?: number;
@@ -126,6 +128,32 @@ export namespace Documents {
return Server.GetDocument(imageProtoId, true)!;
}
+ let PDFProtoId: FIELD_ID;
+ function GetPDFPrototype(): Document {
+ if (PDFProtoId === undefined) {
+ let PDFProto = new Document();
+ PDFProtoId = PDFProto.Id;
+ PDFProto.Set(KeyStore.Title, new TextField("PDF PROTO"));
+ PDFProto.Set(KeyStore.X, new NumberField(0));
+ PDFProto.Set(KeyStore.Y, new NumberField(0));
+ PDFProto.Set(KeyStore.Width, new NumberField(300));
+ PDFProto.Set(KeyStore.Height, new NumberField(300));
+ PDFProto.Set(KeyStore.Layout, new TextField(PDFBox.LayoutString()));
+ PDFProto.Set(KeyStore.LayoutKeys, new ListField([KeyStore.Data]));
+ Server.AddDocument(PDFProto);
+ return PDFProto;
+ }
+ return Server.GetDocument(PDFProtoId, true)!;
+ }
+
+ export function PDFDocument(url: string, options: DocumentOptions = {}): Document{
+ let doc = GetPDFPrototype().MakeDelegate();
+ setupOptions(doc, options);
+ doc.Set(KeyStore.Data, new PDFField(new URL(url)));
+ Server.AddDocument(doc);
+ return Server.GetDocument(doc.Id, true);
+ }
+
export function ImageDocument(url: string, options: DocumentOptions = {}): Document {
let doc = GetImagePrototype().MakeDelegate();
setupOptions(doc, options);