3

I try to render RDLC report to PDF file and the size of the file generated is larger than normal. After some research i found the PDF generated have embedded font: ..... 9 0 obj << /Filter /FlateDecode /Length 52986 /Length1 194264 >> stream .....

When i generate PDFs and save to disk with the same method and the same code one PDF have the size: 6.82 KB and other 109 KB.

The PDFs is identically if i open with Adobe Acrobat.

Solution 1:

I generate the PDF in MVC 4 application with "Microsoft.ReportViewer.WebForms" version 11. I try to use "Microsoft.ReportViewer.WinForms" library in the same MVC application to see if the size decreases but no result.

Failed

Solutin 2:

I search in RDLC file with notepad if exist something about fonts but not exist, only font size, if is bold but not some name.

Failed

The small PDF font property: Small PDF

The large PDF font property: enter image description here

My question is: How to not embed default font in PDF rendered from RDLC?

TotPeRo
  • 6,561
  • 4
  • 47
  • 60

3 Answers3

5

It turns out we merely needed to add a key to the DeviceInfo.xml:

<DeviceInfo>
<EmbedFonts>None</EmbedFonts>
</DeviceInfo>

I found the answer here.

m.edmondson
  • 30,382
  • 27
  • 123
  • 206
  • yes absolutely. this should be the accepted answer. For `ReportViewer.WebForms`, this can also be done from code by passing the whole DeviceInfo xml tag as a string as the `deviceInfo` parameter to the `Render` function. Successfully tested with an rdlc that consisted of nothing but a label in Calibri Light, with embedding 155 KB, without embedding 5 KB. – Cee McSharpface Apr 25 '17 at 14:39
0

According to How to embed a Font in a PDF with RDLC you must meet these requirements:

  • Font must be marked as embedding allowed
  • Font must be of type TrueType

This is similar to the MSDN documentation on font embedding when exporting to a PDF File from Report Builder and SSRS:

  • Font embedding privileges are granted by the font author. Installed fonts include a property that indicates whether the font author
    intends to allow embedding a font in a document. If the property
    value is EMBED_NOEMBEDDING, the font is not embedded in the PDF file. For more information, see "TTGetEmbeddingType" on msdn.microsoft.com.
  • The Font is TrueType.
  • Fonts are referenced by visible items in a report. If a font is referenced by an item that has the Hidden property set to True, the
    font is not needed to display rendered data and will not be included
    in the file. Fonts are embedded only when they are needed to display
    the rendered report data.

So if you do not meet these requirements, your font should not be embedded.

Community
  • 1
  • 1
0

You really shouldn't use Microsoft.ReportViewer.WebForms in ASP.NET MVC. Rather just call your report server and get the report needed.

public async Task<FileStreamResult> GenerateReport()
{

    CredentialCache credentialCache = new CredentialCache();
    credentialCache.Add(new Uri("http://domainORipaddress"), "NTLM", new NetworkCredential(
        ConfigurationManager.AppSettings["username"],
        ConfigurationManager.AppSettings["password"]
    ));

    Stream report = null;
    using (var httpClient = new HttpClient(new HttpClientHandler { Credentials = credentialCache }))
    { 
        //put the desired timeout here if needed to cancel the task
        httpClient.Timeout = TimeSpan.FromMilliseconds(Timeout.Infinite);
        report = await httpClient.GetStreamAsync("reportUrl");
    }

    Response.AppendHeader("Content-Disposition", String.Format("attachment;filename=\"{0}\"", reportName));
    return File(reportPath, MediaTypeNames.Application.Pdf);
}

Reference: SQL Server Reporting Service with ASP.NET MVC

Font embedding was introduced:

SQL Server 2008 Cumulative Update 1 (full font embedding and subsetting for Unicode characters)

SQL Server 2005 Service Pack 3 (limited to non ANSI characters)

Reference: Do You Unicode in PDF?

Font embedding does no longer matter what version of a font is installed on a client - the documents can be viewed the same way regardless of client operating systems, font versions, and client PDF viewer.

So when you disable fonts embedding you are basically reverting back to the old behavior.

How do disable:

  1. Open the RSreportserver.config file under the path: RS Installation Folder\Reporting Services\ReportServer

Reference: Modify a Reporting Services Configuration File (RSreportserver.config)

  1. Find the following

        <Extension Name="PDF" Type="    
        Microsoft.ReportingServices.Rendering.ImageRenderer.PdfReport,
        Microsoft.ReportingServices.ImageRendering"/>
    
  2. Add the following

     <Configuration>
       <DeviceInfo>
          <EmbedFonts>None</EmbedFonts>
       </DeviceInfo>
      </Configuration>
    
  3. You would need to do an IISReset (IISReset stops and restarts the entire web server (including non-ASP.NET apps) to set the changes.

Reference: How to disable this Font embedding in Reporting Services 2005 Service Pack 3?

Matija Grcic
  • 12,963
  • 6
  • 62
  • 90
  • i use Microsoft.ReportViewer.WebForms because i use the same code in winform application and i get the same result on generate pdf. – TotPeRo Jun 30 '14 at 06:55