Convert and validate PDF/E in C++
Convert PDFs to PDF/E-1 and validate documents against the PDF/E-1 standard.
Configure the Aspose.PDF for C++ SDK before running these functions. Pass an existing input file and a writable destination path; create any required output directories first. Each function is an independent example, and its options do not carry over to other examples.
Conversion examples use ConvertErrorAction::Delete, which can remove elements that cannot conform to the selected standard. Review the conversion log and validate the saved PDF before relying on its compliance. The examples do not check the return value of Convert().
Convert PDF to PDF/E-1
Use PdfFormat::PDF_E_1, write a .log.xml conversion report, and save the resulting PDF.
- Open the input PDF as Document.
- Derive the
.log.xmlreport path fromoutputFile. - Convert to
PdfFormat::PDF_E_1with Document::Convert() andConvertErrorAction::Delete. - Save the result with Document::Save().
#include <Aspose.PDF.Cpp/Document.h>
#include <Aspose.PDF.Cpp/IO/ConvertStrategies/PdfFormat.h>
#include <Aspose.PDF.Cpp/IO/ConvertStrategies/ConvertErrorAction.h>
#include <system/io/path.h>
namespace ConvertingExamples
{
using namespace System;
using namespace Aspose::Pdf;
void ConvertPdfToPdfE(String inputFile, String outputFile)
{
auto document = MakeObject<Document>(inputFile);
auto logFile = System::IO::Path::ChangeExtension(outputFile, u".log.xml");
document->Convert(logFile, PdfFormat::PDF_E_1, ConvertErrorAction::Delete);
document->Save(outputFile);
}
}
Validate PDF/E-1 compliance
Call Validate() for PDF_E_1 and print its Boolean result. outputFile names the validation report, not a converted PDF. The input document is not saved or modified.
- Open the input PDF.
- Call Document::Validate() with the report path and PdfFormat::PDF_E_1.
- Print whether the document conforms.
#include <Aspose.PDF.Cpp/Document.h>
#include <Aspose.PDF.Cpp/IO/ConvertStrategies/PdfFormat.h>
#include <iostream>
namespace ConvertingExamples
{
using namespace System;
using namespace Aspose::Pdf;
void ValidatePdfE(String inputFile, String outputFile)
{
auto document = MakeObject<Document>(inputFile);
const bool isValid = document->Validate(outputFile, PdfFormat::PDF_E_1);
std::cout << (isValid ? "Conforms to PDF/E." : "Does not conform to PDF/E.") << std::endl;
}
}