PDFViewer Text Rendering

5 posts, 0 answers
  1. Oliver
    Oliver avatar
    5 posts
    Member since:
    Jul 2011

    Posted 31 May 2012 Link to this post

    Hi,

    I have been using the sharppdf-sl library to generate pdf documents on the fly. But when I try and display these documents in the telerik pdfviewer none of the text appears. I have also tried loading the pdf document in the telerik demo with the same outcome. If I save the document and open with Adobe Reader the pdf file look fine and the text appears.
    I have looked at the other threads first and made sure I have all the relevant dlls referenced in my project in case this was the cause of the missing text.

    I have attached a sample pdf to the thread to demonstrate my point here

    Any ideas?

    Thanks in advance

    Mark
  2. Kammen
    Admin
    Kammen avatar
    312 posts

    Posted 04 Jun 2012 Link to this post

    Hello Mark,

    Thank you for contacting us about this issue.

    We have found that this problem is caused by a bug in our ASCIIHexDecode. We will need more time to investigate this issue and try to solve it. 

    Greetings,
    Kammen
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
  4. Oliver
    Oliver avatar
    5 posts
    Member since:
    Jul 2011

    Posted 06 Jun 2012 Link to this post

    Hi Kammen,

    Thank you for the quick response. Do you know of a possible workaround while the issue is under investigation or is there the possibility of investigating the issue myself in the source code if it is a problem that is likely to take a while to investigate?

    Thanks again
    Mark
  5. Kammen
    Admin
    Kammen avatar
    312 posts

    Posted 07 Jun 2012 Link to this post

    Hello Mark,

    As this problem is connected to one of the PDF filters, there is no workaround. You can investigate (fix) this issue by yourself by creating a custom ASCIIHexDecode filter and using it instead of the existing one. To do this you will need to implement the IPdfFilter interface and register the new class by calling FiltersManager.RegisterFilter () method. RadPdfViewer uses the the Name property in order to recognize the filter so it should return the "ASCIIHexDecode" string.

    If you have further questions do not hesitate to contact us.

    Greetings,

    Kammen
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  6. Oliver
    Oliver avatar
    5 posts
    Member since:
    Jul 2011

    Posted 07 Jun 2012 Link to this post

    Hi Kammen,

    Thanks for your reply, I have a workaround using the IPdfFilter as follows (using utf8 as a string to byte[] encoder). It appears looking at the telerik source that there are a few indexing issues reading in the initial bytes from the stream. I am not saying this is the solution to the problem but is a workaround for simple text;

     

    public class ASCIIHexDecodeFilter : IPdfFilter

    {

     

    public byte[] Decode(System.IO.Stream stream, DecodeParameters parms)

    {

     

    StreamReader sr = new StreamReader(stream);

     

     

    string s = sr.ReadToEnd();

     

    //Need to remove invalid stream character from end of ASCIIHex

     

    string ascii = HexString2Ascii(s.Trim('>'));

     

    byte[] bb = UTF8Encoding.UTF8.GetBytes(ascii);

     

    return bb;

    }

     

    /// <summary>

     

    /// Not needed

     

    /// </summary>

     

    /// <param name="data"></param>

     

    /// <returns></returns>

     

    public byte[] Encode(byte[] data)

    {

     

    return null;

    }

     

    public string Name

    {

     

    get { return "ASCIIHexDecode"; }

    }

     

    public static string HexString2Ascii(string hexString)

    {

     

    StringBuilder sb = new StringBuilder();

     

    for (int i = 0; i <= hexString.Length - 2; i += 2)

    {

    sb.Append(

     

    Convert.ToString(Convert.ToChar(Int32.Parse(hexString.Substring(i, 2), System.Globalization.NumberStyles.HexNumber))));

    }

     

    return sb.ToString();

    }

    }

Back to Top
DevCraft banner