diff options
Diffstat (limited to 'src/documents/Documents.ts')
-rw-r--r-- | src/documents/Documents.ts | 52 |
1 files changed, 27 insertions, 25 deletions
diff --git a/src/documents/Documents.ts b/src/documents/Documents.ts index 61d2e18b9..6dce4e8f0 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 {PDFField} from "../fields/PDFField"; +import {PDFNode} from "../views/nodes/PDFNode" interface DocumentOptions { x?: number; @@ -127,31 +129,31 @@ export namespace Documents { } //for PDF - //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); - //} + 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(PDFNode.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(); |