Back to Devexpress

How to: Hide some of the Export Options in the Print Preview

windowsforms-3229-controls-and-libraries-printing-exporting-examples-print-preview-how-to-hide-some-of-the-export-options-in-the-print-preview.md

latest3.2 KB
Original Source

How to: Hide some of the Export Options in the Print Preview

  • Jan 15, 2024
  • 2 minutes to read

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

How to: Change the Measurement System Exposed in the Print Preview