This is a migrated thread and some comments may be shown as answers.

Disable changing of Header/Footer in print settings of pdfviewernavigator

12 Answers 128 Views
PdfViewer and PdfViewerNavigator
This is a migrated thread and some comments may be shown as answers.
Tra
Top achievements
Rank 1
Tra asked on 12 Mar 2018, 07:51 AM
How can i disable tab of header/footer in print settings in pdfviewernavigator? Is this possible? Thanks in advanced

12 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 14 Mar 2018, 12:10 PM
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
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Richard
Top achievements
Rank 1
answered on 15 Mar 2018, 06:59 AM
What are the needed dlls in this class?
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 15 Mar 2018, 07:09 AM
Hello, Richard,

Thank you for writing.  

Note that RadPdfViewer requires .NET Framework 4.0 and cannot be used with an older version. The following references are necessary when using RadPdfViewer in your project:

  

I hope this information helps. Should you have further questions I would be glad to help. 
 
 Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Richard
Top achievements
Rank 1
answered on 15 Mar 2018, 07:47 AM
I got a error Telerik.WinControls.UI.RadPrintDocument' does not contain a definition for 'AutoPortraitLandscape' and no extension method 'AutoPortraitLandscape' accepting a first argument of type.
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 15 Mar 2018, 09:07 AM
Hello, Richard,

I suppose that you are using an older version because the AutoPortraitLandscape property is available in the latest version.  Could you please specify what is the exact version of the Telerik UI for WinForms suite that you are currently using? 

Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Richard
Top achievements
Rank 1
answered on 15 Mar 2018, 09:29 AM
I'm using version 14 
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 15 Mar 2018, 12:00 PM
Hello, Richard,      

Thank you for writing back. 

Telerik UI for WinForms suite uses the following versions format: [Year].[ReleaseNumber].[Date], e.g. 2018.1 220 for the latest version. I suppose that you may be using another product. Could you please confirm whether you use the Telerik UI for WinForms product and check the installed version in Visual Studio's Toolbox: 



I hope this information helps. If you have any additional questions, please let me know. 

 Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Richard
Top achievements
Rank 1
answered on 15 Mar 2018, 12:40 PM
I'm sorry I'm using 2015.
0
Richard
Top achievements
Rank 1
answered on 15 Mar 2018, 12:42 PM
I'm using 2015
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 15 Mar 2018, 01:27 PM
Hello, Richard,      

Thank you for writing back. 

Indeed, in Q2 2015 the AutoPortraitLandscape property is not available since this functionality had not been implemented yet for RadPdfViewer. You can simply comment this part of the code. Alternatively, feel free to upgrade to the latest version where the AutoPortraitLandscape property exists.  

If you have any additional questions, please let me know. 

 Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Richard
Top achievements
Rank 1
answered on 16 Mar 2018, 12:42 AM

how do I bind your custom class to my pdfviewernavigator so that i can disable my Header/Footer I tried using this

            this.radPdfViewerNavigator1.AssociatedViewer = this.radPdfViewer1;
            CustomPdfPrintPreviewDialog customPdfDialog = new CustomPdfPrintPreviewDialog();
            customPdfDialog(radPdfViewerNavigator1);         

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 16 Mar 2018, 07:33 AM
Hello, Richard,      

Thank you for writing back. 

I have attached a sample project for your reference. A RadPdfViewerNavigator and a RadPdfViewer are added to the form at design time by simply dragging the control from the toolbox and dropping in on the form. The RadPdfViewerNavigator.AssociatedControl is set the pdf viewer instance. Then, in the designer file you need to replace the default RadPdfViewer with the custom one: 
private void InitializeComponent()
{
    this.radPdfViewerNavigator1 = new Telerik.WinControls.UI.RadPdfViewerNavigator();
    this.radPdfViewer1 = new CustomPdfView();
 
    // some other code
}

I hope this information helps. If you have any additional questions, please let me know. 

 Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
PdfViewer and PdfViewerNavigator
Asked by
Tra
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Richard
Top achievements
Rank 1
Share this question
or