我们正在使用 ABCPDF.Net 版本 5 从 HTML 创建 PDF 文件。但是,除了那些在 HTML 中显示为 URL 的链接之外,即使 HtmlOptions.AddLinks 设置为 true,这些链接也不会生效。事实上,当它设置为 true 时,链接呈现的棕色背景在设置为 false 时不存在。这是我们用来创建 PDF (vb.net) 的代码:
Dim oFile As Stream = New MemoryStream()
Dim objPDFInvoice As Doc = New Doc
With objPDFInvoice
Dim w As Double = .MediaBox.Width
Dim h As Double = .MediaBox.Height
Dim l As Double = .MediaBox.Left
Dim b As Double = .MediaBox.Bottom
.Rect.Left += 15
.Rect.Bottom += 15
.Rect.Width -= 15
.Rect.Height -= 15
.HtmlOptions.AddLinks = True
Dim theID As Integer = .AddImageUrl("file://" & sFileName, True, 800, True)
While True
If Not .Chainable(theID) Then
Exit While
End If
.Page = .AddPage()
theID = .AddImageToChain(theID)
End While
For iPage As Integer = 1 To .PageCount
.PageNumber = iPage
.Flatten()
Next
If .PageCount > 0 Then .Page = 1
.SetInfo(.Root, "/HtmlContent:Text", sBody.ToString)
.SetInfo(.Root, "/HtmlFilename:Text", "Certification" & ".pdf")
.Encryption.Type = 2
.Encryption.CanAssemble = False
.Encryption.CanChange = False
.Encryption.CanCopy = False
.Encryption.CanEdit = False
End With
objPDFInvoice.Save(oFile)
objPDFInvoice.Clear()
然后将 oFile 内存流作为电子邮件附件发送,但为了进行测试,我将其保存到文件中。请注意,sBody 是 AddImageURL 中使用的 HTML 文件内容的字符串表示形式。
知道为什么会这样吗?
提前致谢, 鲍里斯·扎哈林