C++: Convert PDF to PDF/A or PDF/X

PDF/A and PDF/X are two subsets of PDF file formats that were created to standardize the use of PDF in different areas. The former, PDF/A format, is primarily used for the long-term preservation or archiving of electronic documents, while the latter, PDF/X format, is specifically designed for the reliable and accurate pre-print exchange of graphic data. This article will demonstrate how to programmatically convert PDF to PDF/A or PDF/X format using Spire.PDF for C++.

Install Spire.PDF for C++

There are two ways to integrate Spire.PDF for C++ into your application. One way is to install it through NuGet, and the other way is to download the package from our website and copy the libraries into your program. Installation via NuGet is simpler and more recommended. You can find more details by visiting the following link.

Integrate Spire.PDF for C++ in a C++ Application

Convert PDF to PDF/A-1A, 2A, 3A, 1B, 2B and 3B in C++

With the passage of time, PDF/A has been continuously enhanced and further standards such as PDF/A-1, PDF/A-2 and PDF/A-3 have been developed. In addition, each standard defines several different levels of conformance. The following are the steps to convert PDF to PDF/A-1A, 2A, 3A, 1B, 2B and 3B compliant files.

  • Create a PdfStandardsConverter instance, and pass in a sample PDF file as a parameter.
  • Convert the sample file to PdfA1A conformance level using PdfStandardsConverter->ToPdfA1A() method.
  • Convert the sample file to PdfA1B conformance level using PdfStandardsConverter->ToPdfA1B() method.
  • Convert the sample file to PdfA2A conformance level using PdfStandardsConverter->ToPdfA2A() method.
  • Convert the sample file to PdfA2B conformance level using PdfStandardsConverter->ToPdfA2B() method.
  • Convert the sample file to PdfA3A conformance level using PdfStandardsConverter->ToPdfA3A() method.
  • Convert the sample file to PdfA3B conformance level using PdfStandardsConverter->ToPdfA3B() method.
  • C++
#include "Spire.Pdf.o.h";

using namespace Spire::Pdf;
using namespace std;
int main() {

	//Specify the input file
	wstring inputFile = L"Data\\Test.pdf";

	//Create a PdfStandardsConverter instance
	PdfStandardsConverter* converter = new PdfStandardsConverter(inputFile.c_str());

	//Convert to PdfA1A
	converter->ToPdfA1A(L"Output/ToPdfA1A.pdf");

	//Convert to PdfA1B
	converter->ToPdfA1B(L"Output/ToPdfA1B.pdf");

	//Convert to PdfA2A
	converter->ToPdfA2A(L"Output/ToPdfA2A.pdf");

	//Convert to PdfA2B
	converter->ToPdfA2B(L"Output/ToPdfA2B.pdf");

	//Convert to PdfA3A
	converter->ToPdfA3A(L"Output/ToPdfA3A.pdf");

	//Convert to PdfA3B
	converter->ToPdfA3B(L"Output/ToPdfA3B.pdf");

	delete converter;
}

C++: Convert PDF to PDF/A or PDF/X

Convert PDF to PDF/X-1a:2001 Standard in C++

PDF/X-1a:2001 is a standard published in 2001 and has been widely adopted by the printing and publishing industries. It restricts certain features of the PDF format to ensure that the file is suitable for high quality printing. The following are the steps to convert PDF to a PDF/X-1a:2001 standard-compliant file.

  • Create a PdfStandardsConverter instance, and pass in a sample PDF file as a parameter.
  • Convert the sample file to PDF/X-1a:2001 standards compliant file using PdfStandardsConverter->ToPdfX1A2001() method.
  • C++
#include "Spire.Pdf.o.h";

using namespace Spire::Pdf;
using namespace std;
int main() {

	//Specify the input file
	wstring inputFile = L"Data\\Test.pdf";

	//Create a PdfStandardsConverter instance
	PdfStandardsConverter* converter = new PdfStandardsConverter(inputFile.c_str());

	//Convert to PDF/X-1a:2001
	converter->ToPdfX1A2001(L"Output/ToPdfX1A2001.pdf");
	converter->Dispose();
	delete converter;
}

C++: Convert PDF to PDF/A or PDF/X

Apply for a Temporary License

If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.