C++ içinde PDF veya Word belgeleri oluşturun

Yüksek kaliteli C++ kitaplığımızı kullanarak programlı olarak hemen hemen her biçimde yeni bir belge oluşturun

C++ geliştiricileri, programlama API'mizi kullanarak PDF, DOC, DOCX, HTML, EPUB ve diğer birçok formatta yalnızca birkaç satır kodla kolayca belge oluşturabilir.

Kod parçacığını görüntüle

C++ kullanarak bir belge oluşturun

Verilen güçlü API ile C++ geliştiricileri hemen hemen her formatta belgeler oluşturabilir. Bunu yapmak için C++ kitaplığımızı kullanarak birkaç adımı izlemeniz gerekir:

  1. Dosya adı ekle
  2. C++ kullanarak bir belge oluşturmaya başlayın
  3. Oluşturulan belgeyi seçilen biçimde kaydedin

Boş bir belgenin teknik olarak bir paragraf içermesi gerektiğini belirtmekte fayda var, bu nedenle programlı olarak bir belge oluşturduğunuzda, tam olarak bu temel belge yapısını elde edeceksiniz.

Yeni oluşturulan bir belgeye anında içerik ekleyebileceğinizi unutmayın. Böylece sadece boş bir belge değil, gerekli içeriği içeren bir belge alacaksınız. Bir belgenin nasıl düzenleneceği hakkında daha fazla bilgi için Düzenleme sayfasına bakın.

C++'te programlı bir belge oluşturun

Verilen C++ kitaplığı, PDF, DOCX, DOC, RTF, ODT, EPUB, HTML ve diğer desteklenen herhangi bir formatta programlı olarak bir belge oluşturmanıza olanak tanır.

Güçlü işlevselliğimizi deneyin ve aşağıdaki örneği kullanarak bazı biçimlerde nasıl belge oluşturacağınızı görün:

C++ kullanarak yeni bir belge oluşturun
Listeden hedef formatı seçin
Kodu çalıştır
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.docx");
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"); // NextSibling null ise, büyük olasılıkla bu, Paragraftaki son Run . 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.docx"); 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"); // NextSibling null ise, büyük olasılıkla bu, Paragraftaki son Run . 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.docx", 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.docx");
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"); // NextSibling null ise, büyük olasılıkla bu, Paragraftaki son Run . 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.docx"); 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"); // NextSibling null ise, büyük olasılıkla bu, Paragraftaki son Run . 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.docx", 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");
// NextSibling null ise, büyük olasılıkla bu, Paragraftaki son Run .
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.docx");
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"); // NextSibling null ise, büyük olasılıkla bu, Paragraftaki son Run . 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.docx"); 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"); // NextSibling null ise, büyük olasılıkla bu, Paragraftaki son Run . 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.docx", 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.docx");
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"); // NextSibling null ise, büyük olasılıkla bu, Paragraftaki son Run . 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.docx"); 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"); // NextSibling null ise, büyük olasılıkla bu, Paragraftaki son Run . 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.docx", saveOptions);
Kodu çalıştır

C++'de bir belge nasıl yapılır

  1. Aspose.Words for C++ yükleyin
  2. C++ projenize bir kitaplık referansı ekleyin (kütüphaneyi içe aktarın)
  3. Yeni bir belge oluştur
  4. Dosya adını ileterek Save() yöntemini çağırın
  5. Sonucu ayrı bir dosya olarak alın

C++ belge oluşturmak için kitaplık

Aspose.Words for C++ ı geliştirici ortamınıza yüklemek için üç seçeneğiniz vardır. Lütfen ihtiyaçlarınıza uygun olanı seçin ve adım adım talimatları izleyin:

sistem gereksinimleri

Microsoft Windows, Linux ve macOS işletim sistemlerinde yazılım geliştirmek için bu C++ kitaplığını kullanabilirsiniz:

  • Linux için GCC >= 6.3.0 ve Clang >= 3.9.1
  • Xcode >= 12.5.1, macOS için Clang ve libc++

Linux veya macOS için yazılım geliştiriyorsanız, lütfen Ürün Belgelerinde fontconfig ve mesa-glu açık kaynak paketleri) hakkındaki bilgileri kontrol edin.

En popüler dosya biçimleri

5%

Aspose Ürün Güncellemelerine Abone Olun

Doğrudan posta kutunuza teslim edilen aylık bültenleri ve teklifleri alın.

© Aspose Pty Ltd 2001-2024. Her hakkı saklıdır.