Workaround: until the feature be implemented one can print each page individually respecting its orientation whether it is portrait or landscape public partial class Form1 : Form { public Form1() { InitializeComponent(); this.radPdfViewer1.LoadDocument(@"..\..\sample.pdf"); } private void radButton1_Click(object sender, EventArgs e) { RadPrintDocument doc = new RadPrintDocument(); doc.AssociatedObject = this.radPdfViewer1; for (int i = 0; i < this.radPdfViewer1.Document.Pages.Count; i++) { RadFixedPage page = this.radPdfViewer1.Document.Pages[i]; doc.CurrentPage = i; doc.PrinterSettings.PrintRange = PrintRange.CurrentPage; doc.Landscape = page.ActualWidth > page.ActualHeight; doc.Print(); } } }
To reproduce: - Print a document that fills the entire page. - On the print preview dialog the page is centered however when printed it is not. In addition, one should be able to control the page scaling.
at System.Drawing.Drawing2D.GraphicsPath.Clone() at Telerik.WinControls.PdfViewer.PdfElementsRenderer.RenderGlyph(Glyph glyph) at Telerik.WinControls.PdfViewer.FixedPageRenderer.DrawGlyph(Glyph glyph, Graphics graphics) at Telerik.WinControls.PdfViewer.FixedPageRenderer.DrawContentElement(IContentElement contentElement, Graphics graphics) at Telerik.WinControls.PdfViewer.FixedPageRenderer.DrawGlyphsLayoutBox(GlyphsLayoutBox glyphBox, Graphics graphics) at Telerik.WinControls.PdfViewer.FixedPageRenderer.DrawContentElement(IContentElement contentElement, Graphics graphics) at Telerik.WinControls.PdfViewer.FixedPageRenderer.DrawContainer(Container container, Graphics graphics) at Telerik.WinControls.PdfViewer.FixedPageRenderer.DrawContentElement(IContentElement contentElement, Graphics graphics) at Telerik.WinControls.PdfViewer.FixedPageRenderer.DrawContainer(Container container, Graphics graphics) at Telerik.WinControls.PdfViewer.FixedPageRenderer.DrawContentElement(IContentElement contentElement, Graphics graphics) at Telerik.WinControls.PdfViewer.FixedPageRenderer.DrawPage(ContentCollection content, Graphics graphics, Matrix pageTransform) at Telerik.WinControls.UI.RadFixedPageElement.pageRenderer_DoWork(Object sender, DoWorkEventArgs e) at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e) at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument) at System.Drawing.Drawing2D.GraphicsPath.Clone() at Telerik.WinControls.PdfViewer.PdfElementsRenderer.RenderGlyph(Glyph glyph) at Telerik.WinControls.PdfViewer.FixedPageRenderer.DrawGlyph(Glyph glyph, Graphics graphics) at Telerik.WinControls.PdfViewer.FixedPageRenderer.DrawContentElement(IContentElement contentElement, Graphics graphics) at Telerik.WinControls.PdfViewer.FixedPageRenderer.DrawGlyphsLayoutBox(GlyphsLayoutBox glyphBox, Graphics graphics) at Telerik.WinControls.PdfViewer.FixedPageRenderer.DrawContentElement(IContentElement contentElement, Graphics graphics) at Telerik.WinControls.PdfViewer.FixedPageRenderer.DrawContainer(Container container, Graphics graphics) at Telerik.WinControls.PdfViewer.FixedPageRenderer.DrawContentElement(IContentElement contentElement, Graphics graphics) at Telerik.WinControls.PdfViewer.FixedPageRenderer.DrawContainer(Container container, Graphics graphics) at Telerik.WinControls.PdfViewer.FixedPageRenderer.DrawContentElement(IContentElement contentElement, Graphics graphics) at Telerik.WinControls.PdfViewer.FixedPageRenderer.DrawPage(ContentCollection content, Graphics graphics, Matrix pageTransform) at Telerik.WinControls.UI.RadFixedPageElement.pageRenderer_DoWork(Object sender, DoWorkEventArgs e) at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e) at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)
1- the load of a document take a while to load (if successed). 2- An unhandled exception thrown while loading a document (Out of memory or Invalid parameter) the file that i'm trying to load is attached and created using Telerik Document Processing Library. ************** Exception Text ************** System.ArgumentException: Parameter is not valid. at System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format) at System.Drawing.Bitmap..ctor(Image original, Int32 width, Int32 height) at System.Drawing.Bitmap..ctor(Image original) at Telerik.WinControls.PdfViewer.PdfElementsRenderer.RenderImage(ImageSource source, ResourceKey key, BackgroundWorker cancellationToken) at Telerik.WinControls.PdfViewer.FixedPageRenderer.DrawImage(Image image, Graphics graphics) at Telerik.WinControls.PdfViewer.FixedPageRenderer.DrawContentElement(IContentElement contentElement, Graphics graphics) at Telerik.WinControls.PdfViewer.FixedPageRenderer.DrawContainer(Container container, Graphics graphics) at Telerik.WinControls.PdfViewer.FixedPageRenderer.DrawContentElement(IContentElement contentElement, Graphics graphics) at Telerik.WinControls.PdfViewer.FixedPageRenderer.DrawContainer(Container container, Graphics graphics) at Telerik.WinControls.PdfViewer.FixedPageRenderer.DrawContentElement(IContentElement contentElement, Graphics graphics) at Telerik.WinControls.PdfViewer.FixedPageRenderer.DrawPage(ContentCollection content, Graphics graphics, Matrix pageTransform) at Telerik.WinControls.UI.FixedPagePreRenderer.rendererWorker_DoWork(Object sender, DoWorkEventArgs e) at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e) at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument) Thank you
PDF Export needs to support certificate signatures so the end user of the document knows the document hasn't been changed.
Workaround: print the document page by page: private void radButton1_Click(object sender, EventArgs e) { RadPrintDocument d = new RadPrintDocument(); d.PrinterSettings.PrintRange = PrintRange.CurrentPage; d.AssociatedObject = this.radPdfViewer1; for (int i = 0; i < this.radPdfViewer1.Document.Pages.Count; i++) { d.CurrentPage = i; d.Print(); } }
Note: If you use the next button to navigate to the next search result, the user should be notified when the end of the document is reached as well. Workaround: public Form1() { InitializeComponent(); this.radPdfViewer1.LoadDocument(@"..\..\..\samplePdf.pdf"); //create a new button CommandBarButton findNext = new CommandBarButton(); findNext.Text = PdfViewerLocalizationProvider.CurrentProvider.GetLocalizedString(PdfViewerStringId.NavigatorFindNextButton); findNext.Click += findNext_Click; findNext.Image = this.radPdfViewerNavigator1.FindNextButton.Image; //hide the currently available button this.radPdfViewerNavigator1.DefaultStrip.Items.Add(findNext); this.radPdfViewerNavigator1.FindNextButton.Visibility = ElementVisibility.Collapsed; } private void findNext_Click(object sender, EventArgs e) { if (this.radPdfViewerNavigator1.SearchTextBox.Text != string.Empty) { if (this.radPdfViewerNavigator1.AssociatedViewer == null || this.radPdfViewerNavigator1.AssociatedViewer.Document == null) { return; } PropertyInfo internalDocumentPI = typeof(RadFixedDocument).GetProperty("InternalDocument", BindingFlags.NonPublic | BindingFlags.Instance); object internalDocument = internalDocumentPI.GetValue(this.radPdfViewerNavigator1.AssociatedViewer.Document, null); object textSearch = internalDocument.GetType().GetProperty("TextSearch", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(internalDocument, null); MethodInfo mi = textSearch.GetType().GetMethod("Find", BindingFlags.Public | BindingFlags.Instance); TextSearchOptions searchOptions = new TextSearchOptions(false); SearchResult searchResult = mi.Invoke(textSearch, new object[2] { this.radPdfViewerNavigator1.SearchTextBox.Text, searchOptions }) as SearchResult; if (searchResult.Result != null) { this.radPdfViewerNavigator1.AssociatedViewer.Select(searchResult); } else { RadMessageBox.Show("No matches"); } } }