Package com.pdftools.toolbox.pdf.content
Class ImageMask
- java.lang.Object
-
- com.pdftools.toolbox.internal.NativeBase
-
- com.pdftools.toolbox.internal.NativeObject
-
- com.pdftools.toolbox.pdf.content.ImageMask
-
public class ImageMask extends NativeObject
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ImageMask
create(Document targetDocument, Stream stream)
Create an image mask object from image data.void
extract(Stream stream)
Extract image mask from PDFvoid
extract(Stream stream, ImageType imageType)
Extract image mask from PDFSize
getSize()
The size of the image mask in samples.-
Methods inherited from class com.pdftools.toolbox.internal.NativeObject
equals, hashCode
-
-
-
-
Method Detail
-
create
public static ImageMask create(Document targetDocument, Stream stream) throws java.io.IOException, UnknownFormatException, CorruptException
Create an image mask object from image data.
Supported formats are:- BMP
- DIB
- JBIG2
- PNG
- GIF
- Parameters:
targetDocument
- the output document with which the returned object is associatedstream
- the image data stream- Returns:
- the newly created image mask object
- Throws:
java.io.IOException
- Error reading from the image or writing to the documentUnknownFormatException
- The image data has an unknown format or the format is not suitable for an image maskCorruptException
- The image data is corruptjava.lang.IllegalArgumentException
- if thetargetDocument
argument has already been closedjava.lang.IllegalArgumentException
- if thetargetDocument
argument is read-onlyjava.lang.IllegalArgumentException
- if thestream
argument isnull
java.lang.IllegalArgumentException
- iftargetDocument
isnull
java.lang.IllegalArgumentException
- ifstream
isnull
-
extract
public void extract(Stream stream) throws GenericException
Extract image mask from PDF
Facilitate the extraction of image masks from a specified page within a PDF, outputting them in the
imageType
format.By default
imageType
takes the valueImageType.TIFF
.Key considerations include:
- The extraction process isolates the image from the page's resources, neglecting any contextual attributes from the PDF page. Consequently, the original resolution and modifications—such as scaling, rotation, or cropping—that influence the image's appearance on the page are not preserved in the extracted image mask.
-
In instances where a
GenericException
error arises, the output file may be compromised and rendered unusable.
This method is designed to efficiently retrieve image masks without their page-specific modifications, ensuring a straightforward extraction process.
- Parameters:
stream
- The image mask data stream.- Throws:
java.lang.IllegalArgumentException
- if thestream
argument is nulljava.lang.IllegalStateException
- if the image has already been closedGenericException
- if image extraction failsjava.lang.IllegalArgumentException
- ifstream
isnull
-
extract
public void extract(Stream stream, ImageType imageType) throws GenericException
Extract image mask from PDF
Facilitate the extraction of image masks from a specified page within a PDF, outputting them in the
imageType
format.By default
imageType
takes the valueImageType.TIFF
.Key considerations include:
- The extraction process isolates the image from the page's resources, neglecting any contextual attributes from the PDF page. Consequently, the original resolution and modifications—such as scaling, rotation, or cropping—that influence the image's appearance on the page are not preserved in the extracted image mask.
-
In instances where a
GenericException
error arises, the output file may be compromised and rendered unusable.
This method is designed to efficiently retrieve image masks without their page-specific modifications, ensuring a straightforward extraction process.
- Parameters:
stream
- The image mask data stream.imageType
-- Throws:
java.lang.IllegalArgumentException
- if thestream
argument is nulljava.lang.IllegalStateException
- if the image has already been closedGenericException
- if image extraction failsjava.lang.IllegalArgumentException
- ifstream
isnull
-
getSize
public Size getSize()
The size of the image mask in samples. (Getter)
- Throws:
java.lang.IllegalStateException
- if the image has already been closed
-
-