+ let segmentedNodes = breakLineAlgorithms.segmentedNodes(a, this.attrs.defaultFrameStyle.width);
+
+ console.log(this.attrs.defaultFrameStyle.width);
+ let segmentedNodesToBox =
+ this.segmentedNodesToFrameBox(segmentedNodes, <FrameBox>this.attrs.defaultFrameStyle);
+
+
+
+ let boxesFixed = this.fixenBoxesPosition(segmentedNodesToBox);
+
+
+
+
+ // generate pdf7
+ const doc = new PDFDocument({size: 'A4'});
+ doc.pipe(fs.createWriteStream('output.pdf'));
+ this.grid(doc);
+
+ await this.putText(doc, boxesFixed);
+ // putChar
+ doc.end();
+
+ }
+
+ async putText(doc : PDFKit.PDFDocument, box : Box): Promise<PDFKit.PDFDocument>{
+
+ if (box.textStyle !== null){
+ let fontInfo = fontStyleTofont(box.textStyle);
+
+ if (fontInfo.path.match(/\.ttc$/g)){
+ doc
+ .font(fontInfo.path, fontInfo.psName)
+ .fontSize(box.textStyle.size*0.75);}
+ else{
+ doc
+ .font(fontInfo.path)
+ .fontSize(box.textStyle.size*0.75);
+ }
+
+ if (box.textStyle.color !== undefined){
+ doc.fill(box.textStyle.color);
+ }
+
+ if (Array.isArray(box.content)){
+ for (var k=0; k<box.content.length; k++){
+
+ doc = await this.putText(doc, box.content[k]);
+ }
+ }else if (box.content !== null){
+ console.log(box.content, box.x, box.y);
+ await doc.text(box.content,
+ (box.x!==null? box.x: undefined),
+ (box.y!==null? box.y: undefined));
+ }
+
+ }
+ return doc;
+ };