Index: src/documentation/content/xdocs/trunk/extensions.xml
===================================================================
--- src/documentation/content/xdocs/trunk/extensions.xml	(revision 789330)
+++ src/documentation/content/xdocs/trunk/extensions.xml	(working copy)
@@ -227,7 +227,33 @@
           </p>
         </section>
       </section>
-      
+      <section id="scale">
+        <title>fox:scale</title>
+        <p>
+          <code>fox:scale="sx [sy]"</code> attribute is used in <code>fo:simple-page-master</code> element and specifies
+          the a scale operation by sx and sy. If sy is not provided, it is assumed to be equal to sx.
+          sx and sy should be between 0 and 1.
+        </p>
+        <note>
+          It is implemented for PDF and Java2D renderers.
+        </note>
+      </section>
+      <section id="pageboundaries">
+        <title>fox:crop-box, fox:trim-box and fox:bleed-box</title>
+        <p>
+          The box attributes which specify the CropBox, TrimBox and BleedBox parameters of PDF page.
+          These box attributes of <code>fo:simple-page-master</code> element can consist out of up to 4 numeric values
+          (top, left, width, height) and should have units as suffix to each of the numbers.
+        </p>
+        <p>
+          Examples:
+          <code>fox:trim-box="10pt 10pt 100pt 100pt"</code> would create TrimBox starting in (10pt, 10pt) point with width=100pt and height=100pt.
+          <code>fox:crop-box="5px 5px"</code> would create CropBox starting in (5px, 5px) point with width and height equal of original page minus 5px.
+        </p>
+        <note>
+          They are implemented for PDF renderer, and cropBox in the Java2D renderer.
+        </note>
+      </section>
     </section>
   </body>
 </document>
Index: src/java/org/apache/fop/area/PageViewport.java
===================================================================
--- src/java/org/apache/fop/area/PageViewport.java	(revision 789330)
+++ src/java/org/apache/fop/area/PageViewport.java	(working copy)
@@ -100,6 +100,7 @@
     public PageViewport(SimplePageMaster spm, int pageNumber, String pageStr, boolean blank) {
         this.simplePageMasterName = spm.getMasterName();
         setExtensionAttachments(spm.getExtensionAttachments());
+        setForeignAttributes(spm.getForeignAttributes());
         this.blank = blank;
         int pageWidth = spm.getPageWidth().getValue();
         int pageHeight = spm.getPageHeight().getValue();
@@ -118,6 +119,9 @@
         if (original.extensionAttachments != null) {
             setExtensionAttachments(original.extensionAttachments);
         }
+        if (original.foreignAttributes != null) {
+            setForeignAttributes(original.foreignAttributes);
+        }
         this.pageIndex = original.pageIndex;
         this.pageNumber = original.pageNumber;
         this.pageNumberString = original.pageNumberString;
Index: src/java/org/apache/fop/pdf/PDFFactory.java
===================================================================
--- src/java/org/apache/fop/pdf/PDFFactory.java	(revision 789330)
+++ src/java/org/apache/fop/pdf/PDFFactory.java	(working copy)
@@ -174,6 +174,30 @@
      * PDFDocument later using addObject().
      *
      * @param resources resources object to use
+     * @param pageIndex index of the page (zero-based)
+     * @param mediaBox the MediaBox area
+     * @param cropBox the CropBox area
+     * @param bleedBox the BleedBox area
+     * @param trimBox the TrimBox area
+     *
+     * @return the created /Page object
+     */
+    public PDFPage makePage(PDFResources resources, int pageIndex,
+                            Rectangle2D mediaBox, Rectangle2D cropBox,
+                            Rectangle2D bleedBox, Rectangle2D trimBox) {
+        PDFPage page = new PDFPage(resources, pageIndex, mediaBox, cropBox, bleedBox, trimBox);
+
+        getDocument().assignObjectNumber(page);
+        getDocument().getPages().addPage(page);
+        return page;
+    }
+
+    /**
+     * Make a /Page object. The page is assigned an object number immediately
+     * so references can already be made. The page must be added to the
+     * PDFDocument later using addObject().
+     *
+     * @param resources resources object to use
      * @param pageWidth width of the page in points
      * @param pageHeight height of the page in points
      * @param pageIndex index of the page (zero-based)
Index: src/java/org/apache/fop/pdf/PDFPage.java
===================================================================
--- src/java/org/apache/fop/pdf/PDFPage.java	(revision 789330)
+++ src/java/org/apache/fop/pdf/PDFPage.java	(working copy)
@@ -60,6 +60,28 @@
      * Create a /Page object
      *
      * @param resources the /Resources object
+     * @param pageIndex the page's zero-based index (or -1 if the page number is auto-determined)
+     * @param mediaBox the MediaBox
+     * @param cropBox the CropBox
+     * @param bleedBox the BleedBox
+     * @param trimBox the TrimBox
+     */
+    public PDFPage(PDFResources resources, int pageIndex,
+                   Rectangle2D mediaBox, Rectangle2D cropBox,
+                   Rectangle2D bleedBox, Rectangle2D trimBox) {
+      /* generic creation of object */
+      super(resources);
+
+      put("Type", new PDFName("Page"));
+      /* set fields using parameters */
+      setSimplePageSize(mediaBox, cropBox, bleedBox, trimBox);
+      this.pageIndex = pageIndex;
+    }
+
+    /**
+     * Create a /Page object
+     *
+     * @param resources the /Resources object
      * @param pageWidth the page's width in points
      * @param pageHeight the page's height in points
      * @param pageIndex the page's zero-based index (or -1 if the page number is auto-determined)
@@ -71,41 +93,46 @@
 
     private void setSimplePageSize(int width, int height) {
         Rectangle2D box = new Rectangle2D.Double(0, 0, width, height);
-        setMediaBox(box);
-        setBleedBox(box); //Recommended by PDF/X
-        setTrimBox(box); //Needed for PDF/X
+        setPageBox("MediaBox", box);
+        setPageBox("BleedBox", box); //Recommended by PDF/X
+        setPageBox("TrimBox", box); //Needed for PDF/X
     }
 
+    private void setSimplePageSize(Rectangle2D mediaBox, Rectangle2D cropBox,
+                                   Rectangle2D bleedBox, Rectangle2D trimBox) {
+        setPageBox("MediaBox", mediaBox);
+
+        if (cropBox == null) {
+            cropBox = mediaBox;
+        }
+        setPageBox("CropBox", cropBox);
+
+        if (bleedBox == null) {
+            bleedBox = cropBox;
+        }
+        setPageBox("BleedBox", bleedBox); //Recommended by PDF/X
+      
+        if (trimBox == null) {
+            trimBox = bleedBox;
+        }
+        setPageBox("TrimBox", trimBox); //Needed for PDF/X
+    }
+
     private PDFArray toPDFArray(Rectangle2D box) {
         return new PDFArray(this, new double[] {
                 box.getX(), box.getY(), box.getMaxX(), box.getMaxY()});
     }
 
     /**
-     * Sets the "MediaBox" entry
-     * @param box the media rectangle
+     * Sets the page box entry
+     * @param type the type of page box
+     * @param box the box rectangle
      */
-    public void setMediaBox(Rectangle2D box) {
-        put("MediaBox", toPDFArray(box));
+    public void setPageBox(String type, Rectangle2D box) {
+        put(type, toPDFArray(box));
     }
 
     /**
-     * Sets the "TrimBox" entry
-     * @param box the trim rectangle
-     */
-    public void setTrimBox(Rectangle2D box) {
-        put("TrimBox", toPDFArray(box));
-    }
-
-    /**
-     * Sets the "BleedBox" entry
-     * @param box the bleed rectangle
-     */
-    public void setBleedBox(Rectangle2D box) {
-        put("BleedBox", toPDFArray(box));
-    }
-
-    /**
      * set this page contents
      *
      * @param contents the contents of the page
Index: src/java/org/apache/fop/render/extensions/prepress/PageBoundariesAttributes.java
===================================================================
--- src/java/org/apache/fop/render/extensions/prepress/PageBoundariesAttributes.java	(revision 0)
+++ src/java/org/apache/fop/render/extensions/prepress/PageBoundariesAttributes.java	(revision 0)
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id: PageBoundariesAttributes.java $ */
+
+package org.apache.fop.render.extensions.prepress;
+
+import org.apache.xmlgraphics.util.QName;
+import org.apache.fop.fo.extensions.ExtensionElementMapping;
+import org.apache.fop.fo.properties.FixedLength;
+
+import java.util.regex.Pattern;
+import java.util.regex.Matcher;
+import java.awt.geom.Rectangle2D;
+import java.text.MessageFormat;
+
+
+/**
+ * This class contains definition of page boundaries FOF's extension attributes for XSL-FO.
+ * That is: bleedBox, trimBox and cropBox.
+ * Also this class provides method to parse the possible values of these attibutes
+ * and to generate original size of bounded area
+ */
+public final class PageBoundariesAttributes {
+
+    /**
+     * The extension attribute for the PDF BleedBox area
+     */
+    public static final QName EXT_BLEED_BOX
+            = new QName(ExtensionElementMapping.URI, null, "bleed-box");
+
+    /**
+     * The extension attribute for the PDF TrimBox area
+     */
+    public static final QName EXT_TRIM_BOX
+            = new QName(ExtensionElementMapping.URI, null, "trim-box");
+
+    /**
+     * The extension attribute for the PDF CropBox area
+     */
+    public static final QName EXT_CROP_BOX
+            = new QName(ExtensionElementMapping.URI, null, "crop-box");
+
+    
+    private static final Pattern SIZE_UNIT_PATTERN
+            = Pattern.compile("^(-?\\d*\\.?\\d*)(px|in|cm|mm|pt|pc|mpt)$");
+
+
+    /**
+     * Utility classes should not have a public or default constructor
+     */
+    private PageBoundariesAttributes() {
+    }
+
+
+
+    /**
+     * Calculates the original size of extension box attributes
+     * @param coord  string that contains coordinates of box area,
+     *               format: left [right [ widht [height]]]]
+     * @param bounds the outer area containing given box. The box should be in this area completely
+     * @return the rectangle from the given coordinates, check that it is in the given bounds
+     */
+    public static Rectangle2D getRectangle(String coord, Rectangle2D bounds) {
+        final String err = "Extension box variable has incorrect size values: {0}";
+
+        if (bounds == null) {
+            return null;
+        }
+        // if this box is undefined then we will return the outer box coordinates
+        if (coord == null) {
+            return bounds;
+        }
+
+        String[] tmp = coord.split(" ");
+        double[] dbl = new double[tmp.length];
+        for (int i = 0; i < tmp.length; i++) {
+            Matcher m = SIZE_UNIT_PATTERN.matcher(tmp[i]);
+            if (m.find()) {
+                dbl[i] = FixedLength.getInstance(Double.parseDouble(m.group(1)), m.group(2))
+                        .getLength().getValue();
+            } else {
+                throw new IllegalArgumentException(MessageFormat.format(err, new Object[]{coord}));
+            }
+        }
+        // possbile value: left [right [ widht [height]]]]
+        double x = bounds.getX(); // lower-left corner - X
+        double y = bounds.getY(); // lower-left corner - Y
+        if (dbl.length > 0) {
+            x = Math.max(x, dbl[0]);
+        }
+        if (dbl.length > 1) {
+            y = Math.max(y, dbl[1]);
+        }
+
+        double w = bounds.getMaxX() - x;
+        double h = bounds.getMaxY() - y;
+        if (dbl.length > 2) {
+            if (x + dbl[2] <= bounds.getMaxX()) {
+                w = dbl[2];
+            }
+        }
+        if (dbl.length > 3) {
+            if (y + dbl[3] <= bounds.getMaxY()) {
+                h = dbl[3];
+            }
+        }
+
+        return new Rectangle2D.Double(x, y, w, h);
+    }
+}
Index: src/java/org/apache/fop/render/extensions/prepress/PageScaleAttributes.java
===================================================================
--- src/java/org/apache/fop/render/extensions/prepress/PageScaleAttributes.java	(revision 0)
+++ src/java/org/apache/fop/render/extensions/prepress/PageScaleAttributes.java	(revision 0)
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id: PageScaleAttributes.java $ */
+
+package org.apache.fop.render.extensions.prepress;
+
+import org.apache.xmlgraphics.util.QName;
+import org.apache.fop.fo.extensions.ExtensionElementMapping;
+
+import java.awt.geom.Point2D;
+import java.text.MessageFormat;
+
+
+/**
+ * This class contains definition of 'scale' FOF's extension attribute for XSL-FO, and provides
+ * utility method to parse the possible values of this attibute
+ */
+public final class PageScaleAttributes {
+
+    /**
+     * The extension 'scale' attribute for simple-page-master element
+     */
+    public static final QName EXT_PAGE_SCALE
+            = new QName(ExtensionElementMapping.URI, null, "scale");
+
+
+    /**
+     * Utility classes should not have a public or default constructor
+     */
+    private PageScaleAttributes() {
+    }
+
+    /**
+     * Compute scale parameters from given fox:scale attribute which has format: scaleX [scaleY]
+     * If scaleY is not defined, it equals scaleX
+     * @param scale scale attribute, input format: scaleX [scaleY]
+     * @return the pair of (sx, sy) values
+     */
+    public static Point2D.Double getScaleAttributes(String scale) {
+        final String err = "Extension 'scale' attribute has incorrect value(s): {0}";
+
+        if (scale == null) {
+            return null;
+        }
+
+        Point2D.Double result = null;
+
+        try {
+            String[] scales = scale.split(" ");
+            if (scales.length > 0) {
+                result = new Point2D.Double(Double.parseDouble(scales[0]),
+                        Double.parseDouble(scales[0]));
+            }
+            if (scales.length > 1) {
+                result.y = Double.parseDouble(scales[1]);
+            }
+            if (result.x <= 0 || result.x > 1 || result.y <= 0 || result.y > 1) {
+                throw new IllegalArgumentException(MessageFormat.format(err, new Object[]{scale}));
+            }
+        } catch (NumberFormatException nfe) {
+            throw new IllegalArgumentException(MessageFormat.format(err, new Object[]{scale}));
+        }
+
+        return result;
+    }
+}
Index: src/java/org/apache/fop/render/java2d/Java2DRenderer.java
===================================================================
--- src/java/org/apache/fop/render/java2d/Java2DRenderer.java	(revision 789330)
+++ src/java/org/apache/fop/render/java2d/Java2DRenderer.java	(working copy)
@@ -75,6 +75,8 @@
 import org.apache.fop.render.AbstractPathOrientedRenderer;
 import org.apache.fop.render.Graphics2DAdapter;
 import org.apache.fop.render.RendererContext;
+import org.apache.fop.render.extensions.prepress.PageScaleAttributes;
+import org.apache.fop.render.extensions.prepress.PageBoundariesAttributes;
 import org.apache.fop.render.pdf.CTMHelper;
 import org.apache.fop.util.CharUtilities;
 import org.apache.fop.util.ColorUtil;
@@ -299,11 +301,26 @@
                             + " (pageWidth " + pageWidth + ", pageHeight "
                             + pageHeight + ")");
 
-            double scale = scaleFactor
+            // set scale factor
+            double scaleX = scaleFactor;
+            double scaleY = scaleFactor;
+            String scale = (String) currentPageViewport.getForeignAttributes().get(
+                    PageScaleAttributes.EXT_PAGE_SCALE);
+            Point2D scales = PageScaleAttributes.getScaleAttributes(scale);
+            if (scales != null) {
+                scaleX = scales.getX();
+                scaleY = scales.getY();
+            }
+
+
+            scaleX = scaleX
                 * (25.4f / FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION)
                 / userAgent.getTargetPixelUnitToMillimeter();
-            int bitmapWidth = (int) ((pageWidth * scale) + 0.5);
-            int bitmapHeight = (int) ((pageHeight * scale) + 0.5);
+            scaleY = scaleY
+                * (25.4f / FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION)
+                / userAgent.getTargetPixelUnitToMillimeter();
+            int bitmapWidth = (int) ((pageWidth * scaleX) + 0.5);
+            int bitmapHeight = (int) ((pageHeight * scaleY) + 0.5);
 
 
             BufferedImage currentPageImage = getBufferedImage(bitmapWidth, bitmapHeight);
@@ -326,7 +343,7 @@
 
             // transform page based on scale factor supplied
             AffineTransform at = graphics.getTransform();
-            at.scale(scale, scale);
+            at.scale(scaleX, scaleY);
             graphics.setTransform(at);
 
             // draw page frame
@@ -353,7 +370,17 @@
                 state = null;
             }
 
-            return currentPageImage;
+            // crop the bitmap image using cropBox extension page attribute
+            String crop = (String) currentPageViewport.getForeignAttributes().get(
+                    PageBoundariesAttributes.EXT_CROP_BOX);
+            Rectangle2D cropArea = PageBoundariesAttributes.getRectangle(crop,
+                    currentPageViewport.getViewArea());
+
+            return currentPageImage.getSubimage(
+                    (int) (cropArea.getX() / 1000f * scaleX + 0.5),
+                    (int) (cropArea.getY() / 1000f * scaleY + 0.5),
+                    (int) (cropArea.getWidth() / 1000f * scaleX + 0.5),
+                    (int) (cropArea.getHeight() / 1000f * scaleY + 0.5));
         } finally {
             this.currentPageViewport = null;
         }
Index: src/java/org/apache/fop/render/pdf/PDFDocumentHandler.java
===================================================================
--- src/java/org/apache/fop/render/pdf/PDFDocumentHandler.java	(revision 789330)
+++ src/java/org/apache/fop/render/pdf/PDFDocumentHandler.java	(working copy)
@@ -21,6 +21,8 @@
 
 import java.awt.Dimension;
 import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+import java.awt.geom.Point2D;
 import java.io.IOException;
 import java.util.Map;
 
@@ -31,6 +33,7 @@
 
 import org.apache.fop.apps.MimeConstants;
 import org.apache.fop.fo.extensions.xmp.XMPMetadata;
+import org.apache.fop.fo.extensions.ExtensionElementMapping;
 import org.apache.fop.pdf.PDFAnnotList;
 import org.apache.fop.pdf.PDFDocument;
 import org.apache.fop.pdf.PDFPage;
@@ -43,6 +46,8 @@
 import org.apache.fop.render.intermediate.IFDocumentNavigationHandler;
 import org.apache.fop.render.intermediate.IFException;
 import org.apache.fop.render.intermediate.IFPainter;
+import org.apache.fop.render.extensions.prepress.PageBoundariesAttributes;
+import org.apache.fop.render.extensions.prepress.PageScaleAttributes;
 
 /**
  * {@code IFDocumentHandler} implementation that produces PDF.
@@ -166,11 +171,49 @@
                 throws IFException {
         this.pdfResources = this.pdfDoc.getResources();
 
+        String crop = (String) getContext().getForeignAttribute(
+                PageBoundariesAttributes.EXT_CROP_BOX);
+        String bleed = (String) getContext().getForeignAttribute(
+                PageBoundariesAttributes.EXT_BLEED_BOX);
+        String trim = (String) getContext().getForeignAttribute(
+                PageBoundariesAttributes.EXT_TRIM_BOX);
+        // make sure that CropBox in the MediaBox
+        Rectangle2D cropBox = PageBoundariesAttributes.getRectangle(crop,
+                new Rectangle2D.Double(0, 0, size.getWidth(), size.getHeight()));
+        // make sure that BleedBox in the CropBox
+        Rectangle2D bleedBox = PageBoundariesAttributes.getRectangle(bleed, cropBox);
+        // make sure that TrimBox in the BleedBox
+        Rectangle2D trimBox = PageBoundariesAttributes.getRectangle(trim, bleedBox);
+
+        // set scale attributes
+        double scaleX = 1;
+        double scaleY = 1;
+        String scale = (String) getContext().getForeignAttribute(
+                PageScaleAttributes.EXT_PAGE_SCALE);
+        Point2D scales = PageScaleAttributes.getScaleAttributes(scale);
+        if (scales != null) {
+            scaleX = scales.getX();
+            scaleY = scales.getY();
+        }
+
         this.currentPage = this.pdfDoc.getFactory().makePage(
             this.pdfResources,
-            (int)Math.round(size.getWidth() / 1000),
-            (int)Math.round(size.getHeight() / 1000),
-            index);
+            index,
+            new Rectangle2D.Double(0, 0,
+                    (scaleX * size.getWidth()) / 1000,
+                    (scaleY * size.getHeight()) / 1000),
+            new Rectangle2D.Double((scaleX * cropBox.getX()) / 1000,
+                    (scaleY * cropBox.getY()) / 1000,
+                    (scaleX * cropBox.getWidth()) / 1000,
+                    (scaleY * cropBox.getHeight()) / 1000),
+            new Rectangle2D.Double((scaleX * bleedBox.getX()) / 1000,
+                    (scaleY * bleedBox.getY()) / 1000,
+                    (scaleX * bleedBox.getWidth()) / 1000,
+                    (scaleY * bleedBox.getHeight()) / 1000),
+            new Rectangle2D.Double((scaleX * trimBox.getX()) / 1000,
+                    (scaleY * trimBox.getY()) / 1000,
+                    (scaleX * trimBox.getWidth()) / 1000,
+                    (scaleY * trimBox.getHeight()) / 1000));
         //pageReferences.put(new Integer(index)/*page.getKey()*/, currentPage.referencePDF());
         //pvReferences.put(page.getKey(), page);
 
@@ -182,7 +225,8 @@
         this.generator = new PDFContentGenerator(this.pdfDoc, this.outputStream, this.currentPage);
         // Transform the PDF's default coordinate system (0,0 at lower left) to the PDFPainter's
         AffineTransform basicPageTransform = new AffineTransform(1, 0, 0, -1, 0,
-                size.height / 1000f);
+                (scaleY * size.height) / 1000f);
+        basicPageTransform.scale(scaleX, scaleY);
         generator.concatenate(basicPageTransform);
     }
 
Index: test/java/org/apache/fop/render/extensions/PrepressTest.java
===================================================================
--- test/java/org/apache/fop/render/extensions/PrepressTest.java	(revision 0)
+++ test/java/org/apache/fop/render/extensions/PrepressTest.java	(revision 0)
@@ -0,0 +1,96 @@
+package org.apache.fop.render.extensions;
+
+import junit.framework.TestCase;
+import org.apache.fop.render.extensions.prepress.PageScaleAttributes;
+import org.apache.fop.render.extensions.prepress.PageBoundariesAttributes;
+
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+
+/**
+ * Base class for automated tests for
+ * {@link org.apache.fop.render.extensions.prepress.PageBoundariesAttributes}
+ * and
+ * {@link org.apache.fop.render.extensions.prepress.PageScaleAttributes}
+ */
+public class PrepressTest extends TestCase {
+
+    private static final Rectangle2D TEST_AREA = new Rectangle2D.Double(0, 0, 800, 800);
+
+    /**
+     * Main constructor
+     * @param name the name of the test case
+     */
+    public PrepressTest(String name) {
+        super(name);
+    }
+
+
+    /**
+     * Tests for 'scale' extension attribute
+     */
+    public void testScaleOk() throws Exception {
+        Point2D res = PageScaleAttributes.getScaleAttributes("0.5");
+        assertEquals("Points should be equal", res.getX(), res.getY(), 0);
+    }
+
+    public void testScaleFailIllArgExc() throws Exception {
+        try {
+            Point2D res = PageScaleAttributes.getScaleAttributes("0.5mm 0.5cm");
+            fail("Expected IllegalArgumentException. Scale shouldn't contain units");
+        } catch (IllegalArgumentException iae) {
+            // Good!
+        }
+    }
+
+    public void testScaleNotEqual() throws Exception {
+        Point2D res = PageScaleAttributes.getScaleAttributes("0.5 0.6");
+        assertFalse("Points shouldn't be equal", res.getX() == res.getY());
+    }
+
+    public void testScaleNull() throws Exception {
+        Point2D res = PageScaleAttributes.getScaleAttributes(null);
+        assertNull("Result shouldn't be null", res);
+    }
+
+
+    /**
+     * Tests for page boundaries
+     */
+    public void testBoxOk1() throws Exception {
+        Rectangle2D res = PageBoundariesAttributes.getRectangle(null, TEST_AREA);
+        assertSame("Result shouldn't be the same as TEST_AREA object", res, TEST_AREA);
+        
+        res = PageBoundariesAttributes.getRectangle("asdfasfdsf", null);
+        assertNull(res);
+    }
+
+    public void testBoxOk2() throws Exception {
+        Rectangle2D res = PageBoundariesAttributes.getRectangle("-10pt", TEST_AREA);
+        assertEquals("Expected equal objects", res, TEST_AREA);
+    }
+
+    public void testBoxOk3() throws Exception {
+        Rectangle2D res = PageBoundariesAttributes.getRectangle("-10pt -10pt", TEST_AREA);
+        assertEquals("Expected equal objects", res, TEST_AREA);
+    }
+
+    public void testBoxOk4() throws Exception {
+        Rectangle2D res = PageBoundariesAttributes.getRectangle("0pt 0pt 100000pt", TEST_AREA);
+        assertEquals("Expected equal objects", res, TEST_AREA);
+    }
+
+    public void testBoxOk5() throws Exception {
+        Rectangle2D res = PageBoundariesAttributes.getRectangle("-1pt -1pt 100000pt 100000pt", TEST_AREA);
+        assertEquals("Expected equal objects", res, TEST_AREA);
+    }
+
+    public void testBoxIllArgExc() throws Exception {
+        try {
+            Rectangle2D res = PageBoundariesAttributes.getRectangle("0", TEST_AREA);
+            fail("Expected IllegalArgumentException. Box should have units");
+        } catch (IllegalArgumentException iae) {
+            // Good!
+        }
+    }
+}
Index: test/java/org/apache/fop/StandardTestSuite.java
===================================================================
--- test/java/org/apache/fop/StandardTestSuite.java	(revision 787039)
+++ test/java/org/apache/fop/StandardTestSuite.java	(working copy)
@@ -31,6 +31,7 @@
 import org.apache.fop.render.pdf.PDFEncodingTestCase;
 import org.apache.fop.render.pdf.PDFsRGBSettingsTestCase;
 import org.apache.fop.render.rtf.RichTextFormatTestSuite;
+import org.apache.fop.render.extensions.PrepressTest;
 
 /**
  * Test suite for basic functionality of FOP.
@@ -56,6 +57,7 @@
         suite.addTest(new TestSuite(ImageLoaderTestCase.class));
         suite.addTest(new TestSuite(ImagePreloaderTestCase.class));
         suite.addTest(new TestSuite(IFMimickingTestCase.class));
+        suite.addTest(new TestSuite(PrepressTest.class));
         //$JUnit-END$
         return suite;
     }
