C++ izstrādātāji var viegli izveidot PDF, izmantojot tikai mūsu jaudīgo produktu API. Tas nozīmē, ka mūsu risinājums nodrošinās programmētājiem visu nepieciešamo, lai izveidotu PDF pakalpojumā C++.
Izmantojot mūsu C++ bibliotēku, izstrādātāji var viegli izveidot PDF no nulles. Lai to izdarītu, C++ izstrādātājiem ir jāveic tikai dažas darbības:
Ir vērts atzīmēt, ka tukšā dokumentā tehniski ir jāiekļauj viena rindkopa, tāpēc, programmatiski veidojot PDF dokumentu, jūs iegūsit tieši tādu dokumenta pamatstruktūru.
Ņemiet vērā, ka varat uzreiz pievienot saturu jaunizveidotajam PDF failam. Tādējādi jūs iegūsit ne tikai tukšu dokumentu, bet arī dokumentu ar nepieciešamo saturu. Papildinformāciju par dokumenta rediģēšanu skatiet rediģēšanas lapā.
Šī C++ bibliotēka ļauj programmatiski izveidot PDF dokumentus. Izmēģiniet mūsu jaudīgo funkcionalitāti un uzziniet, kā dažos formātos izveidot PDF, izmantojot šo piemēru:
dotnet add package Aspose.Words.Cpp
Kopēt
using namespace Aspose::Words;
auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
auto font = builder->get_Font();
font->set_Name(u"Courier New");
font->set_Color(System::Drawing::Color::get_Blue());
font->set_Size(36);
font->set_HighlightColor(System::Drawing::Color::get_Yellow());
builder->Write(u"Morbi enim nunc faucibus a.");
doc->Save(u"Output.pdf");
using namespace Aspose::Words;
auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
auto firstRun = MakeObject<Run>(doc, u"Proin eros metus, sagittis sed. ");
auto secondRun = MakeObject<Run>(doc, u"Morbi enim nunc faucibus a.");
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->AppendChild(firstRun);
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->AppendChild(secondRun);
builder->MoveTo(secondRun);
builder->StartBookmark(u"Aspose bookmark");
// Ja NextSibling ir null, tad visticamāk šī ir pēdējā Run rindkopā.
if (secondRun->get_NextSibling() != NULL)
builder->MoveTo(secondRun->get_NextSibling());
else
builder->MoveTo(secondRun->get_ParentParagraph());
builder->EndBookmark(u"Aspose bookmark");
doc->Save(u"Output.pdf");
using namespace Aspose::Words;
auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
auto firstRun = MakeObject<Run>(doc, u"Proin eros metus, sagittis sed. ");
auto secondRun = MakeObject<Run>(doc, u"Morbi enim nunc faucibus a.");
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->AppendChild(firstRun);
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->AppendChild(secondRun);
builder->MoveTo(secondRun);
builder->StartBookmark(u"Aspose bookmark");
// Ja NextSibling ir null, tad visticamāk šī ir pēdējā Run rindkopā.
if (secondRun->get_NextSibling() != NULL)
builder->MoveTo(secondRun->get_NextSibling());
else
builder->MoveTo(secondRun->get_ParentParagraph());
builder->EndBookmark(u"Aspose bookmark");
auto saveOptions = MakeObject<PdfSaveOptions>();
saveOptions->get_OutlineOptions()->get_BookmarksOutlineLevels()->Add(u"Aspose bookmark", 1);
doc->Save(u"Output.pdf", saveOptions);
using namespace Aspose::Words;
auto doc = MakeObject<Document>();
auto run = MakeObject<Run>(doc, u"Proin eros metus, sagittis sed.");
auto para = doc->get_FirstSection()->get_Body()->get_FirstParagraph();
para->AppendChild(run);
auto comment = MakeObject<Comment>(doc, u"John Doe", u"JD", System::DateTime::get_Today());
comment->SetText(u"Quisque fringilla leo.");
auto commentRangeStart = MakeObject<CommentRangeStart>(doc, comment->get_Id());
auto commentRangeEnd = MakeObject<CommentRangeEnd>(doc, comment->get_Id());
run->get_ParentNode()->InsertBefore(commentRangeStart, run);
run->get_ParentNode()->InsertAfter(commentRangeEnd, run);
commentRangeEnd->get_ParentNode()->InsertAfter(comment, commentRangeEnd);
comment->AddReply(u"Jane Doe", u"JD", System::DateTime::get_Now(),
u"Pellentesque vel sapien justo.");
doc->Save(u"Output.pdf");
using namespace Aspose::Words;
auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
auto firstRun = MakeObject<Run>(doc, u"Proin eros metus, sagittis sed. ");
auto secondRun = MakeObject<Run>(doc, u"Morbi enim nunc faucibus a.");
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->AppendChild(firstRun);
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->AppendChild(secondRun);
builder->MoveTo(secondRun);
builder->StartBookmark(u"Aspose bookmark");
// Ja NextSibling ir null, tad visticamāk šī ir pēdējā Run rindkopā.
if (secondRun->get_NextSibling() != NULL)
builder->MoveTo(secondRun->get_NextSibling());
else
builder->MoveTo(secondRun->get_ParentParagraph());
builder->EndBookmark(u"Aspose bookmark");
doc->Save(u"Output.pdf");
using namespace Aspose::Words;
auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
auto firstRun = MakeObject<Run>(doc, u"Proin eros metus, sagittis sed. ");
auto secondRun = MakeObject<Run>(doc, u"Morbi enim nunc faucibus a.");
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->AppendChild(firstRun);
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->AppendChild(secondRun);
builder->MoveTo(secondRun);
builder->StartBookmark(u"Aspose bookmark");
// Ja NextSibling ir null, tad visticamāk šī ir pēdējā Run rindkopā.
if (secondRun->get_NextSibling() != NULL)
builder->MoveTo(secondRun->get_NextSibling());
else
builder->MoveTo(secondRun->get_ParentParagraph());
builder->EndBookmark(u"Aspose bookmark");
auto saveOptions = MakeObject<PdfSaveOptions>();
saveOptions->get_OutlineOptions()->get_BookmarksOutlineLevels()->Add(u"Aspose bookmark", 1);
doc->Save(u"Output.pdf", saveOptions);
using namespace Aspose::Words;
auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
auto firstRun = MakeObject<Run>(doc, u"Proin eros metus, sagittis sed. ");
auto secondRun = MakeObject<Run>(doc, u"Morbi enim nunc faucibus a.");
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->AppendChild(firstRun);
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->AppendChild(secondRun);
builder->MoveTo(secondRun);
builder->StartBookmark(u"Aspose bookmark");
// Ja NextSibling ir null, tad visticamāk šī ir pēdējā Run rindkopā.
if (secondRun->get_NextSibling() != NULL)
builder->MoveTo(secondRun->get_NextSibling());
else
builder->MoveTo(secondRun->get_ParentParagraph());
builder->EndBookmark(u"Aspose bookmark");
auto saveOptions = MakeObject<PdfSaveOptions>();
saveOptions->get_OutlineOptions()->get_BookmarksOutlineLevels()->Add(u"Aspose bookmark", 1);
doc->Save(u"Output.pdf", saveOptions);
using namespace Aspose::Words;
auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
auto firstRun = MakeObject<Run>(doc, u"Proin eros metus, sagittis sed. ");
auto secondRun = MakeObject<Run>(doc, u"Morbi enim nunc faucibus a.");
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->AppendChild(firstRun);
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->AppendChild(secondRun);
builder->MoveTo(secondRun);
builder->StartBookmark(u"Aspose bookmark");
// Ja NextSibling ir null, tad visticamāk šī ir pēdējā Run rindkopā.
if (secondRun->get_NextSibling() != NULL)
builder->MoveTo(secondRun->get_NextSibling());
else
builder->MoveTo(secondRun->get_ParentParagraph());
builder->EndBookmark(u"Aspose bookmark");
doc->Save(u"Output.pdf");
using namespace Aspose::Words;
auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
auto firstRun = MakeObject<Run>(doc, u"Proin eros metus, sagittis sed. ");
auto secondRun = MakeObject<Run>(doc, u"Morbi enim nunc faucibus a.");
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->AppendChild(firstRun);
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->AppendChild(secondRun);
builder->MoveTo(secondRun);
builder->StartBookmark(u"Aspose bookmark");
// Ja NextSibling ir null, tad visticamāk šī ir pēdējā Run rindkopā.
if (secondRun->get_NextSibling() != NULL)
builder->MoveTo(secondRun->get_NextSibling());
else
builder->MoveTo(secondRun->get_ParentParagraph());
builder->EndBookmark(u"Aspose bookmark");
auto saveOptions = MakeObject<PdfSaveOptions>();
saveOptions->get_OutlineOptions()->get_BookmarksOutlineLevels()->Add(u"Aspose bookmark", 1);
doc->Save(u"Output.pdf", saveOptions);
using namespace Aspose::Words;
auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
auto shape = builder->InsertChart(ChartType::Pie, 432, 252);
auto chart = shape->get_Chart();
chart->get_Title()->set_Text(u"Demo Chart");
chart->get_Series()->Clear();
chart->get_Series()->Add(u"Series 1",
MakeArray<String>({ u"Category1", u"Category2", u"Category3" }),
MakeArray<double>({ 2.7, 3.2, 0.8 }));
doc->Save(u"Output.pdf");
using namespace Aspose::Words;
auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
auto firstRun = MakeObject<Run>(doc, u"Proin eros metus, sagittis sed. ");
auto secondRun = MakeObject<Run>(doc, u"Morbi enim nunc faucibus a.");
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->AppendChild(firstRun);
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->AppendChild(secondRun);
builder->MoveTo(secondRun);
builder->StartBookmark(u"Aspose bookmark");
// Ja NextSibling ir null, tad visticamāk šī ir pēdējā Run rindkopā.
if (secondRun->get_NextSibling() != NULL)
builder->MoveTo(secondRun->get_NextSibling());
else
builder->MoveTo(secondRun->get_ParentParagraph());
builder->EndBookmark(u"Aspose bookmark");
doc->Save(u"Output.pdf");
using namespace Aspose::Words;
auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
auto firstRun = MakeObject<Run>(doc, u"Proin eros metus, sagittis sed. ");
auto secondRun = MakeObject<Run>(doc, u"Morbi enim nunc faucibus a.");
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->AppendChild(firstRun);
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->AppendChild(secondRun);
builder->MoveTo(secondRun);
builder->StartBookmark(u"Aspose bookmark");
// Ja NextSibling ir null, tad visticamāk šī ir pēdējā Run rindkopā.
if (secondRun->get_NextSibling() != NULL)
builder->MoveTo(secondRun->get_NextSibling());
else
builder->MoveTo(secondRun->get_ParentParagraph());
builder->EndBookmark(u"Aspose bookmark");
auto saveOptions = MakeObject<PdfSaveOptions>();
saveOptions->get_OutlineOptions()->get_BookmarksOutlineLevels()->Add(u"Aspose bookmark", 1);
doc->Save(u"Output.pdf", saveOptions);
Ir trīs iespējas, kā instalēt programmu Aspose.Words for C++ savā izstrādātāja vidē. Lūdzu, izvēlieties to, kas atbilst jūsu vajadzībām, un izpildiet soli pa solim sniegtos norādījumus:
Šo C++ bibliotēku varat izmantot, lai izstrādātu programmatūru Microsoft Windows, Linux un macOS operētājsistēmās:
Ja izstrādājat programmatūru operētājsistēmai Linux vai macOS, lūdzu, pārbaudiet informāciju par papildu bibliotēku atkarībām (fontconfig un mesa-glu atvērtā koda pakotnes) produkta dokumentācijā.
Varat izveidot dokumentus citos failu formātos: