PDF File Size

10 posts, 0 answers
  1. imaginarylight
    imaginarylight avatar
    13 posts
    Member since:
    Jun 2006

    Posted 23 Jan 2008 Link to this post

    Hi,

    I am using the script I found in another thread to export my reports directly to PDF. It is simple and works great. However, the size of the resulting PDFs seems too large. A single letter size page with one small logo and just text exports to 1.6 MB. If there a setting or something I can play with to help render these to a smaller file size?

    Thanks

    John

    PS - I tried the same report without the logo and it only reduced the size by 0.1 MB.
  2. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 23 Jan 2008 Link to this post

    Hello imaginarylight,

    Thank you for contacting Telerik Support.

    The large size of your PDF file is most probably such because fonts are embedded in the file.

    With Q3 2007 SP1 we introduced a configuration parameter for the PDF Rendering Extension called FontEmbedding. You can select whether to embed all fonts entirely (Full), embed only the used subsets (Subset) or do not embed fonts at all (None).

    To learn how to configure you export to PDF with the settings that you want, please read carefully the following help topics:

    Configuring Telerik Reporting
    Device Information Settings

    Note: In those topics, in places where version 2.0.0.0 is mentioned, you should put 2.0.1.0 if you are using the Service Pack.

    If you have any problems configuring Telerik Reporting, do not hesitate to drop us a line.

    All the best,
    Ross
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. DevCraft banner
  4. imaginarylight
    imaginarylight avatar
    13 posts
    Member since:
    Jun 2006

    Posted 23 Jan 2008 Link to this post

    Hi Again,

    Here is the code I am using;

    Sub

    ExportToPDF(ByVal reportName As String, ByVal reportToExport As Telerik.Reporting.Report)

    Dim mimeType As String = String.Empty
    Dim ext As String = String.Empty
    Dim encoding As Encoding = Encoding.[Default]
    Dim reportBytes As Byte() = ReportProcessor.Render("PDF", reportToExport, Nothing, mimeType, ext, encoding)
    Dim fileName As String = reportName + ".pdf"

    Response.Clear()
    Response.ContentType = mimeType
    Response.Cache.SetCacheability(HttpCacheability.[Private])
    Response.Expires = -1
    Response.Buffer =

    False
    Response.AddHeader("Content-Disposition", String.Format("{0};FileName=""{1}""", "attachment", fileName))
    Response.OutputStream.Write(reportBytes, 0, reportBytes.Length)
    Response.[End]()

    End Sub

    Where would I use the parameter you are talking about?

    John

  5. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 23 Jan 2008 Link to this post

    Hello imaginarylight,

    Instead of passing Nothing for the deviceInfo parameter of ReportProcessor.Render, you should create a new Hashtable and set the key "FontEmbedding" to "Subset' or "None".

    ...
    Dim
    deviceInfo As Hashtable = new Hashtable()
    deviceInfo("FontEmbedding") = "Subset"
    Dim reportBytes As Byte() = ReportProcessor.Render("PDF", reportToExport, deviceInfo, mimeType, ext, encoding)
    ...

    Best wishes,
    Ross
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  6. rh
    rh avatar
    193 posts
    Member since:
    Jan 2007

    Posted 17 Feb 2008 Link to this post

    This FontEmbedding setting doesn't help with file size. In fact, it seems to have the opposite effect. When setting it to Subset when compared to leaving deviceInfo null the file size actually increased. When setting it to None as compared to Subset the file size stayed the same.
  7. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 18 Feb 2008 Link to this post

    Hello rh,

    The behavior that you are describing is very strange. Can we have the report that causes it. We would like to debug the PDF generation and locate the cause for this behavior.

    Sincerely yours,
    Ross
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  8. Rahul Khinvasara
    Rahul Khinvasara avatar
    303 posts
    Member since:
    Aug 2007

    Posted 17 Oct 2008 Link to this post

    Hi Ross
                I have also used same code for generating PDF, I don't want to show PDF directly to User it will be sent through E-mail to the User. Can it's possible??

    Thanks 
  9. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 17 Oct 2008 Link to this post

    Hi Rahul,

    We've already answered your question in the other forum thread you've opened. Please restrain from opening multiple threads with the same content as this only slows us down. A solution for emailing the report is available in this code library.

    Best wishes,
    Steve
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  10. Vincenzo
    Vincenzo avatar
    1 posts
    Member since:
    Jan 2009

    Posted 12 Jan 2009 Link to this post

    I'd like the C# version for the referenced code below for the FontEmbedding parameter please:

    Dim deviceInfo As Hashtable = new Hashtable()
    deviceInfo("FontEmbedding") = "Subset"
    Dim reportBytes As Byte() = ReportProcessor.Render("PDF", reportToExport, deviceInfo, mimeType, ext, encoding)

    Thanks,
    Vince



  11. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 13 Jan 2009 Link to this post

    Hello Vincenzo,

    You can use our code converter when you need to convert code - it is available here. Here is the C# version of the code you've requested:

           Hashtable deviceInfo = new Hashtable();
           deviceInfo["FontEmbedding"] = "Subset";
           byte[] reportBytes = ReportProcessor.Render("PDF", reportToExport, deviceInfo, mimeType, ext, encoding);

    Best wishes,
    Steve
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top
DevCraft banner