我正在使用Spire.pdf动态链接库静默地打印html页面,它在我的机器上工作得很好,但在客户机上给出了下面的错误。
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.msht
ml, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one
of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.mshtml, Version=7.0.3300.0, Culture=neutral, PublicKeyToke
n=b03f5f7f11d50a3a'
at Spire.Pdf.HtmlConverter.HtmlConverter.?(String A_0, ImageType A_1, Int32 A
_2)
at Spire.Pdf.HtmlConverter.HtmlConverter.Convert(String url, ImageType type,
Int32 width, Int32 height, AspectRatio aspectRatio)
at Spire.Pdf.PdfSection.?(String A_0, Boolean A_1, Boolean A_2, Boolean A_3,
PdfHtmlLayoutFormat A_4)
at Spire.Pdf.PdfDocument.LoadFromHTML(String htmlSourceCode, Boolean autoDete
ctPageBreak, PdfPageSettings setting, PdfHtmlLayoutFormat layoutFormat, Boolean
isLoadComplete)
at Spire.Pdf.PdfDocument.LoadFromHTML(String htmlSourceCode, Boolean autoDete
ctPageBreak, PdfPageSettings setting, PdfHtmlLayoutFormat layoutFormat)
at SP.Module1.Main() in D:\Nikhil\Project\PrintDocument\SP\Module1.vb:line 96
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\M
icrosoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure lo
gging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fus
ion!EnableLog].我看了下面的页面,尝试通过添加引用和将dll复制到可执行文件所在的本地文件夹来引用mshtml.dll,可能是我不完全了解如何使用它。
Could not load file or assembly 'Microsoft.mshtml ... Strong name validation failed
如果有人能告诉我如何在客户机上安装dll,下面是我正在使用代码
Dim doc As New PdfDocument()
Dim pgSt As New PdfPageSettings()
pgSt.Size = PdfPageSize.A4
pgSt.SetMargins(0.5, 0.5, 0.5, 0.5)
Dim htmlLayoutFormat As New PdfHtmlLayoutFormat()
htmlLayoutFormat.IsWaiting = False
' Dim htmlpath As String = "D:\Print-code\test3.html"
Dim source As String = response.Content ' File.ReadAllText(htmlpath)
doc.LoadFromHTML(source, True, pgSt, htmlLayoutFormat)
doc.PrintSettings.PrintController = New StandardPrintController()
doc.PrintSettings.PrinterName = printer
'doc.PrintSettings.Copies = 2
'Print all pages with default printer
doc.Print()发布于 2019-10-25 15:27:24
查看设置为生成目标x86或x64的项目,然后使用相同的Microsoft.mshtml.dll内部版本添加引用
如何了解您的项目设置生成目标右键单击项目->选择属性->选择选项卡build ->查看平台目标
发布于 2019-10-25 15:49:11
从html转换为pdf时,Spire.pdf组件依赖于Microsoft Internet Explorer。因此,IE必须安装在客户端的计算机上。下面是Spire.pdf支持论坛的链接。你可以在那里找到更多信息。
https://stackoverflow.com/questions/58553940
复制相似问题