You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

ABCPDF v12添加PDF信头后第二页无法渲染问题求助

ABCPDF v12 合并PDF时第二页(theDoc1)无法显示问题

我们需要将4个HTML页面合并为单个PDF文件,第一页读取空白PDF(信头)作为背景,再添加剩余3页。该功能在ABCPDF v8中运行正常,但升级至v12后,第二页(对应代码中的theDoc1对象)无法显示。目前theDoc加载信头及HTML内容正常,theDoc1a、theDoc2也可正常加载;若移除theDoc中的信头添加逻辑,4页均可正常显示。

附上使用的VB脚本代码:

Sub page_load()
    Dim rs
    Dim strSQLQuery As String
    Dim theDoc As Doc = New Doc()
    Dim theDoc1 As Doc = New Doc()
    Dim theDoc1a As Doc = New Doc()
    Dim theDoc2 As Doc = New Doc()  

    Dim theDoccontents As Doc = New Doc()
    theDoc.MediaBox.String = "A4"
    theDoc1.MediaBox.String = "A4"
    theDoc1a.MediaBox.String = "A4"
    theDoc2.MediaBox.String = "A4"
   
    theDoc.HtmlOptions.PageCacheEnabled = False
    theDoc.HtmlOptions.PageCacheClear()

    theDoc.HtmlOptions.ImageQuality = 33
    theDoc1.HtmlOptions.ImageQuality = 33
    theDoc1a.HtmlOptions.ImageQuality = 33
    theDoc2.HtmlOptions.ImageQuality = 33
   
    theDoc.HtmlOptions.AddLinks = True
    theDoc1.HtmlOptions.AddLinks = True
    theDoc1a.HtmlOptions.AddLinks = True
    theDoc2.HtmlOptions.AddLinks = True
   
    theDoc.HtmlOptions.Timeout = 10000000
    theDoc1.HtmlOptions.Timeout = 10000000
    theDoc1a.HtmlOptions.Timeout = 10000000
    theDoc2.HtmlOptions.Timeout = 10000000
   
   
    Dim rbrandchosen As String
    Dim quotenumber As String
    Dim rnum As String
    Dim cover as string
    dim pagex as integer
    quotenumber=request("quotenumber")
    rbrandchosen=request("rbrandchosen")
    response.write(quotenumber)
    Dim theURL As String
    Dim theID As Integer
    Dim strsql as string
    Dim theSection as string
    Dim theCountDoc1a As Integer

    Randomize()
    rnum = (CInt(Math.Floor(90 * Rnd())) + 10).ToString
     

        ' add covering letter
       
        cover = "c:\inetpub\wwwroot\icopalukintranet\pnf\letterhead.pdf"
   
            theDoc.Read(cover)

            'theID = theDoc.AddObject("<< >>")


           
            theDoc.HtmlOptions.UseScript = True
            theDoc.HtmlOptions.Engine = EngineType.Chrome86
            ' Render after 2 seconds

            theDoc.Rect.SetRect(20, 110, 600, 620)
            theDoc.HtmlOptions.OnLoadScript = "(function(){ window.ABCpdf_go = false;     setTimeout(function(){ window.ABCpdf_go = true; }, 3000); })();"

            theURL = "http://localhost/icopalukintranet/pnf/rooflights/rooflightquotepdfletter.asp?quotenumber="+ quotenumber + "&stridrnd="+rnum
            'theDoc.AddImageUrl(theURL)
            theID = theDoc.AddImageUrl(theURL)
            While True
               
                If Not theDoc.Chainable(theID) Then
                    Exit While
                End If
                theDoc.Page = theDoc.AddPage()
                theID = theDoc.AddImageToChain(theID)
            End While


            ' add quote

           
 
            theDoc1.HtmlOptions.Engine = EngineType.Chrome86
            theDoc1.HtmlOptions.UseScript = True
            theDoc1.Rect.SetRect(0, 0, 600, 820)
            ' Render after 2 seconds
            theDoc1.HtmlOptions.OnLoadScript = "(function(){ window.ABCpdf_go = false; setTimeout(function(){ window.ABCpdf_go = true; }, 2000); })();"

       
        theURL = "http://localhost/icopalukintranet/pnf/rooflights/rooflightquotepdfquote.asp?quotenumber="+ quotenumber + "&stridrnd="+rnum
 

            theDoc1.Page = theDoc1.AddPage()
           
            theID = theDoc1.AddImageUrl(theURL)

            While True
               
                If Not theDoc1.Chainable(theID) Then
                    Exit While
                End If
                theSection = "Quote"
                theDoc1.Page = theDoc1.AddPage()
                theID = theDoc1.AddImageToChain(theID)
                theDoc1.AddBookmark(theSection, True)
            End While

     

        ' add notes

      
        theDoc1a.HtmlOptions.Engine = EngineType.Chrome86
        theDoc1a.HtmlOptions.UseScript = True
        theDoc1a.Rect.SetRect(0, 0, 600, 820)
        ' Render after 3 seconds
        theDoc1a.HtmlOptions.OnLoadScript = "(function(){ window.ABCpdf_go = false; setTimeout(function(){ window.ABCpdf_go = true; }, 1000); })();"

       
        theURL = "http://localhost/icopalukintranet/pnf/rooflights/rooflightquotepdfnotes.asp?quotenumber="+ quotenumber + "&stridrnd="+rnum
   

       theDoc1a.Page = theDoc1a.AddPage()
       
        theID = theDoc1a.AddImageUrl(theURL)
        While True
           
            If Not theDoc1a.Chainable(theID) Then
                Exit While
            End If
            theDoc1a.Page = theDoc1a.AddPage()
            theID = theDoc1a.AddImageToChain(theID)
        End While

     

        ' add terms details



        theDoc2.HtmlOptions.Engine = EngineType.Chrome86
        theDoc2.HtmlOptions.UseScript = True
       theDoc2.Rect.SetRect(20, 80, 560, 710)
    theDoc2.Transform.Magnify(0.93 ,0.93, 0, 690)
        ' Render after 1 seconds
        theDoc2.HtmlOptions.OnLoadScript = "(function(){ window.ABCpdf_go = false; setTimeout(function(){ window.ABCpdf_go = true; }, 2000); })();"
       
        theURL = "http://localhost/icopalukintranet/pnf/rooflights/rooflightquotepdfterms.asp?quotenumber="+ quotenumber + "&stridrnd="+rnum
   

         theDoc2.Page = theDoc2.AddPage()
       
        theID = theDoc2.AddImageUrl(theURL)
        While True

            If Not theDoc2.Chainable(theID) Then
                Exit While
            End If
            theSection = "Terms"
            theDoc2.Page = theDoc2.AddPage()
            theID = theDoc2.AddImageToChain(theID)
            theDoc2.AddBookmark(theSection, True)
        End While





        


    Dim cst = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                "Data Source=" & Server.MapPath("rooflightquotes.mdb")
    Dim conn = CreateObject("ADODB.Connection")
    conn.open(cst)
    Session("myConn") = conn

    dim rsAddquestion = Server.CreateObject("ADODB.Recordset")
    strsql ="select * from pdfs where id=" & quotenumber & " "
    rsAddquestion.Open(strsql, conn, 3, 3)

    dim n as string
    n=rsAddquestion.recordcount
    rsAddquestion.AddNew
    n=n+1
    rsAddquestion("id")=quotenumber
    rsAddquestion("pdfname") =quotenumber +"-rev"+n+".pdf"
    rsAddquestion("printdate")=now()
    rsAddquestion("status")="Printed"

    rsAddquestion.update

    rsAddquestion = Server.CreateObject("ADODB.Recordset")
    strsql ="select * from header where id=" & quotenumber & " "
    rsAddquestion.Open(strsql, conn, 3, 3)
    rsAddquestion("status")="Printed"
    rsAddquestion.update


    conn.close



   
        

        

        ' add the pdf together in selected order

       
        theDoc.Append(theDoc1)  
        theDoc.Append(theDoc1a)  
        theDoc.Append(theDoc2)
       
       
        Dim theCount = theDoc.PageCount
        '    left bottom width heght
        theDoc.Rect.String = "10 10 580 25"
        theDoc.HPos = 1.0
        theDoc.VPos = 0.5
        theDoc.Color.String = "255 255 255"

        theDoc.Font = theDoc.AddFont("Arial")
        theDoc.FontSize = 10
        For i = 1 To theCount
            theDoc.PageNumber = i
            If i <> 1 Then
       theDoc.AddHtml(" Page " + i.ToString() + " of " + theCount.ToString() + "")
                theDoc.FrameRect()
            End If
        Next


        dim pdffilenamec  = "pdf/"+quotenumber+"-rev"+n+".pdf"
      theDoc.Save(Server.MapPath(pdffilenamec))

       

       'response.redirect("rooflightquotepdfmenu.asp?quotenumber="+quotenumber)
 

End Sub

内容的提问来源于Stack Exchange,提问作者Kevin Bland

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.01 01:01:51