deno.land / x / docx@8.5.0 / demo / 76-compatibility.ts
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788// Add compatibility options
import * as fs from "fs";import { Document, Packer, Paragraph, TextRun } from "docx";
const doc = new Document({ compatibility: { useSingleBorderforContiguousCells: true, wordPerfectJustification: true, noTabStopForHangingIndent: true, noLeading: true, spaceForUnderline: true, noColumnBalance: true, balanceSingleByteDoubleByteWidth: true, noExtraLineSpacing: true, doNotLeaveBackslashAlone: true, underlineTrailingSpaces: true, doNotExpandShiftReturn: true, spacingInWholePoints: true, lineWrapLikeWord6: true, printBodyTextBeforeHeader: true, printColorsBlack: true, spaceWidth: true, showBreaksInFrames: true, subFontBySize: true, suppressBottomSpacing: true, suppressTopSpacing: true, suppressSpacingAtTopOfPage: true, suppressTopSpacingWP: true, suppressSpBfAfterPgBrk: true, swapBordersFacingPages: true, convertMailMergeEsc: true, truncateFontHeightsLikeWP6: true, macWordSmallCaps: true, usePrinterMetrics: true, doNotSuppressParagraphBorders: true, wrapTrailSpaces: true, footnoteLayoutLikeWW8: true, shapeLayoutLikeWW8: true, alignTablesRowByRow: true, forgetLastTabAlignment: true, adjustLineHeightInTable: true, autoSpaceLikeWord95: true, noSpaceRaiseLower: true, doNotUseHTMLParagraphAutoSpacing: true, layoutRawTableWidth: true, layoutTableRowsApart: true, useWord97LineBreakRules: true, doNotBreakWrappedTables: true, doNotSnapToGridInCell: true, selectFieldWithFirstOrLastCharacter: true, applyBreakingRules: true, doNotWrapTextWithPunctuation: true, doNotUseEastAsianBreakRules: true, useWord2002TableStyleRules: true, growAutofit: true, useFELayout: true, useNormalStyleForList: true, doNotUseIndentAsNumberingTabStop: true, useAlternateEastAsianLineBreakRules: true, allowSpaceOfSameStyleInTable: true, doNotSuppressIndentation: true, doNotAutofitConstrainedTables: true, autofitToFirstFixedWidthCell: true, underlineTabInNumberingList: true, displayHangulFixedWidth: true, splitPgBreakAndParaMark: true, doNotVerticallyAlignCellWithSp: true, doNotBreakConstrainedForcedTable: true, ignoreVerticalAlignmentInTextboxes: true, useAnsiKerningPairs: true, cachedColumnBalance: true, }, sections: [ { children: [ new Paragraph({ children: [new TextRun("Hello World")], }), ], }, ],});
Packer.toBuffer(doc).then((buffer) => { fs.writeFileSync("My Document.docx", buffer);});
Version Info