|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.faceless.pdf2.PDFImage
public final class PDFImage
The PDFImage class encapsulates a bitmap image, like a JPEG or PNG file, which can be inserted directly into the PDF document.
PDFPage page = pdf.newPage("A4");
InputStream in = new FileInputStream("mypicture.jpg");
PDFImage img = new PDFImage(in);
in.close();
page.drawImage(img, 100, 100, 100+i.getWidth(), 100+i.getHeight());
Images embedded into the document can be stretched to any size, but it's important to remember that there is a loss in quality as they're stretched. A thumbnail-size image scaled to full page will look bad on a 72dpi screen, and worse on a 600dpi printer.
Embedded ICC Color Profiles will be respected, as are Transparency (supported by the GIF, PNG, TIFF and JPEG2000 file formats) and TIFF clipping paths. Note that transparency will require Acrobat 5 or later to display the PDF.
| Constructor Summary | |
|---|---|
PDFImage(int w,
int h,
int bpc,
double dpix,
double dpiy,
boolean photo,
boolean alpha,
ColorSpace space,
InputStream[] planes)
Create a PDFImage from the raw bitmap data provided. |
|
| Method Summary | |
|---|---|
protected Object |
clone()
|
void |
close()
Compress the image and close it, preventing any further changes. |
protected void |
finalize()
|
double |
getDPIX()
Return the dots-per-inch of the image in the X direction (horizontally). |
double |
getDPIY()
Return the dots-per-inch of the image in the Y direction (vertically) Not every image contains this information (for example, it's not part of the GIF specification), in which case this method returns the default resolution of 72, which means 1 pixel = 1 point. |
float |
getHeight()
Return the height in points of the image. |
Reader |
getMetaData()
Return any XML metadata associated with this object. |
float |
getWidth()
Return the width in points of the image. |
void |
setMetaData(String xmldata)
Set the XML metadata associated with this object. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public PDFImage(int w,
int h,
int bpc,
double dpix,
double dpiy,
boolean photo,
boolean alpha,
ColorSpace space,
InputStream[] planes)
throws IOException
Create a PDFImage from the raw bitmap data provided. The vast majority of
users will be better off either parsing an encoded image format or calling
the #PDFImage(Image) constructor, but for special cases it's possible
to use this constructor to pass the raw bitmap data in for each plane.
w - the width of the image in pixelsh - the height of the image in pixelsbpc - the number of bits for each component of the image. Must be 1, 2, 4, 8 or 16 - although 16 is only supported by Acrobat 6 or later.dpix - the horizontal dots-per-inch of the imagedpiy - the vertical dots-per-inch of the imagephoto - for 8 bit images, whether to use JPEG compression instead of the normal Flate compression. For non 8-bit images this has no effectalpha - whether or not an alpha plane is being passed in as the last planespace - The ColorSpace this image is in. The number of components in the colorspace must match the number of planes passed in.planes - The planes of the image. Each InputStream represents a single plane (for example, a CMYK image would have four planes passed in, the first representing Cyan, the second Magenta and so on). Each InputStream must contain w*h*bpc bits of image data in the form of a number of horizontal scanlines starting at the top of the image. Each scanline must start on a byte boundary. Note the InputStreams are not closed by this constructor.
IOException - if one of the InputStreams throws an IOException while being read, or if one of
them returns a -1 from it's read() method.| Method Detail |
|---|
public float getWidth()
Return the width in points of the image. This may be different to the width in pixels, depending on whether the image contains information about it's resolution.
getDPIX()public float getHeight()
Return the height in points of the image. This may be different to the height in pixels, depending on whether the image contains information about it's resolution.
getDPIY()public double getDPIX()
public double getDPIY()
public void setMetaData(String xmldata)
PDF.setMetaData for more information.
xmldata - the XML data to embed into the document, or null
to clear any existing metadata. No validation is performed on this input.
public Reader getMetaData()
throws IOException
Return any XML metadata associated with this object. See the
PDF.getMetaData() for more information.
Note that JPEG2000 images may have more than one MetaData stream embedded in
them. If this is the case, in order to present only a single root node to the
XML Parser, the XML objects are all wrapped in a single <JPEG2000> node
Reader containing the source of the XML or
null if no metadata is available.
IOException - if the metadata can't be extractedpublic void close()
Cachepublic String toString()
protected void finalize()
finalize in class Objectprotected Object clone()
clone in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||