4

I have an RDLC report created via Webforms.LocalReport that uses a few custom fonts that I have installed on my dev machine. This works well, and embeds the fonts in the PDF so that others don't need the font installed to view.

My problem is, when deploying to our production environment, there are a number of machines that may run the report. I don't want to have to install the font on each 'potential' machine - is there a way to attach the (.TTF) font file to the (VB.NET) solution, and have the font pulled from here, rather than from the local machine?

Hope this makes sense!!

If it helps, below is a sample of the code I'm using

    Dim PDFfile As FileInfo
    Dim deviceInfo As String = String.Empty
    Dim PDF() As Byte
    Dim reportParams As List(Of ReportParameter)

    Using report As New LocalReport

        ' Set up report
        ' Report device information to create PDF with A4 sized pages
        deviceInfo = "<DeviceInfo>" & _
                     "  <OutputFormat>EMF</OutputFormat>" & _
                     "  <Orientation>Portrait</Orientation>" & _
                     "  <PageWidth>21cm</PageWidth>" & _
                     "  <PageHeight>29.7cm</PageHeight>" & _
                     "  <MarginTop>0cm</MarginTop>" & _
                     "  <MarginLeft>0cm</MarginLeft>" & _
                     "  <MarginRight>0cm</MarginRight>" & _
                     "  <MarginBottom>0cm</MarginBottom>" & _
                     "</DeviceInfo>"
        With report
            .DisplayName = "Display Name"
            report.ReportEmbeddedResource = "ReportName.rdlc"

            ' Add all necessary parameters
            reportParams = New List(Of ReportParameter)
            reportParams.Add(...)

            .SetParameters(reportParams)
        End With

        PDF = report.Render("PDF", deviceInfo)
        PDFfile = New FileInfo("C:\")

        Using stream As FileStream = PDFfile.Create
            stream.Write(PDF, 0, PDF.Length)
        End Using
    End Using

Thanks in advance!

brad
  • 105
  • 1
  • 9

1 Answers1

0

First of all make sure that the font you are using allows embedding. In your case you can verify it from the PDF file generated by your dev machine from File>Properties>Fonts tab. 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.

Secondly make sure that the font is installed on your web hosting server.

If so then the report viewer PDF parser then automatically embeds the font to every PDF generated and there is no need for the font to be distributed to each user.

  • Thanks @Syed - unfortunately (actually, gladly!) I no longer work for the company this was for... But I'm pretty sure the font allows embedding. Also, it was a desktop app, so there was no web server to install on. I was hoping that it could be packaged into the app's exe (this may not have been clear...) – brad Dec 09 '14 at 03:11