BackgroundImage Class | Image Class | Performance Considerations | Images | Programming with Generator for COM/ActiveX

DynamicPDF™ Generator for COM/ActiveX is designed to allow highly efficient reuse of images within a document or across several documents. The AddRawImageData method of the Document class is included for this purpose. This method holds the reference for an image and can be used in the  AddImage and AddBackgroundImage methods. When the same ImageData object is used multiple times in a PDF document, its data will only be included once in the resulting PDF document.

NOTE: If the same Image or BackgroundImage Page Element is used multiple times in the same document, image reuse is handled automatically because the same ImageData object is used each time it is displayed. This also applies to images that are used in a single section or document template.

Using The Same Image Multiple Times In A Document

When using an image multiple times in a document, care must be taken to ensure that the image data is not included multiple times in the PDF output. This is accomplished by creating an reference using AddRawImageData Method and using that in the AddImage or AddBackgroundImage methods.  Using this technique, the same image can appear at different locations and scale in the document without increasing the overall size of the document:

[ASP - VBScript]
<!-- METADATA TYPE="typelib" UUID="{DF9225FE-94A4-490D-8CAD-E8366CE621D3}"-->
<%
    ' Create an Reference object from the image.
    Dim MyDocument
    Dim MyPage1
    Dim MyPage2
    Set MyDocument = Server.CreateObject( "DynamicPDF.Document" )
    Dim MyStream
    Set MyStream = Server.CreateObject( "ADODB.Stream" )
    MyStream.Open
    MyStream.Type = 1 'Type of Stream file
    MyStream.LoadFromFile( Server.MapPath( "Images/ceTeSoftware_top.gif" ) )
    Dim MyFilePath
    MyFilePath = MyDocument.AddRawImageData( "Home.jpg", MyStream.Read )
    MyStream.Close
    Set MyStream = Nothing
    Set MyPage1 = MyDocument.AddPage()
    Set MyPage2 = MyDocument.AddPage()
    ' MyFilePath has a reference to the jpg file.   
    ' Add the image to the fist page twice.
    MyPage1.AddBackgroundImage MyFilePath
    MyPage1.AddImage MyFilePath, 0, 0, 24
    ' Add the image to the second page at a different location and scale. 
    MyPage2.AddImage MyFilePath, 100, 100, 48
    MyDocument.DrawToWeb
    Set MyPage1 = Nothing
    Set MyPage2 = Nothing
    Set MyDocument = Nothing
%>

See Also 

BackgroundImage Class | Image Class | Performance Considerations | Images | Programming with Generator for COM/ActiveX