添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
文档首页 >> Aspose.PDF使用教程 >>C++版PDF处理控件Aspose.PDF功能演示:使用PDF API for C ++动态创建PDF文件

C++版PDF处理控件Aspose.PDF功能演示:使用PDF API for C ++动态创建PDF文件

借助Internet的力量,一切都变得数字化,无纸化系统变得越来越流行。数字文档(即PDF)是无纸化系统的组成部分,这些无纸化系统通过提供自动生成和处理功能使生活变得更加轻松。大多数企业使用PDF文档自动化来动态生成报告,收据,发票和其他业务文档。 为了创建PDF文件,我们将使用Aspose.PDF for C ++ API,这是一个本机C ++库,可以以编程方式处理PDF文档。它可以在各种PDF元素的支持下创建交互式PDF文档。 在本文中,我将演示如何在基于C ++的应用程序中集成PDF自动化的功能,以及如何使用C ++动态生成PDF文件。 点击下载最新版Aspose.PDF for C++
// Numeration of Pages starts from 1 auto page = pages->idx_get(1); auto paragraps = page->get_Paragraphs(); // Create text fragment auto text = MakeObject(u"PDF API for C++"); auto ts = text->get_TextState(); // Set text state ts->set_FontSize(16); ts->set_FontStyle(FontStyles::Italic); // Add to paragraph paragraps->Add(text); // Add text to paragraph paragraps->Add(MakeObject(u"This example shows how to create a PDF with text using Aspose.PDF for C++.")); // Save PDF file doc->Save(u"Example1.pdf"); 输入HTML文件 auto tb = MakeObject(pages->idx_get(1)); // Create TextFragment auto text = MakeObject(u"Hello world!"); text->set_Position(MakeObject(100, 800)); // Append TextFragment tb->AppendText(text); // Create another TextFragment text = MakeObject(u"This example is created by Aspose.Pdf for C++."); text->set_Position(MakeObject(150, 750)); tb->AppendText(text); // Create another TextFragment text = MakeObject(u"It demonstrates how to use TextBuilder to append text into PDF file."); text->set_Position(MakeObject(200, 700)); tb->AppendText(text); // Create TextParagraph auto par = MakeObject(); par->set_Position(MakeObject(250,650)); par->AppendLine(u"New paragraph"); par->AppendLine(u"Line 2"); par->AppendLine(u"Line 3"); tb->AppendParagraph(par); // Save PDF document doc->Save(u"Created PDF.pdf"); 输入HTML文件 auto stream = MakeObject(); SharedPtrbitmap = MakeObject(200, 200); SharedPtrgraphics = Graphics::FromImage(bitmap); graphics->Clear(System::Drawing::Color::get_Yellow()); graphics->FillRectangle(Brushes::get_Blue(), System::Drawing::Rectangle(0, 0, 200, 100)); bitmap->Save(stream, Imaging::ImageFormat::get_Bmp()); // Create rectangle double x = 100.0, y = 600.0, width = 200.0, height = 200.0; auto rect = MakeObject(x, y, x + width, y + height); // Add image to PDF stream->Seek(0, System::IO::SeekOrigin::Begin); page->AddImage(stream, rect); // Save PDF document doc->Save(u"Created PDF.pdf"); 输入HTML文件
// Create a text file
System::IO::File::WriteAllText(u"Attachment.txt", u"Some info");
SharedPtrfileSpecification = MakeObject(u"Attachment.txt", u"Sample text file");
// Add attachment to document's attachment collection
auto doc = MakeObject();
doc->get_EmbeddedFiles()->Add(fileSpecification);
// Add a page to PDF
doc->get_Pages()->Add();	 
// Save PDF document
doc->Save(u"Created PDF.pdf");
输入HTML文件