This example shows how to create a PDF displaying an image of a certain size. If the image is the wrong size then we delete it and use a placeholder instead.

 

   
Setup
 
     

First we create an ABCpdf Doc object and set the rect to a point at a particular location 100 pixels up and right from the bottom left. We add the image at this location. Because the width and height of our supplied rectangle are zero the natural dimensions of the image will be used to determine the size of the image on the page. Just for reference we'll save the document at this stage.

Set theDoc = Server.CreateObject("ABCpdf3.Doc")
theDoc.Rect = "100 100 100 100"
theID1 = theDoc.AddImage("c:\mypics\pic.jpg")
theDoc.Save "c:\mypdfs\image1.pdf"

 

   
Check
 
     

We need to check that the dimensions of the image weren't too big for our document so we use the GetInfo function to get the natural dimensions of the image.

theID2 = theDoc.GetInfo(theID1, "XObject")
theWidth = theDoc.GetInfo(theID2, "Width")
theHeight = theDoc.GetInfo(theID2, "Height")

 

   
Delete
 
     

If the image was too big we delete it and add in a placeholder to replace it. Finally we save out the PDF.

If theWidth > 400 Or theHeight > 400 Then
  theDoc.Delete(theID1)
  theDoc.AddImage "c:\mypics\place.jpg"
End If
theDoc.Save "c:\mypdfs\image2.pdf"

 

   
Results
 
     


image1.pdf


image2.pdf

 

   

 

Browser Based Help. Published by chm2web software.