Back to Devexpress

ExportOptions.SetOptionVisibility(ExportOptionKind, Boolean) Method

corelibraries-devexpress-dot-xtraprinting-dot-exportoptions-dot-setoptionvisibility-x28-devexpress-dot-xtraprinting-dot-exportoptionkind-system-dot-boolean-x29.md

latest5.3 KB
Original Source

ExportOptions.SetOptionVisibility(ExportOptionKind, Boolean) Method

Changes the visibility of the specified export option in the Print Preview ( only for desktop platforms ).

Namespace : DevExpress.XtraPrinting

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

NuGet Package : DevExpress.Printing.Core

Declaration

csharp
public void SetOptionVisibility(
    ExportOptionKind optionKind,
    bool visible
)
vb
Public Sub SetOptionVisibility(
    optionKind As ExportOptionKind,
    visible As Boolean
)

Parameters

NameTypeDescription
optionKindExportOptionKind

An ExportOptionKind enumeration value which specifies the export option whose visibility needs to be changed.

| | visible | Boolean |

true to make the export option visible; otherwise, false.

|

Remarks

Use the SetOptionVisibility method to change the visibility of only one export option at a time. To change the visibility of several export options at the same time, use the ExportOptions.SetOptionsVisibility method instead.

Note

To get the current visibility state of an export option, the ExportOptions.GetOptionVisibility method should be used.

Example

This example illustrates how to hide some of the export options from a print preview by using the ExportOptions.SetOptionVisibility and ExportOptions.SetOptionsVisibility methods.

The following code hides some of the PDF-specific export options.

All available export options are listed in the ExportOptionKind enumeration.

csharp
using System.Drawing;
using DevExpress.XtraPrinting;
// ...

private void Form1_Load(object sender, EventArgs e) {
    PrintingSystem ps = new PrintingSystem();
    documentViewer1.PrintingSystem = ps;

    // Draw a simple text brick.
    ps.Begin();
    ps.Graph.DrawString("Some Text", new RectangleF(0, 20, 200, 20));
    ps.End();

    // Obtain its Export options.
    ExportOptions options = ps.ExportOptions;

    // Hide the "Never Embedded Fonts" option, if required.
    if(options.GetOptionVisibility(ExportOptionKind.PdfNeverEmbeddedFonts) != false) {
        options.SetOptionVisibility(ExportOptionKind.PdfNeverEmbeddedFonts, false);
    }

    // Hide all Document Options for PDF export.
    options.SetOptionsVisibility(new ExportOptionKind[] { ExportOptionKind.PdfDocumentApplication,
        ExportOptionKind.PdfDocumentAuthor, ExportOptionKind.PdfDocumentKeywords,
        ExportOptionKind.PdfDocumentSubject, ExportOptionKind.PdfDocumentTitle}, false);            
}
vb
Imports System.Drawing
Imports DevExpress.XtraPrinting
' ...

Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
    Dim ps As New PrintingSystem()
    documentViewer1.PrintingSystem = ps

    ' Draw a simple text brick.
    ps.Begin()
    ps.Graph.DrawString("Some Text", New RectangleF(0, 20, 200, 20))
    ps.End()

    ' Obtain its Export options.
    Dim options As ExportOptions = ps.ExportOptions

    ' Hide the "Never Embedded Fonts" option, if required.
    If options.GetOptionVisibility(ExportOptionKind.PdfNeverEmbeddedFonts) <> False Then
        options.SetOptionVisibility(ExportOptionKind.PdfNeverEmbeddedFonts, False)
    End If

    ' Hide all Document Options for PDF export.
    options.SetOptionsVisibility(New ExportOptionKind() { ExportOptionKind.PdfDocumentApplication, _
        ExportOptionKind.PdfDocumentAuthor, ExportOptionKind.PdfDocumentKeywords, ExportOptionKind.PdfDocumentSubject, _
        ExportOptionKind.PdfDocumentTitle}, False)
End Sub

See Also

SetOptionsVisibility(ExportOptionKind[], Boolean)

GetOptionVisibility(ExportOptionKind)

ExportOptions Class

ExportOptions Members

DevExpress.XtraPrinting Namespace