Package org.pdfclown.documents.contents.xObjects

Examples of org.pdfclown.documents.contents.xObjects.XObject


    AlignmentXEnum alignmentX,
    AlignmentYEnum alignmentY,
    float rotation
    )
  {
    XObject xObject = scanner.getContentContext().getResources().getXObjects().get(name);

    // Adjusting default dimensions...
    /*
      NOTE: Zero-valued dimensions represent default proportional dimensions.
    */
    Dimension2D xObjectSize = xObject.getSize();
    if(size.getWidth() == 0)
    {
      if(size.getHeight() == 0)
      {size.setSize(xObjectSize);}
      else
      {size.setSize(size.getHeight() * xObjectSize.getWidth() / xObjectSize.getHeight(),size.getHeight());}
    }
    else if(size.getHeight() == 0)
    {size.setSize(size.getWidth(),size.getWidth() * xObjectSize.getHeight() / xObjectSize.getWidth());}

    // Scaling.
    double[] matrix = xObject.getMatrix();
    double scaleX, scaleY;
    scaleX = size.getWidth() / (xObjectSize.getWidth() * matrix[0]);
    scaleY = size.getHeight() / (xObjectSize.getHeight() * matrix[3]);

    // Alignment.
View Full Code Here


        */
        Dimension2D imageSize = null; // Image native size.
        if(objectWrapper instanceof ContentScanner.XObjectWrapper)
        {
          ContentScanner.XObjectWrapper xObjectWrapper = (ContentScanner.XObjectWrapper)objectWrapper;
          XObject xObject = xObjectWrapper.getXObject();
          // Is the external object an image?
          if(xObject instanceof ImageXObject)
          {
            System.out.print(
              "External Image '" + xObjectWrapper.getName() + "' (" + xObject.getBaseObject() + ")" // Image key and indirect reference.
              );
            imageSize = xObject.getSize(); // Image native size.
          }
        }
        else if(objectWrapper instanceof ContentScanner.InlineImageWrapper)
        {
          System.out.print("Inline Image");
View Full Code Here

    )
  {
    // 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();
      if(xObjects == null)
        continue;

      for(PdfName xObjectKey : xObjects.keySet())
      {
        XObject xObject = xObjects.get(xObjectKey);
        // Is the page's resource an image?
        if(xObject instanceof ImageXObject)
        {
          System.out.println("Substituting " + xObjectKey + " image xobject.");
          xObjects.put(xObjectKey,imageXObject);
View Full Code Here

    // 2. Instantiate a new PDF file!
    File file = new File();
    Document document = file.getDocument();

    // 3. Convert the first page of the source file into a form inside the new document!
    XObject form = formFile.getDocument().getPages().get(0).toXObject(document);

    // 4. Insert the contents into the new document!
    populate(document,form);

    // (boilerplate metadata insertion -- ignore it)
View Full Code Here

    )
  {
    // Get the abstract barcode entity!
    EAN13Barcode barcode = new EAN13Barcode("8012345678901");
    // Create the reusable barcode within the document!
    XObject barcodeXObject = barcode.toXObject(document);

    Pages pages = document.getPages();
    // Page 1.
    {
      Page page = new Page(document);
View Full Code Here

TOP

Related Classes of org.pdfclown.documents.contents.xObjects.XObject

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.