ABCPDF不呈现链接

时间:2011-12-27 02:42:06

标签: hyperlink abcpdf

我正在使用ABCPDF库的AddImageUrl函数,并使页面呈现为PDF格式。但是我遇到的问题是链接(标签)没有在PDF链接中呈现,而是作为没有链接功能的普通文本。我检查了HTML页面以确保页面上存在链接。

2 个答案:

答案 0 :(得分:9)

我想出来了。希望这可以帮助有这个问题的其他人。在生成pdf之前,您需要包含以下行以使链接处于活动状态。

theDoc.HtmlOptions.AddLinks = true;

答案 1 :(得分:-1)

我们正在使用ABCPDF.Net版本6从HTML创建PDF文件。但是,即使HtmlOptions.AddLinks设置为true,链接也不会显示,除非那些链接在HTML中显示为URL。实际上,当它设置为true时,链接呈现为棕色背景,当它设置为false时不存在。以下是我们使用vb.net

创建PDF的代码
     Dim theID As Object
        Dim pageRect As String
        Dim Header As String = Nothing
        If SubBank.Length <> 0 Then
            If HttpContext.Current.Session("BankType") IsNot Nothing And (HttpContext.Current.Session("BankType") = 1 Or HttpContext.Current.Session("BankType") = 4) Then
                Header = "<br/><br/> <br/><br/><div class='bankname1' align='center'>" & SubBank & " </div><div style='float:right'><img src='" & getBaseUrl() & "/Images_Modern/SGPSMainLogo.png' /> </div>"
            Else
                Header = "<br/><br/> <br/><br/><div class='bankname1' align='center'>" & SubBank & " </div><div style='float:right'><img src='" & getBaseUrl() & "/Images_Modern/bankers_gps_logo_pdf.gif' /> </div>"
            End If

            If PeerGroup.Length <> 0 AndAlso HttpContext.Current.Session("Product_Id") = 1 Then
                Header &= "<div class='bankname2' align='center'>Vs&nbsp;&nbsp;&nbsp;" & PeerGroup & " </div>"
            End If
            strContent = Header & strContent
        End If

        Dim objAbc As New WebSupergoo.ABCpdf6.Doc
        objAbc.Rect.Inset(15, 15)
        CreateErrorText(Header)
        Dim ObjSet As New PDFSettings
        ObjSet.objAbc = objAbc
        ObjSet.OriWidth = objAbc.MediaBox.Width
        ObjSet.OriHeight = objAbc.MediaBox.Height

        objAbc.HtmlOptions.AddLinks = True
        objAbc.HtmlOptions.TargetLinks = True

        'objAbc.HtmlOptions.MaxAtomicImageSize = 100
        'objAbc.HtmlOptions.ImageQuality = 101
        ObjSet.Rotate(Orientation)
        'theID = objAbc.AddImageHtml(strContent, True, 0, False)
        'objAbc.SetInfo(theID, "/Rotate", "90")
        theID = objAbc.AddImageHtml(strContent)

        objAbc.Rendering.DotsPerInch = 96S
        pageRect = objAbc.Rect.String

        Do
            'theDoc.FrameRect
            If Not objAbc.Chainable(theID) Then Exit Do
            objAbc.Page = objAbc.AddPage()
            theID = objAbc.AddImageToChain(theID)

        Loop

        Dim i
        For i = 1 To objAbc.PageCount
            objAbc.PageNumber = i
            objAbc.Flatten()
        Next
        'added By yuvraj For NS Headder :17/04/2012
        If (strContent.IndexOf("NSHEADSTART") > -1) Then
            objAbc.HPos = 0.5
            objAbc.VPos = 0.5
            '  objAbc.Color.String = "0 255 0"
            objAbc.FontSize = 16
            For i = 1 To objAbc.PageCount
                objAbc.PageNumber = i
                objAbc.Rect.Pin = 0
                objAbc.Rect.String = "20 20 400 400"
                objAbc.HPos = 0.5
                objAbc.AddHtml(getHeadText(strContent))
                objAbc.Rect.Move(200, 500)
                objAbc.Rect.String = pageRect
                objAbc.HPos = 0
            Next

        End If
        'theDoc.Rect.Move  0, -50
        objAbc.HPos = 0
        objAbc.Save(PDFPath)
        objAbc.Clear()
        'Response.Redirect(".\PDF\manoj12.pdf")
        objAbc = Nothing
        theID = Nothinge