VintaSoft PDF .NET Plug-in Discussions
Questions, comments and suggestions concerning VintaSoft PDF .NET Plug-in.
Board index < VintaSoft Imaging < VintaSoft PDF .NET Plug-in Discussions
private static int VerifyDocument(System.IO.Stream stream) {
PdfDocumentVerifier verifier = PdfAVerifier.Create(PdfDocumentConformance.PdfA_3u);
using (ProcessingState state = new ProcessingState()) {
using (VerificationProfileResult result = verifier.Verify(stream, state)) {
if (result.IsPassed) {
//passed A3-A
return 0;
} else {
//...
}
}
}
return -1;
}
Convert code:
private static int ConvertDocument(System.IO.Stream stream) {
PdfDocumentConverter converter = PdfAConverter.Create(PdfDocumentConformance.PdfA_3u);
using (ProcessingState state = new ProcessingState()) {
using (ConversionProfileResult result = converter.Convert(stream, state)) {
if (result.IsSuccessful) {
//Successful but still A3-A
return 0;
} else {
//...
}
}
}
return -1;
}
private static void ConvertDocumentToPdfA3u(System.IO.Stream stream)
{
// create PDF/A-3u converter
Vintasoft.Imaging.Pdf.Processing.PdfDocumentConverter converter =
Vintasoft.Imaging.Pdf.Processing.PdfA.PdfAConverter.Create(PdfDocumentConformance.PdfA_3u);
// create object that stores state of PDF/A conversion process
using (Vintasoft.Imaging.Processing.ProcessingState state = new Vintasoft.Imaging.Processing.ProcessingState())
{
// open PDF document
using (Vintasoft.Imaging.Pdf.PdfDocument document = new Vintasoft.Imaging.Pdf.PdfDocument(stream))
{
// delete metadata of PDF document
document.Catalog.Metadata = null;
// convert document to PDF/A-3u
using (Vintasoft.Imaging.Processing.ConversionProfileResult result = converter.Convert(document, state))
{
// if document is not converted
if (!result.IsSuccessful)
throw result.CreateConversionException();
}
// save converted document
document.Save(stream);
}
}
}
Best regards, Alexander