Test in a live environment
Test in production without watermarks.
Works wherever you need it to.
The Portable Document Format (PDF) has been the go-to format for sharing documents across various platforms. However, with the increasing significance of digital archiving, there is a growing need to archive documents in a standardized format that ensures long-term preservation and accessibility. The PDF/A (PDFA) format is specifically designed for this purpose, offering a stable and self-contained format that is suitable for archiving.
PDF/A, an ISO-standardized PDF variant, is designed to preserve documents over time, maintaining content accessibility and integrity. In contrast to a regular PDF file, PDF/A file comes with specific restrictions that assure its robustness and self-sufficiency.
This article guides you through the process of converting PDF documents into PDF/A format using the QPDF library in C++. QPDF, a powerful C++ library, empowers developers to programmatically manage and convert PDF documents, including PDF-to-PDF/A conversion in just a few lines of code.
QPDF is a C++ library and command-line tool designed to support working with, transforming, and parsing PDF files. It allows developers to programmatically access and manipulate the content of PDF files, with word support. QPDF is an open-source project that offers a range of features, including encryption, decryption, linearization, optimization, and PDF/A conformance.
Before you begin, ensure that you have the following set up:
To include the QPDF header files in Code::Blocks, follow these steps:
Additionally, you need to establish a connection with the QPDF library during the linking phase. Follow these steps:
#include <iostream>
#include <qpdf/QPDF.hh>
#include <qpdf/QPDFWriter.hh>
This code incorporates essential header files for working with C++ standard input/output (iostream
) and the QPDF library.
In the main function (starting point of the C++ program), set paths for input and output files:
std::string input_pdf_path = "input.pdf";
std::string output_pdf_a_path = "output.pdfa";
These two lines declare and initialize two variables of type std::string
. These lines declare and initialize variables for input ("input.pdf") and output PDF/A ("output.pdfa") paths.
The input file is an editable form:
QPDF input_pdf;
input_pdf.processFile(input_pdf_path.c_str());
A QPDF
object named input_pdf
is created. processFile
function is used on the input_pdf
object, passing the input file path as an argument.
QPDFWriter
Object for Writing PDF/A FileQPDFWriter writer(input_pdf, output_pdf_a_path.c_str());
A QPDFWriter
object, writer
, is created to write the output PDF/A file.
writer.setQDFMode(true);
writer.write();
This code sets the PDF/A conformance using setQDFMode(true)
on the writer
object. The write()
function performs conversion on PDF document and save the output to a PDF/A file.
The output file is non-editable and PDF/A-compliant:
IronPDF is a .NET PDF library that provides comprehensive functionalities for working with PDF documents. It allows developers to create, modify, and convert PDF documents using C# or VB.NET. Users can use IronPDF for generating PDF files from HTML, ASPX, Word documents (.doc), or images dynamically, and incorporate rich elements like charts, tables, and images (like JPG, PNG formats) data. It also enables merging, splitting, and editing pages of existing PDF files, along with text extraction and content manipulation of PDF data.
IronPDF facilitates to convert PDF to the PDF/A-3b standard with just a few lines of code. The following code helps to achieve this task:
using IronPdf;
// Create a PdfDocument object or open any PDF file
PdfDocument pdf = PdfDocument.FromFile("wikipedia.pdf");
// Use the SaveAsPdfA method to save to file
pdf.SaveAsPdfA("pdf-a3-wikipedia.pdf", PdfAVersions.PdfA3);
using IronPdf;
// Create a PdfDocument object or open any PDF file
PdfDocument pdf = PdfDocument.FromFile("wikipedia.pdf");
// Use the SaveAsPdfA method to save to file
pdf.SaveAsPdfA("pdf-a3-wikipedia.pdf", PdfAVersions.PdfA3);
Imports IronPdf
' Create a PdfDocument object or open any PDF file
Private pdf As PdfDocument = PdfDocument.FromFile("wikipedia.pdf")
' Use the SaveAsPdfA method to save to file
pdf.SaveAsPdfA("pdf-a3-wikipedia.pdf", PdfAVersions.PdfA3)
This article guides through the C++ conversion of a standard PDF document into PDF/A format using the QPDF libraries. PDF/A compliance ensures content preservation and accessibility, making it ideal for archiving.
IronPDF also supports various format conversions such as HTML, images, and Word documents to PDF files. For further information, please visit this site.
IronPDF provides a free trial to test the functionality for commercial production. You can download the software from here.
9 .NET API products for your office documents