Python via .NET kūrėjai gali lengvai sukurti MD naudodami tik mūsų galingą produkto API. Tai reiškia, kad mūsų sprendimas suteiks programuotojams viską, ko reikia norint sukurti MD Python.
Naudodami "Python" biblioteką kūrėjai gali lengvai sukurti "MD" nuo nulio. Norėdami tai padaryti, Python via .NET kūrėjai turi atlikti tik kelis veiksmus:
Verta paminėti, kad tuščiame dokumente techniškai turėtų būti viena pastraipa, todėl programiškai kurdami MD dokumentą gausite būtent tokią pagrindinę dokumento struktūrą.
Atminkite, kad galite akimirksniu įtraukti turinį į naujai sukurtą "MD" failą. Taigi jūs gausite ne tik tuščią dokumentą, bet ir dokumentą su reikiamu turiniu. Daugiau informacijos apie tai, kaip redaguoti dokumentą, rasite puslapyje Redagavimas.
Ši Python via .NET biblioteka leidžia programiškai kurti MD dokumentus. Išbandykite mūsų galingą funkciją ir sužinokite, kaip sukurti MD kai kuriais formatais, naudojant šį pavyzdį:
pip install aspose-words
Kopijuoti
import aspose.words as aw
doc = aw.Document()
builder = aw.DocumentBuilder(doc)
font = builder.font
font.name = "Courier New"
font.color = drawing.Color.blue
font.size = 36
font.highlight_color = drawing.Color.yellow
builder.write("Morbi enim nunc faucibus a.")
doc.Save("Output.md")
import aspose.words as aw
doc = aw.Document()
builder = aw.DocumentBuilder(doc)
firstRun = aw.Run(doc, "Proin eros metus, sagittis sed. ")
secondRun = aw.Run(doc, "Morbi enim nunc faucibus a.")
doc.first_section.body.first_paragraph.append_child(firstRun)
doc.first_section.body.first_paragraph.append_child(secondRun)
builder.move_to(secondRun)
builder.start_bookmark("Aspose bookmark")
# Jei NextSibling yra nulis, greičiausiai tai yra paskutinis Run pastraipoje.
if (secondRun.next_sibling != None):
builder.move_to(secondRun.next_sibling)
else:
builder.move_to(secondRun.parent_paragraph)
builder.end_bookmark("Aspose bookmark")
doc.Save("Output.md")
import aspose.words as aw
doc = aw.Document()
builder = aw.DocumentBuilder(doc)
firstRun = aw.Run(doc, "Proin eros metus, sagittis sed. ")
secondRun = aw.Run(doc, "Morbi enim nunc faucibus a.")
doc.first_section.body.first_paragraph.append_child(firstRun)
doc.first_section.body.first_paragraph.append_child(secondRun)
builder.move_to(secondRun)
builder.start_bookmark("Aspose bookmark")
# Jei NextSibling yra nulis, greičiausiai tai yra paskutinis Run pastraipoje.
if (secondRun.next_sibling != None):
builder.move_to(secondRun.next_sibling)
else:
builder.move_to(secondRun.parent_paragraph)
builder.end_bookmark("Aspose bookmark")
save_options = aw.saving.PdfSaveOptions()
save_options.outline_options.bookmarks_outline_levels.add("Aspose bookmark", 1);
doc.Save("Output.md", save_options);
import aspose.words as aw
doc = aw.Document()
run = aw.Run(doc, "Proin eros metus, sagittis sed.")
para = doc.first_section.body.first_paragraph
para.append_child(run)
comment = aw.Comment(doc)
comment.author = "John Doe"
comment.initial = "JD"
comment.date_time = datetime.now()
comment.set_text("Quisque fringilla leo.")
commentRangeStart = aw.CommentRangeStart(doc, comment.id)
commentRangeEnd = aw.CommentRangeEnd(doc, comment.id)
run.parent_node.insert_before(commentRangeStart, run)
run.parent_node.insert_after(commentRangeEnd, run)
commentRangeEnd.parent_node.insert_after(comment, commentRangeEnd)
comment.add_reply("Jane Doe", "JD", datetime.now(), "Pellentesque vel sapien justo.")
doc.save("Output.md")
import aspose.words as aw
doc = aw.Document()
builder = aw.DocumentBuilder(doc)
firstRun = aw.Run(doc, "Proin eros metus, sagittis sed. ")
secondRun = aw.Run(doc, "Morbi enim nunc faucibus a.")
doc.first_section.body.first_paragraph.append_child(firstRun)
doc.first_section.body.first_paragraph.append_child(secondRun)
builder.move_to(secondRun)
builder.start_bookmark("Aspose bookmark")
# Jei NextSibling yra nulis, greičiausiai tai yra paskutinis Run pastraipoje.
if (secondRun.next_sibling != None):
builder.move_to(secondRun.next_sibling)
else:
builder.move_to(secondRun.parent_paragraph)
builder.end_bookmark("Aspose bookmark")
doc.Save("Output.md")
import aspose.words as aw
doc = aw.Document()
builder = aw.DocumentBuilder(doc)
firstRun = aw.Run(doc, "Proin eros metus, sagittis sed. ")
secondRun = aw.Run(doc, "Morbi enim nunc faucibus a.")
doc.first_section.body.first_paragraph.append_child(firstRun)
doc.first_section.body.first_paragraph.append_child(secondRun)
builder.move_to(secondRun)
builder.start_bookmark("Aspose bookmark")
# Jei NextSibling yra nulis, greičiausiai tai yra paskutinis Run pastraipoje.
if (secondRun.next_sibling != None):
builder.move_to(secondRun.next_sibling)
else:
builder.move_to(secondRun.parent_paragraph)
builder.end_bookmark("Aspose bookmark")
save_options = aw.saving.PdfSaveOptions()
save_options.outline_options.bookmarks_outline_levels.add("Aspose bookmark", 1);
doc.Save("Output.md", save_options);
import aspose.words as aw
doc = aw.Document()
builder = aw.DocumentBuilder(doc)
firstRun = aw.Run(doc, "Proin eros metus, sagittis sed. ")
secondRun = aw.Run(doc, "Morbi enim nunc faucibus a.")
doc.first_section.body.first_paragraph.append_child(firstRun)
doc.first_section.body.first_paragraph.append_child(secondRun)
builder.move_to(secondRun)
builder.start_bookmark("Aspose bookmark")
# Jei NextSibling yra nulis, greičiausiai tai yra paskutinis Run pastraipoje.
if (secondRun.next_sibling != None):
builder.move_to(secondRun.next_sibling)
else:
builder.move_to(secondRun.parent_paragraph)
builder.end_bookmark("Aspose bookmark")
doc.Save("Output.md")
import aspose.words as aw
doc = aw.Document()
builder = aw.DocumentBuilder(doc)
firstRun = aw.Run(doc, "Proin eros metus, sagittis sed. ")
secondRun = aw.Run(doc, "Morbi enim nunc faucibus a.")
doc.first_section.body.first_paragraph.append_child(firstRun)
doc.first_section.body.first_paragraph.append_child(secondRun)
builder.move_to(secondRun)
builder.start_bookmark("Aspose bookmark")
# Jei NextSibling yra nulis, greičiausiai tai yra paskutinis Run pastraipoje.
if (secondRun.next_sibling != None):
builder.move_to(secondRun.next_sibling)
else:
builder.move_to(secondRun.parent_paragraph)
builder.end_bookmark("Aspose bookmark")
doc.Save("Output.md")
import aspose.words as aw
doc = aw.Document()
builder = aw.DocumentBuilder(doc)
firstRun = aw.Run(doc, "Proin eros metus, sagittis sed. ")
secondRun = aw.Run(doc, "Morbi enim nunc faucibus a.")
doc.first_section.body.first_paragraph.append_child(firstRun)
doc.first_section.body.first_paragraph.append_child(secondRun)
builder.move_to(secondRun)
builder.start_bookmark("Aspose bookmark")
# Jei NextSibling yra nulis, greičiausiai tai yra paskutinis Run pastraipoje.
if (secondRun.next_sibling != None):
builder.move_to(secondRun.next_sibling)
else:
builder.move_to(secondRun.parent_paragraph)
builder.end_bookmark("Aspose bookmark")
save_options = aw.saving.PdfSaveOptions()
save_options.outline_options.bookmarks_outline_levels.add("Aspose bookmark", 1);
doc.Save("Output.md", save_options);
import aspose.words as aw
doc = aw.Document()
builder = aw.DocumentBuilder(doc)
shape = builder.insert_chart(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.md")
import aspose.words as aw
doc = aw.Document()
builder = aw.DocumentBuilder(doc)
firstRun = aw.Run(doc, "Proin eros metus, sagittis sed. ")
secondRun = aw.Run(doc, "Morbi enim nunc faucibus a.")
doc.first_section.body.first_paragraph.append_child(firstRun)
doc.first_section.body.first_paragraph.append_child(secondRun)
builder.move_to(secondRun)
builder.start_bookmark("Aspose bookmark")
# Jei NextSibling yra nulis, greičiausiai tai yra paskutinis Run pastraipoje.
if (secondRun.next_sibling != None):
builder.move_to(secondRun.next_sibling)
else:
builder.move_to(secondRun.parent_paragraph)
builder.end_bookmark("Aspose bookmark")
doc.Save("Output.md")
import aspose.words as aw
doc = aw.Document()
builder = aw.DocumentBuilder(doc)
firstRun = aw.Run(doc, "Proin eros metus, sagittis sed. ")
secondRun = aw.Run(doc, "Morbi enim nunc faucibus a.")
doc.first_section.body.first_paragraph.append_child(firstRun)
doc.first_section.body.first_paragraph.append_child(secondRun)
builder.move_to(secondRun)
builder.start_bookmark("Aspose bookmark")
# Jei NextSibling yra nulis, greičiausiai tai yra paskutinis Run pastraipoje.
if (secondRun.next_sibling != None):
builder.move_to(secondRun.next_sibling)
else:
builder.move_to(secondRun.parent_paragraph)
builder.end_bookmark("Aspose bookmark")
save_options = aw.saving.PdfSaveOptions()
save_options.outline_options.bookmarks_outline_levels.add("Aspose bookmark", 1);
doc.Save("Output.md", save_options);
Python paketus talpiname PyPi saugyklose. Vadovaukitės nuosekliomis instrukcijomis, kaip įdiegti "Aspose.Words for Python via .NET" į kūrėjo aplinką.
Šis paketas suderinamas su Python ≥3.5 ir <3.12. Jei kuriate programinę įrangą, skirtą Linux, peržiūrėkite papildomus gcc ir libpython reikalavimus produkto dokumentacijoje.
Galite kurti dokumentus kitais failų formatais: