Repeated Images

Sometimes it happens to repeat many times the same image inside a PDF file. This always happens if you use a background image (like powerpint slides or tax forms) or with your company logo.

PDFReport is so smart to permit the developer to import an image once and to reuse it in various sizes and pages throughout the entire document.

All you need to to is to import once the image and then to draw that image as many times as you want. The image will be stored only once inside the PDF document, so it will be very small.

As no other PDF engine or PDF Printer driver offers this solution, this means that you can make big catalogs with backgrounds and Hi Res logos or scanned tax forms inside your PDF files KEPPING THEM VERY SMALL. For example, the avarage space saving is normally 12:1 if you use the same background on all 12 pages of a PDF file. In this case for example a 6 megabyte file could be reduced to a 0.5 Megabyte file!

Private Sub Command12_Click()
Dim PDFRPT As New PDFDocument
Dim BackgroundImageID As Integer
PDFRPT.NewPDF "This is my first PDF"
PDFRPT.SetFillColor 255, 255, 255
BackgroundImageID = PDFRPT.ImportImageAsResource(App.Path & "\audiavus07s.jpg", 99)
PDFRPT.DrawImageResource 0, 0, 210, 297, BackgroundImageID
PDFRPT.TextOut "Hello World!", 10, 10
PDFRPT.AddPage
PDFRPT.SetFillColor 255, 0, 255 ' another color for text...
PDFRPT.DrawImageResource 0, 0, 210, 297, BackgroundImageID
PDFRPT.TextOut "Hello World!", 10, 10
PDFRPT.AddPage
PDFRPT.DrawImageResource 0, 0, 210, 297, BackgroundImageID
PDFRPT.SetFillColor 255, 255, 0 ' another color for text...
PDFRPT.TextOut "Hello World!", 10, 10
PDFRPT.SavePDF "c:\provaocx.pdf"
End Sub

This is the result:

If we use the normal ImportImage function, the file is identical in the aspect, but is nearly 3 times larger!

This is because we have imported 3 times (for 3 pages) the same image!

(By the way: the images' sizes were: 141 KB the optimized version, 404 Kb the NON optimized version)