Disable changing of Header/Footer in print settings of pdfviewernavigator

13 posts, 0 answers
  1. Tra
    Tra avatar
    2 posts
    Member since:
    Feb 2018

    Posted 12 Mar 2018 Link to this post

    How can i disable tab of header/footer in print settings in pdfviewernavigator? Is this possible? Thanks in advanced
  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3174 posts

    Posted 14 Mar 2018 Link to this post

    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.
  3. Richard
    Richard avatar
    8 posts
    Member since:
    Mar 2018

    Posted 15 Mar 2018 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    What are the needed dlls in this class?
  4. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3174 posts

    Posted 15 Mar 2018 Link to this post

    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.
  5. Richard
    Richard avatar
    8 posts
    Member since:
    Mar 2018

    Posted 15 Mar 2018 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    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.
  6. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3174 posts

    Posted 15 Mar 2018 Link to this post

    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.
  7. Richard
    Richard avatar
    8 posts
    Member since:
    Mar 2018

    Posted 15 Mar 2018 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    I'm using version 14 
  8. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3174 posts

    Posted 15 Mar 2018 Link to this post

    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.
  9. Richard
    Richard avatar
    8 posts
    Member since:
    Mar 2018

    Posted 15 Mar 2018 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    I'm sorry I'm using 2015.
  10. Richard
    Richard avatar
    8 posts
    Member since:
    Mar 2018

    Posted 15 Mar 2018 in reply to Richard Link to this post

    I'm using 2015
  11. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3174 posts

    Posted 15 Mar 2018 Link to this post

    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.
  12. Richard
    Richard avatar
    8 posts
    Member since:
    Mar 2018

    Posted 15 Mar 2018 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    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);         

  13. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3174 posts

    Posted 16 Mar 2018 Link to this post

    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.
Back to Top