'''' This code is part of Document Solutions for PDF .NET demos.'' Copyright (c) MESCIUS inc. All rights reserved.''ImportsSystem.IOImportsSystem.DrawingImportsGrapeCity.Documents.PdfImportsGrapeCity.Documents.DrawingImports GCDRAW = GrapeCity.Documents.Drawing '' This sample demonstrates the ability of DsPdf to render'' images Imports a specified transparency (opacity).PublicClassImageTransparencyFunctionCreatePDF(ByVal stream AsStream) AsIntegerDim doc = NewGcPdfDocument()Dim page = doc.NewPage()Dim g = page.Graphics Dim rc = Util.AddNote("GcPdfGraphics.DrawImage() method allows rendering images with a specified opacity. " +"Below is a random text with an image drawn on top of it using opacity 0.2 (almost transparent), " +"0.5 (medium transparency) and 1 (non-transparent).", page) Dim tl = g.CreateTextLayout() tl.DefaultFormat.Font = StandardFonts.Times tl.DefaultFormat.FontSize = 12 tl.MaxWidth = page.Size.Width tl.MaxHeight = page.Size.Height tl.MarginAll = 36 tl.MarginTop += rc.Bottom tl.Append(Util.LoremIpsum(2)) tl.PerformLayout(True) g.DrawTextLayout(tl, PointF.Empty) Using img AsGCDRAW.Image = GCDRAW.Image.FromFile(Path.Combine("Resources", "Images", "puffins.jpg"))Dim imageRc = NewRectangleF(tl.MarginLeft, tl.MarginTop, 144, 144)'' Opacity 0.2: g.DrawImage(img, imageRc, Nothing, ImageAlign.ScaleImage, 0.2F) imageRc.Offset(imageRc.Width + 36, 0)'' Opacity 0.5: g.DrawImage(img, imageRc, Nothing, ImageAlign.ScaleImage, 0.5F) imageRc.Offset(imageRc.Width + 36, 0)'' Opacity 1 (default): g.DrawImage(img, imageRc, Nothing, ImageAlign.ScaleImage) '' NOTE: we must save document BEFORE disposing the image(s) used in it: doc.Save(stream)EndUsingReturn doc.Pages.CountEndFunctionEndClass