Package org.pdfclown.documents.contents.entities

Examples of org.pdfclown.documents.contents.entities.Image


    frame.y = blockComposer.getBoundBox().getMaxY() + 30;
    frame.height -= (blockComposer.getBoundBox().getHeight() + 30);

    // Showing the posted image...
    // Instantiate a jpeg image object!
    Image image = null;
    try
    {
      image = Image.get(
        new Buffer(imageFileFormField.get())
        ); // Abstract image (entity).
    }
    catch(Exception e)
    {/* NOOP. */}
    if(image == null)
    {
      blockComposer.begin(frame,AlignmentXEnum.Left,AlignmentYEnum.Top);
      composer.setFont(bodyFont,12);
      composer.setFillColor(new DeviceRGBColor(1,0,0));
      blockComposer.showText("The file you uploaded wasn't a valid JPEG image!");
      blockComposer.end();

      // Move past the closed block!
      frame.y = blockComposer.getBoundBox().getMaxY() + 20;
      frame.height -= (blockComposer.getBoundBox().getHeight() + 20);
    }
    else
    {
      blockComposer.begin(frame,AlignmentXEnum.Left,AlignmentYEnum.Top);
      composer.setFont(bodyFont,12);
      blockComposer.showText("Here it is the image you uploaded: ");
      blockComposer.end();

      // Move past the closed block!
      frame.y = blockComposer.getBoundBox().getMaxY() + 20;
      frame.height -= (blockComposer.getBoundBox().getHeight() + 20);

      double width = image.getWidth(), height = image.getHeight();
      if(width > frame.getWidth())
      {
        height *= frame.getWidth() / width;
        width = frame.getWidth();
      }
      if(height > frame.getHeight() / 2)
      {
        width *= frame.getHeight() / 2 / height;
        height = frame.getHeight() / 2;
      }
      // Show the image!
      composer.showXObject(
        image.toXObject(document),
        new Point2D.Double(
          (pageSize.getWidth() - 90 - width) / 2 + 20,
          blockComposer.getBoundBox().getMaxY() + 20
          ),
        new Dimension(width,height)
View Full Code Here


    template.setSize(document.getPageSize());
    Dimension2D templateSize = template.getSize();

    PrimitiveComposer composer = new PrimitiveComposer(template);

    Image image = null;
    try
    {
      // Instantiate a jpeg image object!
      image = Image.get(new java.io.File(((java.net.URL)SampleHelper.class.getResource("mountains.jpg")).toURI()).getPath()); // Abstract image (entity).
    }
    catch(Exception e)
    {/* NOOP. */}
    // Show the image inside the common content stream!
    composer.showXObject(
      image.toXObject(document),
      new Point2D.Double(0,0),
      new Dimension(
        (int)templateSize.getWidth() - 50,
        125
        )
View Full Code Here

    composer.stroke();
    */

    // Showing the 'GNU' image...
    // Instantiate a jpeg image object!
    Image image = Image.get(getInputPath() + java.io.File.separator + "images" + java.io.File.separator + "gnu.jpg"); // Abstract image (entity).
    // Show the image!
    composer.showXObject(
      image.toXObject(document),
      new Point2D.Double(
        (pageSize.getWidth() - 90 - image.getWidth()) / 2 + 20,
        pageSize.getHeight() - 100 - image.getHeight()
        ),
      new Dimension(0,0)
      );

    // Showing the title...
    blockComposer.begin(frame,AlignmentXEnum.Left,AlignmentYEnum.Top);
    composer.setFont(font,24);
    blockComposer.showText("The Free Software Definition");
    blockComposer.end();

    // Showing the copyright note...
    frame = new Rectangle2D.Double(
      blockComposer.getBoundBox().getX(),
      blockComposer.getBoundBox().getY() + blockComposer.getBoundBox().getHeight() + 32,
      blockComposer.getBoundBox().getWidth(),
      (pageSize.getHeight() - 100 - image.getHeight() - 10) - (blockComposer.getBoundBox().getY() + blockComposer.getBoundBox().getHeight() + 32)
      );
    blockComposer.begin(frame,AlignmentXEnum.Justify,AlignmentYEnum.Bottom);
    composer.setFont(font,6);
    blockComposer.showText("Copyright 2004, 2005, 2006 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA Verbatim copying and distribution of this entire article are permitted worldwide, without royalty, in any medium, provided this notice is preserved.");

    // Showing the body...
    blockComposer.showBreak(breakSize);
    composer.setFont(font,8.25f);
    Rectangle2D[] frames = new Rectangle2D[]
      {
        new Rectangle2D.Double(
          blockComposer.getBoundBox().getX(),
          pageSize.getHeight() - 100 - image.getHeight() - 10,
          blockComposer.getBoundBox().getWidth()-image.getWidth()/2,
          image.getHeight() + 10
          ),
        new Rectangle2D.Double(
          20 + 20 + (pageSize.getWidth() - 90 - 20) / 2,
          150,
          (pageSize.getWidth() - 90 - 20) / 2,
          (pageSize.getHeight() - 100 - image.getHeight() - 10) - 150
          ),
        new Rectangle2D.Double(
          20 + 20 + (pageSize.getWidth() - 90 - 20) / 2 + image.getWidth()/2,
          pageSize.getHeight() - 100 - image.getHeight() - 10,
          blockComposer.getBoundBox().getWidth()-image.getWidth()/2,
          image.getHeight() + 10
          ),
        new Rectangle2D.Double(
          20,
          150,
          (pageSize.getWidth() - 90 - 20) / 2,
View Full Code Here

    // End the block!
    blockComposer.end();

    // Showing the clown photo...
    // Instantiate a jpeg image object!
    Image image = Image.get(getInputPath() + java.io.File.separator + "images" + java.io.File.separator + "Clown.jpg"); // Abstract image (entity).

    Point2D imageLocation = new Point2D.Double(
      blockComposer.getBoundBox().getX() + blockComposer.getBoundBox().getWidth() - image.getWidth(),
      blockComposer.getBoundBox().getY() + blockComposer.getBoundBox().getHeight() + 25
      );
    // Show the image!
    composer.showXObject(
      image.toXObject(document),
      imageLocation,
      new Dimension(0,0)
      );

    Rectangle2D descriptionFrame = new Rectangle2D.Double(
      imageLocation.getX(),
      imageLocation.getY() + image.getHeight() + 5,
      image.getWidth(),
      20
      );

    frame = new Rectangle2D.Double(
      blockComposer.getBoundBox().getX(),
      imageLocation.getY(),
      blockComposer.getBoundBox().getWidth() - image.getWidth() - 20,
      image.getHeight()
      );
    blockComposer.begin(frame,AlignmentXEnum.Left,AlignmentYEnum.Middle);
    composer.setFont(font,30);
    blockComposer.showText("This is a sample document that merely demonstrates some basic graphics features supported by PDF Clown.");
    blockComposer.showBreak(AlignmentXEnum.Center);
View Full Code Here

    // Get form content stream!
    PrimitiveComposer composer = new PrimitiveComposer(template);

    // Showing the header image inside the common content stream...
    // Instantiate a jpeg image object!
    Image image = Image.get(getInputPath() + java.io.File.separator + "images" + java.io.File.separator + "mountains.jpg"); // Abstract image (entity).
    // Show the image inside the common content stream!
    composer.showXObject(
      image.toXObject(document),
      new Point2D.Double(0,0),
      new Dimension(
        (int)templateSize.getWidth() - 50,
        125
        )
View Full Code Here

      blockComposer.end();
    }
    // Showing the 'GNU' image...
    {
      // Instantiate a jpeg image object!
      Image image = Image.get(
        getInputPath() + java.io.File.separator + "images" + java.io.File.separator + "gnu.jpg"
        ); // Abstract image (entity).
      // Show the image!
      composer.showXObject(
        image.toXObject(document),
        new Point2D.Double(
          (float)pageSize.getWidth() / 2,
          (float)pageSize.getHeight() / 2
          ),
        new Dimension(0,0),
View Full Code Here

      blockComposer.end();
    }
    // Showing the 'GNU' image...
    {
      // Instantiate the image!
      Image image = Image.get(getInputPath() + java.io.File.separator + "images" + java.io.File.separator + "gnu.jpg");
      // Set the position of the image in the page!
      composer.applyMatrix(200,0,0,200,(pageSize.getWidth()-200)/2,(pageSize.getHeight()-200)/2);
      // Show the image!
      image.toInlineObject(composer); // Transforms the image entity into an inline image within the page.
    }
    composer.flush();
  }
View Full Code Here

  private void replaceImages(
    Document document
    )
  {
    // Get the image used to replace existing ones!
    Image image = Image.get(getInputPath() + java.io.File.separator + "images" + java.io.File.separator + "gnu.jpg"); // Image is an abstract entity, as it still has to be included into the pdf document.
    // Add the image to the document!
    XObject imageXObject = image.toXObject(document); // XObject (i.e. external object) is, in PDF spec jargon, a reusable object.
    // Looking for images to replace...
    for(Page page : document.getPages())
    {
      Resources resources = page.getResources();
      XObjectResources xObjects = resources.getXObjects();
View Full Code Here

      }
      );
    composer.clip();
    // Showing a clown image...
    // Instantiate a jpeg image object!
    Image image = Image.get(getInputPath() + java.io.File.separator + "images" + java.io.File.separator + "Clown.jpg"); // Abstract image (entity).
    // Show the image!
    composer.showXObject(
      image.toXObject(document),
      new Point2D.Double(
        170,
        320
        ),
      new Dimension(450,0)
View Full Code Here

TOP

Related Classes of org.pdfclown.documents.contents.entities.Image

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.