Adding Images

Adding images to PDF for Silverlight documents is also easy, all the work is done by the C1PdfDocument.DrawImage method.

C1PdfDocument.DrawImage draws a given image at a specified location and has parameters that provide control over the image alignment and scaling. In the following example, this image is:

      Stretched to fill the given rectangle

      Center-aligned within the rectangle, scaled to keep the aspect ratio

      Aligned to the top-left corner of the rectangle, with the original size

This code is used to draw the same image three times:

      Visual Basic

      C#

 

The PDF document will look similar to this:

 

Notice that you can render any regular .NET Image object, including Metafiles. Metafiles are not converted into bitmaps; they are played into the document and thus retain the best possible resolution. If you want to add charts or technical drawings to your PDF document, Metafiles are better than bitmap images.

Bitmap images are managed automatically by PDF for Silverlight. If you render the same image several times (in a page header for example), only one copy of the image is saved into the PDF file.


Send us comments about this topic.
Copyright © GrapeCity, inc. All rights reserved.