Ստեղծեք PDF կամ Word փաստաթղթեր JavaScript ում

Ստեղծեք նոր փաստաթուղթ գրեթե ցանկացած ձևաչափով ծրագրային կերպով՝ օգտագործելով մեր բարձր հավատարմության JavaScript գրադարանը

Օգտագործելով մեր ծրագրավորման API ը՝ Node.js via .NET մշակողները կարող են հեշտությամբ փաստաթուղթ պատրաստել PDF, DOC, DOCX, HTML, EPUB և շատ այլ ձևաչափերով՝ ընդամենը մի քանի տող կոդով:

Դիտեք կոդի հատվածը

Ստեղծեք փաստաթուղթ JavaScript ի միջոցով

Տրված հզոր API ի միջոցով JavaScript ի մշակողները կարող են փաստաթղթեր ստեղծել գրեթե ցանկացած ձևաչափով: Դա անելու համար դուք պետք է կատարեք մի քանի քայլ՝ օգտագործելով մեր Node.js via .NET գրադարանը.

  1. Ավելացնել ֆայլի անունը
  2. Սկսեք ստեղծել փաստաթուղթ JavaScript ի միջոցով
  3. Պահպանեք ստեղծված փաստաթուղթը ընտրված ձևաչափով

Հարկ է նշել, որ դատարկ փաստաթուղթը տեխնիկապես պետք է պարունակի մեկ պարբերություն, այնպես որ, երբ դուք ծրագրային կերպով փաստաթուղթ եք ստեղծում, դուք կստանաք հենց այդ հիմնական փաստաթղթի կառուցվածքը:

Նկատի ունեցեք, որ դուք կարող եք ակնթարթորեն բովանդակություն ավելացնել նոր ստեղծված փաստաթղթում: Այսպիսով, դուք կստանաք ոչ միայն դատարկ փաստաթուղթ, այլ անհրաժեշտ բովանդակություն պարունակող փաստաթուղթ: Լրացուցիչ տեղեկությունների համար, թե ինչպես խմբագրել փաստաթուղթը, տես Խմբագրման էջը:

Ստեղծեք փաստաթուղթ JavaScript ում ծրագրային եղանակով

Տվյալ Node.js via .NET գրադարանը թույլ է տալիս ծրագրային ձևով փաստաթուղթ ստեղծել ցանկացած աջակցվող ձևաչափով՝ PDF, DOCX, DOC, RTF, ODT, EPUB, HTML և այլն:

Փորձեք մեր հզոր ֆունկցիոնալությունը և տեսեք, թե ինչպես ստեղծել փաստաթուղթ որոշ ձևաչափերով՝ օգտագործելով հետևյալ օրինակը.

Ստեղծեք նոր փաստաթուղթ՝ օգտագործելով JavaScript
Ցանկից ընտրեք թիրախային ձևաչափը
Գործարկել կոդը
npm install @aspose/words
Պատճենել
const aw = require('@aspose/words');

var doc = new aw.Document()
var builder = new aw.DocumentBuilder(doc)

font = builder.font
font.name = "Courier New"
font.color = '#FF0000'
font.size = 36
font.highlightColor = '#F0DB4F'

builder.write("Morbi enim nunc faucibus a.")

doc.save("Output.docx")
const aw = require('@aspose/words'); var doc = new aw.Document() var builder = new aw.DocumentBuilder(doc) var firstRun = new aw.Run(doc, "Proin eros metus, sagittis sed. ") var secondRun = new aw.Run(doc, "Morbi enim nunc faucibus a.") doc.firstSection.body.firstParagraph.appendChild(firstRun) doc.firstSection.body.firstParagraph.appendChild(secondRun) builder.moveTo(secondRun) builder.startBookmark("Aspose bookmark") // Եթե NextSibling - ը զրոյական է, ապա դա, ամենայն հավանականությամբ, պարբերության վերջին մեկնարկն է: if (secondRun.nextSibling != null) builder.moveTo(secondRun.nextSibling) else builder.moveTo(secondRun.parentParagraph) builder.endBookmark("Aspose bookmark") doc.save("Output.docx") const aw = require('@aspose/words'); var doc = new aw.Document() var builder = new aw.DocumentBuilder(doc) var firstRun = new aw.Run(doc, "Proin eros metus, sagittis sed. ") var secondRun = new aw.Run(doc, "Morbi enim nunc faucibus a.") doc.firstSection.body.firstParagraph.appendChild(firstRun) doc.firstSection.body.firstParagraph.appendChild(secondRun) builder.moveTo(secondRun) builder.startBookmark("Aspose bookmark") // Եթե NextSibling - ը զրոյական է, ապա դա, ամենայն հավանականությամբ, պարբերության վերջին մեկնարկն է: if (secondRun.nextSibling != null) builder.moveTo(secondRun.nextSibling) else builder.moveTo(secondRun.parentParagraph) builder.endBookmark("Aspose bookmark") var saveOptions = new aw.Saving.PdfSaveOptions() saveOptions.outlineOptions.bookmarksOutlineLevels.add("Aspose bookmark", 1); doc.save("Output.docx", saveOptions)
const aw = require('@aspose/words');

var doc = new aw.Document()

var run = new aw.Run(doc, "Proin eros metus, sagittis sed.")
var para = doc.firstSection.body.firstParagraph
para.appendChild(run)

var comment = new aw.Comment(doc)
comment.author = "John Doe"
comment.initial = "JD"
comment.dateTime = new Date()
comment.setText("Quisque fringilla leo.")

var commentRangeStart = new aw.CommentRangeStart(doc, comment.id)
var commentRangeEnd = new aw.CommentRangeEnd(doc, comment.id)

run.parentNode.insertBefore(commentRangeStart, run)
run.parentNode.insertAfter(commentRangeEnd, run)
commentRangeEnd.parentNode.insertAfter(comment, commentRangeEnd)

comment.addReply("Jane Doe", "JD", new Date(), "Pellentesque vel sapien justo.")

doc.save("Output.docx")
const aw = require('@aspose/words'); var doc = new aw.Document() var builder = new aw.DocumentBuilder(doc) var firstRun = new aw.Run(doc, "Proin eros metus, sagittis sed. ") var secondRun = new aw.Run(doc, "Morbi enim nunc faucibus a.") doc.firstSection.body.firstParagraph.appendChild(firstRun) doc.firstSection.body.firstParagraph.appendChild(secondRun) builder.moveTo(secondRun) builder.startBookmark("Aspose bookmark") // Եթե NextSibling - ը զրոյական է, ապա դա, ամենայն հավանականությամբ, պարբերության վերջին մեկնարկն է: if (secondRun.nextSibling != null) builder.moveTo(secondRun.nextSibling) else builder.moveTo(secondRun.parentParagraph) builder.endBookmark("Aspose bookmark") doc.save("Output.docx") const aw = require('@aspose/words'); var doc = new aw.Document() var builder = new aw.DocumentBuilder(doc) var firstRun = new aw.Run(doc, "Proin eros metus, sagittis sed. ") var secondRun = new aw.Run(doc, "Morbi enim nunc faucibus a.") doc.firstSection.body.firstParagraph.appendChild(firstRun) doc.firstSection.body.firstParagraph.appendChild(secondRun) builder.moveTo(secondRun) builder.startBookmark("Aspose bookmark") // Եթե NextSibling - ը զրոյական է, ապա դա, ամենայն հավանականությամբ, պարբերության վերջին մեկնարկն է: if (secondRun.nextSibling != null) builder.moveTo(secondRun.nextSibling) else builder.moveTo(secondRun.parentParagraph) builder.endBookmark("Aspose bookmark") var saveOptions = new aw.Saving.PdfSaveOptions() saveOptions.outlineOptions.bookmarksOutlineLevels.add("Aspose bookmark", 1); doc.save("Output.docx", saveOptions)
const aw = require('@aspose/words');

var doc = new aw.Document()
var builder = new aw.DocumentBuilder(doc)

var firstRun = new aw.Run(doc, "Proin eros metus, sagittis sed. ")
var secondRun = new aw.Run(doc, "Morbi enim nunc faucibus a.")
doc.firstSection.body.firstParagraph.appendChild(firstRun)
doc.firstSection.body.firstParagraph.appendChild(secondRun)

builder.moveTo(secondRun)
builder.startBookmark("Aspose bookmark")
// Եթե NextSibling - ը զրոյական է, ապա դա, ամենայն հավանականությամբ, պարբերության վերջին մեկնարկն է:
if (secondRun.nextSibling != null)
    builder.moveTo(secondRun.nextSibling)
else
    builder.moveTo(secondRun.parentParagraph)
builder.endBookmark("Aspose bookmark")

doc.save("Output.docx")
const aw = require('@aspose/words'); var doc = new aw.Document() var builder = new aw.DocumentBuilder(doc) var firstRun = new aw.Run(doc, "Proin eros metus, sagittis sed. ") var secondRun = new aw.Run(doc, "Morbi enim nunc faucibus a.") doc.firstSection.body.firstParagraph.appendChild(firstRun) doc.firstSection.body.firstParagraph.appendChild(secondRun) builder.moveTo(secondRun) builder.startBookmark("Aspose bookmark") // Եթե NextSibling - ը զրոյական է, ապա դա, ամենայն հավանականությամբ, պարբերության վերջին մեկնարկն է: if (secondRun.nextSibling != null) builder.moveTo(secondRun.nextSibling) else builder.moveTo(secondRun.parentParagraph) builder.endBookmark("Aspose bookmark") doc.save("Output.docx") const aw = require('@aspose/words'); var doc = new aw.Document() var builder = new aw.DocumentBuilder(doc) var firstRun = new aw.Run(doc, "Proin eros metus, sagittis sed. ") var secondRun = new aw.Run(doc, "Morbi enim nunc faucibus a.") doc.firstSection.body.firstParagraph.appendChild(firstRun) doc.firstSection.body.firstParagraph.appendChild(secondRun) builder.moveTo(secondRun) builder.startBookmark("Aspose bookmark") // Եթե NextSibling - ը զրոյական է, ապա դա, ամենայն հավանականությամբ, պարբերության վերջին մեկնարկն է: if (secondRun.nextSibling != null) builder.moveTo(secondRun.nextSibling) else builder.moveTo(secondRun.parentParagraph) builder.endBookmark("Aspose bookmark") var saveOptions = new aw.Saving.PdfSaveOptions() saveOptions.outlineOptions.bookmarksOutlineLevels.add("Aspose bookmark", 1); doc.save("Output.docx", saveOptions)
const aw = require('@aspose/words');

var doc = new aw.Document()
var builder = new aw.DocumentBuilder(doc)

shape = builder.insertChart(aw.Drawing.Charts.ChartType.Pie, 432, 252)
chart = shape.chart
chart.title.text = "Demo Chart"

chart.series.clear()
chart.series.add("Series 1",
    ["Category1", "Category2", "Category3"],
    [2.7, 3.2, 0.8])

doc.save("Output.docx")
const aw = require('@aspose/words'); var doc = new aw.Document() var builder = new aw.DocumentBuilder(doc) var firstRun = new aw.Run(doc, "Proin eros metus, sagittis sed. ") var secondRun = new aw.Run(doc, "Morbi enim nunc faucibus a.") doc.firstSection.body.firstParagraph.appendChild(firstRun) doc.firstSection.body.firstParagraph.appendChild(secondRun) builder.moveTo(secondRun) builder.startBookmark("Aspose bookmark") // Եթե NextSibling - ը զրոյական է, ապա դա, ամենայն հավանականությամբ, պարբերության վերջին մեկնարկն է: if (secondRun.nextSibling != null) builder.moveTo(secondRun.nextSibling) else builder.moveTo(secondRun.parentParagraph) builder.endBookmark("Aspose bookmark") doc.save("Output.docx") const aw = require('@aspose/words'); var doc = new aw.Document() var builder = new aw.DocumentBuilder(doc) var firstRun = new aw.Run(doc, "Proin eros metus, sagittis sed. ") var secondRun = new aw.Run(doc, "Morbi enim nunc faucibus a.") doc.firstSection.body.firstParagraph.appendChild(firstRun) doc.firstSection.body.firstParagraph.appendChild(secondRun) builder.moveTo(secondRun) builder.startBookmark("Aspose bookmark") // Եթե NextSibling - ը զրոյական է, ապա դա, ամենայն հավանականությամբ, պարբերության վերջին մեկնարկն է: if (secondRun.nextSibling != null) builder.moveTo(secondRun.nextSibling) else builder.moveTo(secondRun.parentParagraph) builder.endBookmark("Aspose bookmark") var saveOptions = new aw.Saving.PdfSaveOptions() saveOptions.outlineOptions.bookmarksOutlineLevels.add("Aspose bookmark", 1); doc.save("Output.docx", saveOptions)
Գործարկել կոդը

Ինչպես պատրաստել փաստաթուղթ JavaScript ում

  1. Տեղադրեք Aspose.Words for Node.js via .NET
  2. Ձեր JavaScript նախագծին ավելացրեք գրադարանի հղում (ներմուծեք գրադարանը):
  3. Ստեղծեք նոր փաստաթուղթ
  4. Զանգահարեք save() մեթոդը՝ փոխանցելով ֆայլի անունը
  5. Ստացեք արդյունքը որպես առանձին ֆայլ

JavaScript գրադարան՝ փաստաթղթեր ստեղծելու համար

We host our Node.js via .Net packages in NPM repositories. Please follow the step-by-step instructions on how to install "Aspose.Words for Node.js via .NET" to your developer environment.

System Requirements

This package is compatible with Node.js 14.17.0 or higher.

Ամենատարածված ֆայլի ձևաչափերը

5%

Բաժանորդագրվեք Aspose Product Updates-ին

Ստացեք ամսական տեղեկագրեր և առաջարկներ անմիջապես ձեր փոստարկղին:

© Aspose Pty Ltd 2001-2025. Բոլոր իրավունքները պաշտպանված են.