Gabbar
Gabbar

Reputation: 4066

ABCPDF not rendering links

I am using the AddImageUrl function of the ABCPDF library and getting the pages to render fine as PDFs. But I am having a problem where the links (a tags) are not getting rendered in the PDF links but rather as normal text without the link functionality. I have checked the HTML page to make sure that the links exist on the page.

Upvotes: 4

Views: 2720

Answers (2)

ashish
ashish

Reputation: 25

We are using ABCPDF.Net version 6 to create a PDF file from HTML. However, the links are not live except for those that appear as URLs in the HTML even when HtmlOptions.AddLinks is set to true. In fact, when it's set to true, the links render with a brown background not present when it's set to false. Here is the code we use to create the PDF using vb.net

     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

Upvotes: -1

Gabbar
Gabbar

Reputation: 4066

I figured this out. Hopefully, this will help someone else who has this problem. You need to include the following lines before generating the pdf to make the links active.

theDoc.HtmlOptions.AddLinks = true;

Upvotes: 10

Related Questions