White PDF issue

11 posts, 0 answers
  1. Andrea Riva
    Andrea Riva avatar
    3 posts
    Member since:
    Feb 2010

    Posted 19 Mar 2013 Link to this post

    Hi,
    we have an issue with the version 2011.3.1220.1040 of the RadPDFViewer.
    With many PDFs it works fine, but with some PDFs the document source, after setting it, it still at null. I've tryed the online demo and the PDFs work fine, so it is possibile that there is a bug with our assembly?

    Thank you very much,
    Andrea Riva
  2. Kammen
    Admin
    Kammen avatar
    312 posts

    Posted 19 Mar 2013 Link to this post

    Hi Andrea,

    PdfDocumentSource loads the PDF document asynchronously. Thus, it is completely natural that the document is null.

    As for our online demo, with the Q1 release (2013.1 220), we have implemented a whole new text rendering system that greatly improves the way PDF documents (text) are displayed in RadPdfViewer. This means that upgrading to the latest version would be a good idea.

    Hope this answers your question.

    All the best,
    Kammen
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
  4. Andrea Riva
    Andrea Riva avatar
    3 posts
    Member since:
    Feb 2010

    Posted 19 Mar 2013 Link to this post

    Thanks for the quick answer.
    I have told you about the "null" of the document source for give you more information.
    However many PDFs are displayed correctly, while others aren't displayed: they only show a white "page".
    The only thing that I can suppose is that there is a problem when PDFs have large images. In these cases the PDFViewer doesn't display the PDF.
    In particular, one of the PDF that isn't displayed have only images, not text.

    This is why I'm asking you about a bug or similar.

    Thank you,
    Andrea Riva
  5. Angel
    Angel avatar
    8 posts
    Member since:
    Apr 2011

    Posted 21 Mar 2013 Link to this post

    I've upgrade the newest version, 2013.1.220.1050, and the new RadPdfViewer doesn't work like old one (our last one was Q3.2012).
    The pdf files we have stored, are charged on PdfViewer, but they are not visibles. I can store it on my desktop (with own button save as..)
    The Print button doesn't open. The Open Button, to load a pdf from Desktop, doesn't load.  A pdf file created with Export option of Reporting Telerik, also is not visible with new PdfViewer. Nothing

    I've Telerik.Windows.Documents.Core and use some like this:
    VisorPdf.DocumentSource = new Telerik.Windows.Documents.Fixed.PdfDocumentSource(stream);

    How I can use the old control, in the new version?
    Thanks in advance
    Angel

  6. Petya
    Admin
    Petya avatar
    975 posts

    Posted 22 Mar 2013 Link to this post

    Hello Andrea, Angel,

    @Andrea In regard to images, there were a lot of changes introduced with the last couple of releases. As you can see here, support for more image formats(among other things) was introduced with Q1 2012. Generally, RadPdfViewer is constantly improving and most likely the difference between our online demo and your project comes from a feature implemented at a later stage. Unfortunately, there is not much we can do to help you, except to advise you to upgrade.

    @Angel Have you tried verifying the behavior of your files in our online demo? Generally, with Q1 there were some changes and we are currently working on resolving an issue that consists of some resources not being accessed. The issue should be resolved in next weeks's LIB. I suggest you test the behavior of your files then and get back to us if you are still experiencing problems.

    Please, excuse us for the inconvenience.
     
    Regards,
    Petya
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  7. Angel
    Angel avatar
    8 posts
    Member since:
    Apr 2011

    Posted 22 Mar 2013 Link to this post

    Hi Petya:
    Thank you your soon reply. I tested with online demo radpdfviewer, opening samples of pdf's who I can't read on my project.
    And the visualization is ok, with your demo.
    I think the only one change I made was upgrade to last version. I link a pdf sample, the view of my formpdfviewer and below xaml and cs codes, so please, can you check it to solve?.

        https://www.dropbox.com/s/3sg33ouwqyfxge9/ULTIMO.pdf

    Thanks in advance
    Angel

    <base:FormularioBase x:Class="SIAR.Silverlight.Formularios.FORMPDFVIEWER"
        xmlns:base="clr-namespace:SIAR.Silverlight.Formularios"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
        xmlns:converters="clr-namespace:Telerik.Windows.Documents.Converters;assembly=Telerik.Windows.Controls.FixedDocumentViewers"
        xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
        xmlns:arcoControles="clr-namespace:ArcoControles_SL;assembly=ArcoControles_SL"
        xmlns:tt="clr-namespace:Silverlight.Controls.ToolTips;assembly=Silverlight.Controls.ToolTips"
        xmlns:myWeb="clr-namespace:SIAR.Silverlight.Web"
        xmlns:myBL="clr-namespace:SIAR.BL"
        xmlns:arco="clr-namespace:SIAR.Silverlight"
        mc:Ignorable="d"
        d:DesignHeight="220" d:DesignWidth="420" TabNavigation="Cycle">

        <base:FormularioBase.Resources>
        </base:FormularioBase.Resources>

        <telerik:RadBusyIndicator Name="FormBusyIndicator">
            <Grid x:Name="LayoutRoot" Background="{StaticResource ColorFondoFormularios}" >
                <Grid.RowDefinitions>
                    <RowDefinition Height="35"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>

                <telerik:RadToolBar Grid.Row="0" Grid.Column="0" DataContext="{Binding ElementName=VisorPDF, Path=Commands}">
                    <telerik:RadToolBar.Resources>
                        <converters:DoubleToStringPercentConverter x:Key="doubleToStringPercentConverter" />
                        <converters:FixedDocumentViewerModeConverter x:Key="ModeConverter" />
                    </telerik:RadToolBar.Resources>

                    <telerik:RadButton HorizontalAlignment="Left" VerticalAlignment="Stretch" Margin="2" Padding="0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" IsBackgroundVisible="False" Click="Save_Click">
                        <ToolTipService.ToolTip>
                            <TextBlock Text="{Binding Miscelanea.PDFVW_TTbtnSave, Source={StaticResource Recursos}}" />
                        </ToolTipService.ToolTip>
                        <Image Source="/Telerik.Windows.Controls.FixedDocumentViewers;component/Images/save.png" Stretch="None" />
                    </telerik:RadButton>

                    <telerik:RadButton Command="{Binding OpenPdfDocumentCommand}" HorizontalAlignment="Left" VerticalAlignment="Stretch" Margin="2" Padding="0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" IsBackgroundVisible="False">
                        <ToolTipService.ToolTip>
                            <TextBlock Text="{Binding Miscelanea.PDFVW_TTbtnOpen, Source={StaticResource Recursos}}" />
                        </ToolTipService.ToolTip>
                        <Image Source="/Telerik.Windows.Controls.FixedDocumentViewers;component/Images/open.png" Stretch="None" />
                    </telerik:RadButton>

                    <telerik:RadButton Command="{Binding PrintPdfDocumentCommand}" HorizontalAlignment="Left" VerticalAlignment="Stretch" Margin="2" Padding="0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" IsBackgroundVisible="False">
                        <ToolTipService.ToolTip>
                            <TextBlock Text="{Binding Miscelanea.PDFVW_TTbtnPrint, Source={StaticResource Recursos}}" />
                        </ToolTipService.ToolTip>
                        <Image Source="/Telerik.Windows.Controls.FixedDocumentViewers;component/Images/printer.png" Stretch="None" />
                    </telerik:RadButton>

                    <telerik:RadToolBarSeparator/>

                    <telerik:RadButton Command="{Binding PageUpCommand}"  HorizontalAlignment="Left" VerticalAlignment="Stretch" Margin="2" Padding="0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" IsBackgroundVisible="False">
                        <ToolTipService.ToolTip>
                            <TextBlock Text="{Binding Miscelanea.PDFVW_TTbtnPreviousPage, Source={StaticResource Recursos}}" />
                        </ToolTipService.ToolTip>
                        <Image Source="/Telerik.Windows.Controls.FixedDocumentViewers;component/Images/previous.png" Stretch="None" />
                    </telerik:RadButton>

                    <telerik:RadButton Command="{Binding PageDownCommand}" HorizontalAlignment="Left" VerticalAlignment="Stretch" Margin="2" Padding="0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" IsBackgroundVisible="False">
                        <ToolTipService.ToolTip>
                            <TextBlock Text="{Binding Miscelanea.PDFVW_TTbtnNextPage, Source={StaticResource Recursos}}" />
                        </ToolTipService.ToolTip>
                        <Image Source="/Telerik.Windows.Controls.FixedDocumentViewers;component/Images/next.png" Stretch="None" />
                    </telerik:RadButton>

                    <TextBox Width="30" Margin="2" Text="{Binding FixedDocumentViewer.CurrentPageNumber, Mode=TwoWay}" HorizontalContentAlignment="Center" x:Name="tbCurrentPage" KeyDown="tbCurrentPage_KeyDown"/>
                    <TextBlock VerticalAlignment="Center" Margin="2" Text="/" />
                    <TextBlock VerticalAlignment="Center" Margin="2" Text="{Binding ElementName=VisorPDF, Path=Document.Pages.Count}" />
                    <telerik:RadToolBarSeparator/>

                    <telerik:RadButton Command="{Binding ZoomInCommand}" HorizontalAlignment="Left" VerticalAlignment="Stretch" Margin="2" Padding="0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" IsBackgroundVisible="False">
                        <ToolTipService.ToolTip>
                            <TextBlock Text="{Binding Miscelanea.PDFVW_TTbtnZoomIn, Source={StaticResource Recursos}}" />
                        </ToolTipService.ToolTip>
                        <Image Source="/Telerik.Windows.Controls.FixedDocumentViewers;component/Images/zoom-in.png" Stretch="None" />
                    </telerik:RadButton>

                    <telerik:RadButton x:Name="PART_btnZoomOut" Command="{Binding ZoomOutCommand}" HorizontalAlignment="Left" VerticalAlignment="Stretch" Margin="2" Padding="0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" IsBackgroundVisible="False">
                        <ToolTipService.ToolTip>
                            <TextBlock Text="{Binding Miscelanea.PDFVW_TTbtnZoomOut, Source={StaticResource Recursos}}" />
                        </ToolTipService.ToolTip>
                        <Image Source="/Telerik.Windows.Controls.FixedDocumentViewers;component/Images/zoom-out.png" Stretch="None" />
                    </telerik:RadButton>

                    <telerik:RadComboBox IsEditable="True" Margin="2" MaxWidth="95" SelectedIndex="4" x:Name="cbScale"
                            Text="{Binding FixedDocumentViewer.ScaleFactor, Converter={StaticResource doubleToStringPercentConverter}, Mode=TwoWay}">
                        <telerik:RadComboBoxItem Content="10%" />
                        <telerik:RadComboBoxItem Content="25%" />
                        <telerik:RadComboBoxItem Content="50%" />
                        <telerik:RadComboBoxItem Content="75%" />
                        <telerik:RadComboBoxItem Content="100%" />
                        <telerik:RadComboBoxItem Content="150%" />
                        <telerik:RadComboBoxItem Content="200%" />
                        <telerik:RadComboBoxItem Content="500%" />
                        <telerik:RadComboBoxItem Content="1000%" />
                        <telerik:RadComboBoxItem Content="2000%" />
                    </telerik:RadComboBox>
                    <telerik:RadToolBarSeparator />

                    <telerik:RadToggleButton IsChecked="{Binding FixedDocumentViewer.Mode, Mode=TwoWay, Converter={StaticResource ModeConverter}, ConverterParameter=Pan}" Margin="2" Padding="0" IsBackgroundVisible="False" HorizontalAlignment="Left" VerticalAlignment="Stretch">
                        <ToolTipService.ToolTip>
                            <TextBlock Text="{Binding Miscelanea.PDFVW_TTbtnPan, Source={StaticResource Recursos}}" />
                        </ToolTipService.ToolTip>
                        <Image Source="/Telerik.Windows.Controls.FixedDocumentViewers;component/Images/hand-free.png" Stretch="None" />
                    </telerik:RadToggleButton>

                    <telerik:RadToggleButton IsChecked="{Binding FixedDocumentViewer.Mode, Mode=TwoWay, Converter={StaticResource ModeConverter}, ConverterParameter=TextSelection}" Margin="2" Padding="0" IsBackgroundVisible="False" HorizontalAlignment="Left" VerticalAlignment="Stretch">
                        <ToolTipService.ToolTip>
                            <TextBlock Text="{Binding Miscelanea.PDFVW_TTbtnTextSelection, Source={StaticResource Recursos}}" />
                        </ToolTipService.ToolTip>
                        <Image Source="/Telerik.Windows.Controls.FixedDocumentViewers;component/Images/text-selection.png" Stretch="None" />
                    </telerik:RadToggleButton>

                    <telerik:RadToolBarSeparator />
                    <telerik:RadWatermarkTextBox Margin="2" x:Name="tbFind" KeyDown="tbFind_KeyDown" Width="100">
                        <telerik:RadWatermarkTextBox.WatermarkContent>
                            <TextBlock Text="{Binding Miscelanea.PDFVW_TTbtnFind, Source={StaticResource Recursos}}" FontStyle="Normal" />
                        </telerik:RadWatermarkTextBox.WatermarkContent>
                    </telerik:RadWatermarkTextBox>

                    <telerik:RadButton x:Name="btnPrev" Visibility="Collapsed" Command="{Binding FindPreviousCommand}" CommandParameter="{Binding ElementName=tbFind, Path=Text}" Margin="2" Padding="0" IsBackgroundVisible="False" HorizontalAlignment="Left" VerticalAlignment="Stretch">
                        <ToolTipService.ToolTip>
                            <TextBlock Text="{Binding Miscelanea.PDFVW_TTbtnFindPrevious, Source={StaticResource Recursos}}" />
                        </ToolTipService.ToolTip>
                        <Image Source="/Telerik.Windows.Controls.FixedDocumentViewers;component/Images/find-previous.png" Stretch="None" />
                    </telerik:RadButton>

                    <telerik:RadButton x:Name="btnNext" Visibility="Collapsed" Command="{Binding FindCommand}" CommandParameter="{Binding ElementName=tbFind, Path=Text}" Margin="2" Padding="0" IsBackgroundVisible="False" HorizontalAlignment="Left" VerticalAlignment="Stretch">
                        <ToolTipService.ToolTip>
                            <TextBlock Text="{Binding Miscelanea.PDFVW_TTbtnFindNext, Source={StaticResource Recursos}}" />
                        </ToolTipService.ToolTip>
                        <Image Source="/Telerik.Windows.Controls.FixedDocumentViewers;component/Images/find-next.png" Stretch="None" />
                    </telerik:RadButton>
                </telerik:RadToolBar>

                <telerik:RadPdfViewer Grid.Row="1" Grid.Column="0" Name="VisorPDF">
                   
                </telerik:RadPdfViewer>

            </Grid>
        </telerik:RadBusyIndicator>
    </base:FormularioBase>

    using System;
    using System.Windows;
    using System.Windows.Controls;
    using System.ServiceModel.DomainServices.Client;

    using Telerik.Windows.Controls;
    using Telerik.Windows.Documents.Fixed;

    using ArcoDac;
    using ArcoControles_SL;

    using SIAR.Silverlight.Web;

     

    namespace SIAR.Silverlight.Formularios
    {
        public partial class FORMPDFVIEWER : FormularioBase
        {

            #region --- Constructor por defecto y metodos auxiliares

            public FORMPDFVIEWER(RadBusyIndicator busyIndicator, string codigoCargaInicial, bool soloLectura, string moduloFormulario, string [] parametros )
            {
                InitializeComponent();
                busyIndicator.IsBusy = false;           
                this.FormBusyIndicator.IsBusy = false;

                Inicializar_BusyIndicator();

                if (parametros.Length == 1)
                {
                    string fichero = parametros[0];               
                    GenerarPDF(fichero);
                }
            }
           
            /// <summary>
            /// Preparar "BusyIndicatorPrincipal" para que al cerrarse vuelva a
            /// enfocar al control que lo abrio.
            /// </summary>
            private void Inicializar_BusyIndicator()
            {
                System.Windows.Data.Binding backBusy = new System.Windows.Data.Binding();
                backBusy.Source = this.FormBusyIndicator;
                backBusy.Path = new PropertyPath("IsBusyIndicationVisible");
                backBusy.Mode = System.Windows.Data.BindingMode.OneWay;
            }

          
            private void GenerarPDF(string fichero)
            {
                SIARDomainContext dc = new SIARDomainContext();
                dc.LectorPDF(DatosSesion.ASID, fichero,
                    delegate(InvokeOperation<byte[]> invOp)
                    {
                        if (invOp.HasError)
                        {
                            invOp.MarkErrorAsHandled();
                            string mensaje;
                            if (invOp.Error.Message.Contains("ARCOERROR"))
                                mensaje = invOp.Error.Message + ", GenerarPDF";
                            else
                                mensaje = ArcoError.Get("QV_UNHANDLED_EXCEPTION", "", invOp.Error.Message, DatosSesion.Repositorio.DataAccount, fichero, "", "", "", "GenerarPDF");
                            ArcoErroresManager.ObtenerErrorFormateado(mensaje);
                            ArcoSLMessageBox.Alert(mensaje);
                        }
                        else
                        {
                            try
                            {
                                this.DocumentoPdf = invOp.Value;
                                System.IO.Stream stream = new System.IO.MemoryStream(this.DocumentoPdf);
                                this.VisorPDF.DocumentSource = new PdfDocumentSource(stream);
                            }
                            catch (Exception ex)
                            {
                                string mensaje = ArcoError.Get("QV_UNHANDLED_EXCEPTION", "", ex.Message, DatosSesion.Repositorio.DataAccount, fichero, "", "", "", "GenerarPDF");
                                ArcoErroresManager.ObtenerErrorFormateado(mensaje);
                                ArcoSLMessageBox.Alert(mensaje);
                            }
                        }
                    }, null);
            }

            #endregion

            private void tbCurrentPage_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
            {
                TextBox textBox = sender as TextBox;
                if (textBox != null)
                {
                    if (e.Key == System.Windows.Input.Key.Enter)
                    {
                        textBox.GetBindingExpression(TextBox.TextProperty).UpdateSource();
                    }
                }
            }

            private void tbFind_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
            {
                if (e.Key == System.Windows.Input.Key.Enter)
                {
                    this.VisorPDF.Commands.FindCommand.Execute(this.tbFind.Text);
                    this.btnPrev.Visibility = System.Windows.Visibility.Visible;
                    this.btnNext.Visibility = System.Windows.Visibility.Visible;
                }
            }

            #region --- Boton Guardar

            private SaveFileDialog saveFileDialog;

            private byte[] _DocumentoPdf;
            public byte[] DocumentoPdf
            {
                get { return _DocumentoPdf;  }
                set { _DocumentoPdf = value; }
            }

            private void InitializeSaveDialog()
            {
                saveFileDialog = new SaveFileDialog();
                saveFileDialog.DefaultExt = "pdf";
                saveFileDialog.Filter = "pdf Files (*.pdf)|*.pdf|All files (*.*)|*.*";
                saveFileDialog.FilterIndex = 1;

            }

            private void Save_Click(object sender, System.Windows.RoutedEventArgs e)
            {
                InitializeSaveDialog();
                if (saveFileDialog.ShowDialog() == true)
                {
                    using (System.IO.Stream fs = (System.IO.Stream)this.saveFileDialog.OpenFile())
                    {
                        fs.Write(DocumentoPdf, 0, DocumentoPdf.Length);
                        fs.Close();
                    }
                }
            }

            #endregion
        }
    }


  8. Petya
    Admin
    Petya avatar
    975 posts

    Posted 25 Mar 2013 Link to this post

    Hi Angel,

    I am unable to find anything unusual in your code and successfully ran it after removing the missing resources.

    Generally, the issue I was talking about is related to UI Culture and I can't really advise how to verify this is what you are facing. However, as I said, the problem was already resolved and the LIB will be uploaded tomorrow. I suggest you download it test the behavior of your application.

    Let us know how it goes.

    Regards,
    Petya
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  9. Angel
    Angel avatar
    8 posts
    Member since:
    Apr 2011

    Posted 25 Mar 2013 Link to this post

    Thank you for check my code. Our default culture is es-ES. Only to check the UI culture, I've forced the culture in my form, with the below code, and result is same. 
                System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en");
                System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en");

    I'll wait tomorrow and inform you with good news, I hope.
    Angel
  10. Angel
    Angel avatar
    8 posts
    Member since:
    Apr 2011

    Posted 26 Mar 2013 Link to this post

    Hy Petya
    The upgrade with new patch to solve problems with RadPdfViewer was ok.
    Thank you so much
    Angel
  11. Joemerick
    Joemerick avatar
    1 posts
    Member since:
    Apr 2013

    Posted 25 Apr 2013 Link to this post

    Hi, we are using 2012.1.326.1050 version. And as of last week I am encountering the white pdf issue. The pdf is displayed last month, but since Monday, the pdf viewer is just display white pages.

    Thanks
  12. Petya
    Admin
    Petya avatar
    975 posts

    Posted 29 Apr 2013 Link to this post

    Hello Joemerick,

    I am afraid I do not quite understand you.

    When you say that the PDF was displayed previously, are you referring to one and the same file? If so, have you upgraded the RadControls for SIlverlight version in your project? If you haven't upgraded and the PDF file is the same, this seems rather strange and is most likely caused by a change in your application logic.

    Please note that we constantly try to improve the control and new features are released with each new version. The version of RadPdfViewer you are currently using was one of the first ones and the PDF support has drastically improved since then. That said, we usually recommend upgrading to our most recent release to take advantage of all improvements.

    In case you are still facing issues with a particular file or setup I recommend opening a support ticket and sending us the respective PDF file/project along with detailed explanation, so that we can further investigate.

    I am looking forward to your reply.

    Regards,
    Petya
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top
DevCraft banner