Hello, Tra,
Thank you for writing.
Here is demonstrated a sample code snippet demonstrating how to create a custom
RadPdfViewer in order to hide the Headers/Footers tab in the
PdfPrintSettingsDialog:
public
class
CustomPdfView : RadPdfViewer
{
protected
override
RadPdfViewerElement CreateViewerElement()
{
return
new
CustomRadPdfViewerElement();
}
}
public
class
CustomRadPdfViewerElement : RadPdfViewerElement
{
public
CustomRadPdfViewerElement()
{
}
public
override
void
PrintPreview(RadPrintDocument document)
{
if
(document !=
null
)
{
document.AssociatedObject =
this
;
CustomPdfPrintPreviewDialog dialog =
new
CustomPdfPrintPreviewDialog(document);
dialog.ThemeName = ((RadControl)
this
.ElementTree.Control).ThemeName;
if
(dialog.DialogResult != DialogResult.Abort)
{
dialog.ShowDialog();
}
dialog.Dispose();
}
}
}
public
class
CustomPdfPrintPreviewDialog : PdfPrintPreviewDialog
{
RadPrintDocument printDocument;
RadFixedDocument fixedDocument;
public
CustomPdfPrintPreviewDialog(RadPrintDocument document) :
base
(document)
{
this
.printDocument = document;
RadPdfViewerElement pdfViewerElement = printDocument.AssociatedObject
as
RadPdfViewerElement;
RadPdfViewer pdfViewer = printDocument.AssociatedObject
as
RadPdfViewer;
this
.fixedDocument = pdfViewer ==
null
? pdfViewerElement ==
null
?
null
: pdfViewerElement.Document : pdfViewer.Document;
}
protected
override
void
OnShowPrintSettingsDialog()
{
if
(
this
.printDocument ==
null
)
{
return
;
}
PdfPrintSettingsDialog dialog =
this
.printDocument.AssociatedObject.GetSettingsDialog(
this
.printDocument)
as
PdfPrintSettingsDialog;
RadPageView pageView = dialog.Controls[
"radPageView1"
]
as
RadPageView;
pageView.Pages.Last().Item.Visibility = ElementVisibility.Collapsed;
RadForm radDialog = dialog
as
RadForm;
if
(radDialog !=
null
)
{
radDialog.ThemeName =
this
.ThemeName;
}
if
(dialog.ShowDialog() == DialogResult.OK)
{
this
.printDocument.PrinterSettings.PrintRange = System.Drawing.Printing.PrintRange.AllPages;
this
.UpdatePreview();
}
RadGroupBox radGroupBoxOrientation =
this
.Controls[
"radGroupBoxOrientation"
]
as
RadGroupBox;
RadRadioButton radRadioButtonLandscape = radGroupBoxOrientation.Controls[
"radRadioButtonLandscape"
]
as
RadRadioButton;
radRadioButtonLandscape.ToggleState =
this
.printDocument.Landscape && !
this
.printDocument.AutoPortraitLandscape ? ToggleState.On : ToggleState.Off;
RadRadioButton radRadioButtonAuto = radGroupBoxOrientation.Controls[
"radRadioButtonAuto"
]
as
RadRadioButton;
radRadioButtonAuto.ToggleState =
this
.printDocument.AutoPortraitLandscape ? ToggleState.On : ToggleState.Off;
}
private
void
UpdatePreview()
{
if
(
this
.fixedDocument ==
null
||
this
.fixedDocument.Pages.Count == 0)
{
return
;
}
this
.UpdateScaleLabelText();
this
.UpdatePaperSizeText();
this
.UpdatePagePreview();
this
.UpdateCurrentPageText();
}
}
I hope this information helps. Should you have further questions I would be glad to help.
Regards,
Dess
Progress Telerik