GemBox.Pdf
  • Overview
  • Examples
  • Free version
  • Support
  • Pricelist

    Show / Hide Table of Contents

    PdfImage Class

    Namespace:
    GemBox.Pdf.Content
    Assembly:
    GemBox.Pdf.dll

    A rectangular array of sample values, each representing a color.

    • C#
    • VB.NET
    public sealed class PdfImage : PdfExternalObject
    Public NotInheritable Class PdfImage
        Inherits PdfExternalObject
    Inheritance:
    System.Object
    PdfObject
    PdfContentResource
    PdfExternalObject
    PdfImage

    Properties

    BitsPerComponent

    (Required except for image masks and images that use the JPXDecode filter) The number of bits used to represent each color component.

    Only a single value shall be specified; the number of bits shall be the same for all color components. The value shall be 1, 2, 4, 8, or (in PDF 1.5) 16.

    If ImageMask is true, this entry is optional, but if specified, its value shall be 1.

    • C#
    • VB.NET
    public int? BitsPerComponent { get; }
    Public ReadOnly Property BitsPerComponent As Integer?
    Property Value
    System.Nullable<System.Int32>

    The number of bits used to represent each color component.

    ColorSpace

    (Required for images, except those that use the JPXDecode filter; not permitted for image masks) The color space in which image samples shall be specified; it can be any type of color space except Pattern.

    • C#
    • VB.NET
    public PdfColorSpace ColorSpace { get; }
    Public ReadOnly Property ColorSpace As PdfColorSpace
    Property Value
    PdfColorSpace

    The color space in which image samples shall be specified.

    ExplicitMask

    (Optional; shall not be present for image masks; PDF 1.3) An image XObject defining an image mask to be applied to this image (see 8.9.6.3,"Explicit masking"), or an array specifying a range of colors to be applied to it as a color key mask (see 8.9.6.4, "Color key masking").

    If ImageMask is true, this entry shall not be present.

    • C#
    • VB.NET
    public PdfImage ExplicitMask { get; }
    Public ReadOnly Property ExplicitMask As PdfImage
    Property Value
    PdfImage

    An image XObject defining an image mask to be applied to this image.

    Height

    (Required) The height of the image, in samples (pixels). For physical dimensions (in points), use the Size property.

    • C#
    • VB.NET
    public int Height { get; }
    Public ReadOnly Property Height As Integer
    Property Value
    System.Int32

    The height of the image, in samples (pixels).

    ImageMask

    (Optional) A flag indicating whether the image shall be treated as an image mask (see 8.9.6, "Masked Images").

    If this flag is true, the value of BitsPerComponent shall be 1 and Mask and ColorSpace shall not be specified; unmasked areas shall be painted using the current nonstroking color.

    Default value: false.

    • C#
    • VB.NET
    public bool ImageMask { get; }
    Public ReadOnly Property ImageMask As Boolean
    Property Value
    System.Boolean

    A flag indicating whether the image shall be treated as an image mask.

    Size

    Gets or sets the physical size of the PdfImage in points (72 points = 1 inch).

    Default value: the Width and the Height of the PdfImage (1 pixel = 1 point).

    • C#
    • VB.NET
    public PdfSize Size { get; set; }
    Public Property Size As PdfSize
    Property Value
    PdfSize

    The physical size of the PdfImage in points.

    Remarks

    This property is set when loading a PdfImage if the encoded image data contains the DPI (dots or pixels per inch) information. For example, in the PNG-encoded image this information is contained in the pHYs chunk.

    It can be set to an arbitrary value to specify the physical size of the PdfImage and is used when drawing a PdfImage with the DrawImage(PdfImage, PdfPoint) overload (the Width is set to the M11 and the Height is set to the M22 of the Transform of the inserted PdfImageContent).

    If specified, it is used when saving a PdfImageContent to encode the DPI information if the encoded image format supports it.

    It is also used for positioning and sizing the signature Icon and when cloning the PdfImage.

    note

    This property is not saved to a PDF file because the physical size (or more exactly, the transformation) of the image in a PDF content is specified with the Transform of the PdfImageContent.

    SoftMask

    (Optional; PDF 1.4) A subsidiary image XObject defining a soft-mask image (see 11.6.5.2, "Soft-mask images") that shall be used as a source of mask shape or mask opacity values in the transparent imaging model. The alpha source parameter in the graphics state determines whether the mask values shall be interpreted as shape or opacity.

    If present, this entry shall override the current soft mask in the graphics state, as well as the image’s Mask entry, if any.

    • C#
    • VB.NET
    public PdfImage SoftMask { get; }
    Public ReadOnly Property SoftMask As PdfImage
    Property Value
    PdfImage

    A subsidiary image XObject defining a soft-mask image.

    Width

    (Required) The width of the image, in samples (pixels). For physical dimensions (in points), use the Size property.

    • C#
    • VB.NET
    public int Width { get; }
    Public ReadOnly Property Width As Integer
    Property Value
    System.Int32

    The width of the image, in samples (pixels).

    Methods

    Clone()

    Clones this PdfImage.

    • C#
    • VB.NET
    public PdfImage Clone()
    Public Function Clone As PdfImage
    Returns
    PdfImage

    The clone of this PdfImage.

    Remarks

    This method doesn't do a deep clone of the underlying indirect objects and is intended to be used only to edit inline Image as explained in the documentation of the Image property.

    Load(Stream)

    Loads a PdfImage from the specified stream and with the Default options.

    • C#
    • VB.NET
    public static PdfImage Load(Stream stream)
    Public Shared Function Load(stream As Stream) As PdfImage
    Parameters
    stream
    System.IO.Stream

    The stream from which to load a PdfImage.

    Returns
    PdfImage

    A loaded PdfImage.

    Load(Stream, ImageLoadOptions)

    Loads a PdfImage from the specified stream and with the specified options.

    • C#
    • VB.NET
    public static PdfImage Load(Stream stream, ImageLoadOptions options)
    Public Shared Function Load(stream As Stream, options As ImageLoadOptions) As PdfImage
    Parameters
    stream
    System.IO.Stream

    The stream from which to load a PdfImage.

    options
    ImageLoadOptions

    The options used for loading a PdfImage from the specified stream.

    Returns
    PdfImage

    A loaded PdfImage.

    Load(String)

    Loads a PdfImage from a file with the specified path and with the Default options.

    • C#
    • VB.NET
    public static PdfImage Load(string path)
    Public Shared Function Load(path As String) As PdfImage
    Parameters
    path
    System.String

    The path to a file from which to load a PdfImage.

    Returns
    PdfImage

    A loaded PdfImage.

    Load(String, ImageLoadOptions)

    Loads a PdfImage from a file with the specified path and with the specified options.

    • C#
    • VB.NET
    public static PdfImage Load(string path, ImageLoadOptions options)
    Public Shared Function Load(path As String, options As ImageLoadOptions) As PdfImage
    Parameters
    path
    System.String

    The path to a file from which to load a PdfImage.

    options
    ImageLoadOptions

    The options used for loading a PdfImage from a file.

    Returns
    PdfImage

    A loaded PdfImage.

    Inherited Properties

    AssociatedFiles

    (Optional; PDF 2.0) An array of one or more PdfFileSpecifications which denote the associated files for this PdfImage or PdfForm.

    (Inherited from PdfExternalObject)

    Document

    Gets the PdfDocument associated with this PdfContentResource or null if no PdfDocument is associated with this PdfContentResource.

    (Inherited from PdfContentResource)

    Metadata

    (Optional; PDF 1.4) A metadata stream containing metadata for the component.

    (Inherited from PdfObject)

    Extension Methods

    PdfObjectExtensions.GetDictionary(PdfObject)
    PdfObjectExtensions.GetOrAddDictionary(PdfObject)
    PdfObjectExtensions.GetArray(PdfObject)

    See Also

    PdfExternalObject
    PDF Specification ISO 32000-1:2008, section '8.9.5 Image Dictionaries'
    Back to top

    Facebook • Twitter • LinkedIn

    © GemBox Ltd. — All rights reserved.