Create PDF document programmatically
Contents
[
Hide
]
Create PDF files programmatically for reports, invoices, and other generated documents.
Create a PDF with text
- Create an empty Document.
- Add a page to the document with PageCollection::Add().
- Create a TextFragment containing Hello World!.
- Add the text fragment to the page’s Paragraphs collection.
- Save the result with Document::Save().
#include <Aspose.PDF.Cpp/Document.h>
#include <Aspose.PDF.Cpp/Page.h>
#include <Aspose.PDF.Cpp/PageCollection.h>
#include <Aspose.PDF.Cpp/Text/TextFragment.h>
#include <Aspose.PDF.Cpp/Generator/Paragraphs.h>
using namespace System;
using namespace Aspose::Pdf;
using namespace Aspose::Pdf::Text;
void CreatePDF(String path_outfile) {
auto document = MakeObject<Document>();
auto page = document->get_Pages()->Add();
auto textFragment = MakeObject<TextFragment>(u"Hello World!");
page->get_Paragraphs()->Add(textFragment);
document->Save(path_outfile);
}