Back to Devexpress

PdfExportOptions.Validate() Method

corelibraries-devexpress-dot-xtraprinting-dot-pdfexportoptions-4d99151e.md

latest3.1 KB
Original Source

PdfExportOptions.Validate() Method

Checks the validity of PDF export options and returns a list of any detected inconsistencies.

Namespace : DevExpress.XtraPrinting

Assembly : DevExpress.Printing.v25.2.Core.dll

NuGet Package : DevExpress.Printing.Core

Declaration

csharp
public IList<string> Validate()
vb
Public Function Validate As IList(Of String)

Returns

TypeDescription
IList<String>

A collection of String values, specifying inconsistencies detected in the PDF export options.

|

Example

The following code illustrates how to use the PdfExportOptions.Validate method to check the validity of PDF export options.

Use this method to make sure that none of the specified options are mutually exclusive, e.g., when applying PDF/A options to a document (PdfExportOptions.PdfACompatibility).

In this example, the following inconsistencies will be detected.

  • “PDF/A standard implicitly forbids showing the print dialog on opening a document.”

  • “Encryption is not supported in a PDF/A document.”

  • C#

  • VB.NET

csharp
using DevExpress.XtraPrinting;
using DevExpress.XtraReports.UI;
using System;
using System.Collections.Generic;
// ...

using (XtraReport report = new XtraReport()) {
    PdfExportOptions options = new PdfExportOptions();
    options.PdfACompatibility = PdfACompatibility.PdfA1b;
    options.PasswordSecurityOptions.PermissionsPassword = "pwd";
    options.ShowPrintDialogOnOpen = true;
    IList<string> result = options.Validate();
    if (result.Count > 0)
        Console.WriteLine(String.Join(Environment.NewLine, result));
    else
        report.ExportToPdf("Result.pdf", options);
}
vb
Imports DevExpress.XtraPrinting
Imports DevExpress.XtraReports.UI
Imports System
Imports System.Collections.Generic
' ...

Using report As New XtraReport()
    Dim options As New PdfExportOptions()
    options.PdfACompatibility = PdfACompatibility.PdfA1b
    options.PasswordSecurityOptions.PermissionsPassword = "pwd"
    options.ShowPrintDialogOnOpen = True
    Dim result As IList(Of String) = options.Validate()
    If result.Count > 0 Then
        Console.WriteLine([String].Join(Environment.NewLine, result))
    Else
        report.ExportToPdf("Result.pdf", options)
    End If
End Using

See Also

PdfExportOptions Class

PdfExportOptions Members

DevExpress.XtraPrinting Namespace