VintaSoft Imaging .NET SDK v8.6
Vintasoft.Imaging.Pdf.Drawing.GraphicsFigures Namespace / ImageFigure Class
Members Example



In This Topic
    ImageFigure Class
    In This Topic
    Represents an image.
    Object Model
    ImageFigure ClassPdfBrush ClassPdfImageResource ClassPdfContentPadding StructurePdfPen ClassGraphicsFigurePoints Class
    Syntax
    'Declaration
     
    Public Class ImageFigure 
       Inherits RectangleFigure
       Implements IAutoSizeGraphicsFigure 
    public class ImageFigure : RectangleFigure, IAutoSizeGraphicsFigure  
    public __gc class ImageFigure : public RectangleFigure, IAutoSizeGraphicsFigure  
    public ref class ImageFigure : public RectangleFigure, IAutoSizeGraphicsFigure  
    Example
    This example shows how to draw an image figure on PDF page.
    Public Shared Sub CreatePdfDocument(pdfFilename As String, imageFilename As String)
        ' create PDF document
        Using document As New Vintasoft.Imaging.Pdf.PdfDocument(pdfFilename, Vintasoft.Imaging.Pdf.PdfFormat.Pdf_14)
            ' open image
            Using image As New Vintasoft.Imaging.VintasoftImage(imageFilename)
                ' add new page to PDF document
                Dim page As Vintasoft.Imaging.Pdf.Tree.PdfPage = document.Pages.Add(Vintasoft.Imaging.PaperSizeKind.A4)
                ' add image resource to PDF document
                Dim imageResource As New Vintasoft.Imaging.Pdf.Tree.PdfImageResource(document, image, Vintasoft.Imaging.Pdf.PdfCompression.Auto)
                
                ' create layout panel
                Dim rootLayout As New Vintasoft.Imaging.Pdf.Drawing.GraphicsFigures.AlignmentPanel()
                rootLayout.Location = page.MediaBox.Location
                rootLayout.Size = page.MediaBox.Size
                ' set layout panel margin (5 mm)
                Dim margin As Double = Vintasoft.Imaging.Utils.UnitOfMeasureConverter.ConvertToPdfUserUnits(5, Vintasoft.Imaging.UnitOfMeasure.Millimeters)
                rootLayout.Margin = New Vintasoft.Imaging.Pdf.Drawing.PdfContentPadding(margin)
                
                ' create image figure
                Dim imageFigure As New Vintasoft.Imaging.Pdf.Drawing.GraphicsFigures.ImageFigure(imageResource)
                ' maintain aspect ratio of image
                imageFigure.MaintainAspectRatio = True
                ' add image figure to layout panel
                rootLayout.Add(imageFigure)
                
                ' draw figures on graphics of PDF page
                Using g As Vintasoft.Imaging.Pdf.Drawing.PdfGraphics = page.GetGraphics()
                    rootLayout.Draw(g)
                End Using
                
                ' save document changes
                document.SaveChanges()
            End Using
        End Using
    End Sub
    public static void CreatePdfDocument(string pdfFilename, string imageFilename)
    {
        // create PDF document
        using (Vintasoft.Imaging.Pdf.PdfDocument document = 
            new Vintasoft.Imaging.Pdf.PdfDocument(pdfFilename, Vintasoft.Imaging.Pdf.PdfFormat.Pdf_14))
        {
            // open image
            using (Vintasoft.Imaging.VintasoftImage image = new Vintasoft.Imaging.VintasoftImage(imageFilename))
            {
                // add new page to PDF document
                Vintasoft.Imaging.Pdf.Tree.PdfPage page = document.Pages.Add(
                    Vintasoft.Imaging.PaperSizeKind.A4);
                // add image resource to PDF document
                Vintasoft.Imaging.Pdf.Tree.PdfImageResource imageResource = 
                    new Vintasoft.Imaging.Pdf.Tree.PdfImageResource(
                        document, image, Vintasoft.Imaging.Pdf.PdfCompression.Auto);
                
                // create layout panel
                Vintasoft.Imaging.Pdf.Drawing.GraphicsFigures.AlignmentPanel rootLayout = 
                    new Vintasoft.Imaging.Pdf.Drawing.GraphicsFigures.AlignmentPanel();
                rootLayout.Location = page.MediaBox.Location;
                rootLayout.Size = page.MediaBox.Size;
                // set layout panel margin (5 mm)
                double margin = Vintasoft.Imaging.Utils.UnitOfMeasureConverter.ConvertToPdfUserUnits(
                    5, Vintasoft.Imaging.UnitOfMeasure.Millimeters);
                rootLayout.Margin = new Vintasoft.Imaging.Pdf.Drawing.PdfContentPadding(margin);
                
                // create image figure
                Vintasoft.Imaging.Pdf.Drawing.GraphicsFigures.ImageFigure imageFigure = 
                    new Vintasoft.Imaging.Pdf.Drawing.GraphicsFigures.ImageFigure(imageResource);
                // maintain aspect ratio of image
                imageFigure.MaintainAspectRatio = true;
                // add image figure to layout panel
                rootLayout.Add(imageFigure);
                
                // draw figures on graphics of PDF page
                using (Vintasoft.Imaging.Pdf.Drawing.PdfGraphics g = page.GetGraphics())
                    rootLayout.Draw(g);
                
                // save document changes
                document.SaveChanges();
            }
        }
    }
    Inheritance Hierarchy

    System.Object
       Vintasoft.Imaging.Pdf.Drawing.GraphicsFigures.GraphicsFigure
          Vintasoft.Imaging.Pdf.Drawing.GraphicsFigures.RectangleFigure
             Vintasoft.Imaging.Pdf.Drawing.GraphicsFigures.ImageFigure

    Requirements

    Target Platforms: Windows 10, Windows 8, Windows 7, Windows Vista, Windows XP, Windows Server 2012, Windows Server 2008, Windows Server 2003

    See Also