diff options
author | Andrew Kim <andrewdkim@users.noreply.github.com> | 2019-02-23 16:19:45 -0500 |
---|---|---|
committer | Andrew Kim <andrewdkim@users.noreply.github.com> | 2019-02-23 16:19:45 -0500 |
commit | 07f5e56508c362725db003736a0f7980cd72107d (patch) | |
tree | 697242d7468203c46a5847cef2d24bd0d4001968 /src/documents/Documents.ts | |
parent | 5b55e1b6081393989ca35d2964da9604c2a93802 (diff) |
PDFNode
Diffstat (limited to 'src/documents/Documents.ts')
-rw-r--r-- | src/documents/Documents.ts | 28 |
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); |