gpt4 book ai didi

pdf - 如何在解决方案中嵌入字体以用于带有 RDLC 的 PDF

转载 作者:行者123 更新时间:2023-12-03 02:05:50 24 4
gpt4 key购买 nike

我有一个通过 Webforms.LocalReport 创建的 RDLC 报告,它使用了我在开发计算机上安装的一些自定义字体。这效果很好,并将字体嵌入到 PDF 中,这样其他人就不需要安装字体来查看。

我的问题是,当部署到我们的生产环境时,有许多机器可能会运行该报告。我不想在每台“潜在”机器上安装字体 - 有没有办法将(.TTF)字体文件附加到(VB.NET)解决方案,并从这里提取字体,而不是从本地机器?

希望这是有道理的!!

如果有帮助,下面是我正在使用的代码示例

    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

提前致谢!

最佳答案

首先确保您使用的字体允许嵌入。在您的情况下,您可以通过您的开发机器从"file">“属性”>“字体”选项卡生成的 PDF 文件来验证它。字体嵌入权限由字体作者授予。安装的字体包括一个属性,该属性指示字体作者是否打算允许在文档中嵌入字体。如果属性值为 EMBED_NOEMBEDDING,则字体不会嵌入到 PDF 文件中。有关详细信息,请参阅 msdn.microsoft.com 上的“TTGetEmbeddingType”。

其次,确保您的网络托管服务器上安装了该字体。

如果是这样,则报表查看器 PDF 解析器会自动将该字体嵌入到生成的每个 PDF 中,并且无需将该字体分发给每个用户。

关于pdf - 如何在解决方案中嵌入字体以用于带有 RDLC 的 PDF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19237725/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com