This example shows how to import an HTML page into a multi-page PDF document. Additionally it shows how you can scale HTML pages.

 

   
Scale
 
     

We first create an ABCpdf Doc object and set up a scale transform so our HTML pages will be shrunk down by 50%. We need to enlarge our Rect to encompass the new scale and then we inset the edges a little so that the HTML will appear in the middle of the page.

Set theDoc = Server.CreateObject("ABCpdf3.Doc")
theScale = 0.5
theDoc.Rect.Magnify 1 / theScale, 1 / theScale
theDoc.Transform.Magnify theScale, theScale, 0, 0
theDoc.Rect.Inset 72 / theScale, 144 / theScale

 

   
First
 
     

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.

theID = theDoc.AddImage("http://www.yahoo.com/", 1)

 

   
More
 
     

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

Do
  theDoc.FrameRect
  If theDoc.GetInfo(theID, "Truncated") <> "1" Then Exit Do
  theDoc.Page = theDoc.AddPage()
  theID = theDoc.AddImage(theID)
Loop

 

   
Comp
 
     

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]

 

 

 

   

 

Browser Based Help. Published by chm2web software.