This example shows how to import an HTML page into a multi-page PDF document.

 

   

Setup
 

We first create a Doc object and inset the edges a little so that the HTML will appear in the middle of the page.

Set theDoc = Server.CreateObject("ABCpdf10.Doc")
theDoc.Rect.Inset 72, 144

 

   

Page
 

We add the first page and indicate that we will be adding more pages by telling the Doc object that this is page one. We save the returned ID as this will be used to add subsequent pages.

theDoc.Page = theDoc.AddPage()
theURL = "http://www.yahoo.com/"
theID = theDoc.AddImageUrl(theURL)

 

   

Chain
 

We now chain subsequent pages together. We stop when we reach a page which wasn't truncated.

Do
  theDoc.FrameRect ' add a black border
  If Not theDoc.Chainable(theID) Then Exit Do
  theDoc.Page = theDoc.AddPage()
  theID = theDoc.AddImageToChain(theID)
Loop

 

   

Flatten
 

After adding the pages, we can flatten them. We can't do this until after the pages have been added because flattening will invalidate our previous ID and break the chain.

For i = 1 To theDoc.PageCount
  theDoc.PageNumber = i
  theDoc.Flatten
Next

 

   

Save
 

Finally, we save.

theDoc.Save "c:\mypdfs\pagedhtml.pdf"

 

   

Results
 

We get the following output.


pagedhtml.pdf [Page 1]

pagedhtml.pdf [Page 2]