HTML JPG PDF XML XLSX
  Product Family
PDF

Create PDF File in C++

Native and high performance PDF file creation programmatically without Micorsoft Office using C++ library.

Create PDF File Using C++

How to create PDF file? With Aspose.Cells for C++ library, you can easily Create PDF file programmatically with a few lines of code. Aspose.Cells for C++ is capable of building cross-platform applications with the ability to generate, modify, convert, render and print all Excel files. C++ Excel API not only convert between spreadsheet formats, it can also render Excel files as images, PDF, HTML, ODS, CSV, SVG, JSON, WORD, PPT and more, thus making it a perfect choice to exchange documents in industry-standard formats. You can download its latest version directly, just open NuGet package manager, search for Aspose.Cells.Cpp and install. You may also use the following command from the Package Manager Console.

Command


PM> Install-Package Aspose.Cells.Cpp

How to Create PDF in C++

It is easy for the developers to create, load, modify and convert PDF files within running reporting applications for data processing in just few lines of code.

  1. Create an object of the IWorkbook class.
  2. Get the first sheet into an IWorksheet object.
  3. Use IWorksheet->GetICells() method to get the cells of the worksheet into an ICells object.
  4. Use ICells->GetObjectByIndex() method to access the desired cell of the worksheet into an ICell object.
  5. Use ICell->PutValue() method to input value into the cell.
  6. Save the workbook as .pdf file using Save() method.
 

Sample code shows how to create PDF file in C++.


// Create an object of the IWorkbook class.
intrusive_ptr<IWorkbook> wkb = Factory::CreateIWorkbook();

// Get the first sheet into an IWorksheet object.
intrusive_ptr<IWorksheetCollection> wsc = wkb->GetIWorksheets();
intrusive_ptr<IWorksheet> ws = wsc->GetObjectByIndex(0);

// Use IWorksheet->GetICells() method to get the cells of the worksheet into an ICells object.
intrusive_ptr<ICells> cells = ws->GetICells();

// Use ICells->GetObjectByIndex() method to access the desired cell of the worksheet into an ICell object.
intrusive_ptr<ICell> cell00 = cells->GetObjectByIndex(0, 0);
intrusive_ptr<ICell> cell01 = cells->GetObjectByIndex(0, 1);
intrusive_ptr<ICell> cell10 = cells->GetObjectByIndex(1, 0);
intrusive_ptr<ICell> cell11 = cells->GetObjectByIndex(1, 1);

// Use ICell->PutValue() method to input value into the cell.
cell00->PutValue(new String("ColumnA"));
cell01->PutValue(new String("ColumnB"));
cell10->PutValue(new String("ValueA"));
cell11->PutValue(new String("ValueB"));

// Save workbook to resultFile folder
wkb->Save(new String("created_one.pdf"));
 

C++ library to create PDF file

There are three options to install “Aspose.Cells for C++” onto your system. Please choose one that resembles your needs and follow the step-by-step instructions:

  1. Install a NuGet Package . See Documentation
  2. Install the library using Include and lib Folders. See Documentation
  3. Install Aspose.Cells for C++ in Linux. See Documentation

System Requirements

Before running the C++ conversion sample source code, make sure that you have the following prerequisites.

  • Microsoft Windows or a compatible OS with C++ Runtime Environment for Windows 32 bit, Windows 64 bit and Linux 64 bit.
  • Add reference to the Aspose.Cells for C++ DLL in your project.

PDF What is PDF File Format?

Portable Document Format (PDF) is a type of document created by Adobe back in 1990s. The purpose of this file format was to introduce a standard for representation of documents and other reference material in a format that is independent of application software, hardware as well as Operating System. The PDF file format has full capability to contain information like text, images, hyperlinks, form-fields, rich media, digital signatures, attachments, metadata, Geospatial features and 3D objects in it that can become as part of source document.

Read More

Other Supported Sheets Generation

You can also create other Microsoft Excel files including few listed below.

XLS (Microsoft Excel Spreadsheet (Legacy))
XLSX (Open XML Workbook)
XLSB (Excel Binary Workbook)
XLSM (Macro-enabled Spreadsheet)
XLT (Excel 97 - 2003 Template)
XLTX (Excel Template)
XLTM (Excel Macro-Enabled Template)
CSV (Comma Separated Values)
TSV (Tab Separated Values)
ODS (OpenDocument Spreadsheet)
PDF (Portable Document Format)
HTML (Hyper Text Markup Language)