Validate PDF/A
This sample shows you how to verify ISO 19005-1 and ISO 19005-2 compliance for existing PDF documents.
It is recommended that you have already reviewed the Getting Started sample, since that includes Licensing and Framework initialization code required to make this sample run.
				
				1
				2
				3
				4
				5
				6
				7
				8
				9
				10
				11
				12
				13
				14
				15
				16
				17
				18
				19
				20
				21
				22
				23
				24
				25
				26
				27
				28
				29
				30
				31
				32
				33
				34
				35
				36
				37
				38
				39
				40
				41
				42
				43
				44
				45
				46
				47
				48
				49
				50
				51
				52
				53
				54
				55
			
			
				
				using System;
				using SolidFramework.Converters;
				using SolidFramework.Converters.Plumbing;
				 
				namespace CSharp_Tutorials
				{
				    public static partial class Tutorials
				    {
				        public static bool ValidatePdfA(string pdfPath, string outputPath)
				        {
				            // Create a PdfToPdfAConverter
				            using (var converter = new PdfToPdfAConverter())
				            {
				                // Add the PDF file to validate
				                converter.AddSourceFile(pdfPath);
				 
				                // Set the PDF/A mode to validate as
				                converter.ValidationMode = SolidFramework.Plumbing.ValidationMode.PdfA2B;
				 
				                Console.WriteLine("Validating " + pdfPath);
				 
				                // Validate the file
				                converter.Validate();
				 
				                // Check the results
				                foreach (var result in converter.Results)
				                {
				                    var status = result.Status;
				                    if (status != ConversionStatus.Success && status != ConversionStatus.PdfAError)
				                    {
				                        Console.WriteLine("Validating " + pdfPath + " failed with status: " + status);
				                        Console.WriteLine();
				                        return false;
				                    }
				                }
				 
				                // Save the report
				                var report = converter.Report;
				                if (report == null)
				                {
				                    Console.WriteLine("Validating " + pdfPath + " did not create a report");
				                    Console.WriteLine();
				                    return false;
				                }
				            }
				            Console.WriteLine("Successfully validated " + pdfPath + ". Report has been saved to " + outputPath);
				            Console.WriteLine();
				            return true;
				        }
				    }
				}
				 
			
		
				
				1
				2
				3
				4
				5
				6
				7
				8
				9
				10
				11
				12
				13
				14
				15
				16
				17
				18
				19
				20
				21
				22
				23
				24
				25
				26
				27
				28
				29
				30
				31
				32
				33
				34
				35
				36
				37
				38
				39
				40
				41
				42
				43
				44
				45
				46
				47
				48
				49
				50
				51
				52
				53
			
			
				
				Imports System
				Imports SolidFramework.Converters
				Imports SolidFramework.Converters.Plumbing
				Imports SolidFramework.Pdf.Reports
				 
				Namespace VBNet_Tutorials
				    Partial Module Tutorials
				        Function ValidatePdfA(ByVal pdfPath As String, ByVal outputPath As String) As Boolean
				 
				            ' Create a PdfToPdfAConverter
				            Using converter As PdfToPdfAConverter = New PdfToPdfAConverter()
				 
				                ' Add the PDF file to validate
				                converter.AddSourceFile(pdfPath)
				 
				                ' Set the PDF/A mode to validate as
				                converter.ValidationMode = SolidFramework.Plumbing.ValidationMode.PdfA2B
				 
				                Console.WriteLine("Validating " & pdfPath)
				 
				                ' Validate the file
				                converter.Validate()
				 
				                ' Check the results
				                For Each result As ConversionResult In converter.Results
				                    Dim status As ConversionStatus = result.Status
				 
				                    If status <> ConversionStatus.Success AndAlso status <> ConversionStatus.PdfAError Then
				                        Console.WriteLine("Validating " & pdfPath & " failed with status: " & status)
				                        Console.WriteLine()
				                        Return False
				                    End If
				                Next
				 
				                Dim report As PdfAReport = converter.Report
				 
				                If report Is Nothing Then
				                    Console.WriteLine("Validating " & pdfPath & " did not create a report")
				                    Console.WriteLine()
				                    Return False
				                End If
				            End Using
				 
				            Console.WriteLine("Successfully validated " & pdfPath & ". Report has been saved to " & outputPath)
				            Console.WriteLine()
				            Return True
				        End Function
				    End Module
				End Namespace
				 
			
		
				
				1
				2
				3
				4
				5
				6
				7
				8
				9
				10
				11
				12
				13
				14
				15
				16
				17
				18
				19
				20
				21
				22
				23
				24
				25
				26
				27
				28
				29
				30
				31
				32
				33
				34
				35
				36
				37
				38
				39
				40
				41
				42
				43
				44
				45
				46
				47
				48
			
			
				
				#include "Tutorials.h"
				 
				using namespace SolidFramework::Converters::Plumbing;
				using namespace SolidFramework::Converters;
				 
				bool ValidatePdfA(const wstring & pdfPath, const wstring & outputPath)
				{
				    // Create a PdfToPdfAConverter
				    auto converter = make_shared<PdfToPdfAConverter>();
				 
				    // Add the PDF file to validate
				    converter->AddSourceFile(pdfPath);
				    
				    // Set the PDF/A mode to validate as
				    converter->SetValidationMode(SolidFramework::Plumbing::ValidationMode::PdfA2B);
				 
				    wcout << L"Validating " << pdfPath << endl;
				 
				    // Validate the file
				    converter->Validate();
				 
				    // Check the results
				    auto results = converter->GetResults();
				    for (const auto & result: results)
				    {
				        auto status = result->GetStatus();
				        if (status != ConversionStatus::Success && status != ConversionStatus::PdfAError)
				        {
				            wcout << L"Validating " << pdfPath << L" failed with status " << (int)status << endl << endl;
				            return false;
				        }
				    }
				 
				    // Save the report
				    auto report = converter->GetReport();
				    if (report == nullptr)
				    {
				        wcout << L"Validating " << pdfPath << L" did not create a report" << endl << endl;
				        return false;
				    }
				    report->Save(outputPath);
				    wcout << L"Successfully validated " << pdfPath << L". Report has been saved to " << outputPath << endl << endl;
				    return true;
				}
				 
			
		