diff options
Diffstat (limited to 'test')
5 files changed, 634 insertions, 0 deletions
diff --git a/test/java/org/apache/fop/render/ps/AbstractPostScriptTestCase.java b/test/java/org/apache/fop/render/ps/AbstractPostScriptTestCase.java new file mode 100644 index 000000000..522d193ed --- /dev/null +++ b/test/java/org/apache/fop/render/ps/AbstractPostScriptTestCase.java @@ -0,0 +1,139 @@ +/* + * 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$ */ + +package org.apache.fop.render.ps; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.MissingResourceException; + +import javax.xml.transform.Source; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.sax.SAXResult; +import javax.xml.transform.stream.StreamSource; + +import junit.framework.TestCase; + +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; + +import org.apache.xmlgraphics.ps.PSResource; +import org.apache.xmlgraphics.ps.dsc.DSCException; +import org.apache.xmlgraphics.ps.dsc.DSCParser; +import org.apache.xmlgraphics.ps.dsc.events.AbstractResourceDSCComment; +import org.apache.xmlgraphics.ps.dsc.events.DSCComment; +import org.apache.xmlgraphics.ps.dsc.events.DSCEvent; + +import org.apache.fop.apps.FOUserAgent; +import org.apache.fop.apps.Fop; +import org.apache.fop.apps.FopFactory; +import org.apache.fop.apps.MimeConstants; + +/** + * Abstract base class for PostScript verification tests. + */ +public abstract class AbstractPostScriptTestCase extends TestCase { + + /** the JAXP TransformerFactory */ + protected TransformerFactory tFactory = TransformerFactory.newInstance(); + /** the FopFactory */ + protected FopFactory fopFactory = FopFactory.newInstance(); + + /** + * Renders a test file. + * @param ua the user agent (with override set!) + * @param resourceName the resource name for the FO file + * @param suffix a suffix for the output filename + * @return the output file + * @throws Exception if an error occurs + */ + protected File renderFile(FOUserAgent ua, String resourceName, String suffix) + throws Exception { + File outputFile = new File("build/test-results/" + resourceName + suffix + ".ps"); + File outputDir = outputFile.getParentFile(); + FileUtils.forceMkdir(outputDir); + + // Prepare input file + InputStream in = getClass().getResourceAsStream(resourceName); + if (in == null) { + throw new MissingResourceException(resourceName + " not found in resources", + getClass().getName(), null); + } + try { + Source src = new StreamSource(in); + + // Create PostScript + OutputStream out = new java.io.FileOutputStream(outputFile); + out = new java.io.BufferedOutputStream(out); + try { + Fop fop = fopFactory.newFop(MimeConstants.MIME_POSTSCRIPT, ua, out); + SAXResult res = new SAXResult(fop.getDefaultHandler()); + + Transformer transformer = tFactory.newTransformer(); + transformer.transform(src, res); + } finally { + IOUtils.closeQuietly(out); + } + } finally { + IOUtils.closeQuietly(in); + } + return outputFile; + } + + /** + * Scans for a certain resource DSC comment and checks against a given resource. + * @param parser the DSC parser + * @param comment the comment to scan for + * @param resource the resource to check against + * @throws IOException if an I/O error occurs + * @throws DSCException if a DSC error occurs + */ + protected void checkResourceComment(DSCParser parser, String comment, PSResource resource) + throws IOException, DSCException { + AbstractResourceDSCComment resComment; + resComment = (AbstractResourceDSCComment)gotoDSCComment(parser, comment); + assertEquals(resource, resComment.getResource()); + } + + /** + * Advances the DSC parser to a DSC comment with the given name. + * @param parser the DSC parser + * @param name the name of the DSC comment + * @return the DSC comment + * @throws IOException if an I/O error occurs + * @throws DSCException if a DSC error occurs + */ + protected static DSCComment gotoDSCComment(DSCParser parser, String name) + throws IOException, DSCException { + while (parser.hasNext()) { + DSCEvent event = parser.nextEvent(); + if (event.isDSCComment()) { + DSCComment comment = event.asDSCComment(); + if (comment.getName().equals(name)) { + return comment; + } + } + } + return null; + } + +} diff --git a/test/java/org/apache/fop/render/ps/ImageHandlingTestCase.java b/test/java/org/apache/fop/render/ps/ImageHandlingTestCase.java new file mode 100644 index 000000000..51c4dc301 --- /dev/null +++ b/test/java/org/apache/fop/render/ps/ImageHandlingTestCase.java @@ -0,0 +1,188 @@ +/* + * 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$ */ + +package org.apache.fop.render.ps; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; + +import org.apache.commons.io.IOUtils; + +import org.apache.xmlgraphics.ps.DSCConstants; +import org.apache.xmlgraphics.ps.PSResource; +import org.apache.xmlgraphics.ps.dsc.DSCException; +import org.apache.xmlgraphics.ps.dsc.DSCParser; +import org.apache.xmlgraphics.ps.dsc.events.DSCCommentPage; +import org.apache.xmlgraphics.ps.dsc.events.DSCCommentPages; +import org.apache.xmlgraphics.ps.dsc.events.DSCCommentTitle; +import org.apache.xmlgraphics.ps.dsc.events.DSCEvent; + +import org.apache.fop.apps.FOUserAgent; + +/** + * Tests the image handling in PostScript output. + */ +public class ImageHandlingTestCase extends AbstractPostScriptTestCase { + + /** + * Tests JPEG handling with the {@link PSRenderer}. + * @throws Exception if an error occurs + */ + public void testJPEGImageWithRendererLevel3() throws Exception { + innerTestJPEGImageWithRenderer(3); + } + + /** + * Tests JPEG handling with the {@link PSRenderer}. + * @throws Exception if an error occurs + */ + public void testJPEGImageWithRendererLevel2() throws Exception { + innerTestJPEGImageWithRenderer(2); + } + + /** + * Tests JPEG handling with the {@link PSDocumentHandler}. + * @throws Exception if an error occurs + */ + public void testJPEGImageWithIFLevel3() throws Exception { + innerTestJPEGImageWithIF(3); + } + + /** + * Tests JPEG handling with the {@link PSDocumentHandler}. + * @throws Exception if an error occurs + */ + public void testJPEGImageWithIFLevel2() throws Exception { + innerTestJPEGImageWithIF(2); + } + + private void innerTestJPEGImageWithRenderer(int level) throws Exception { + FOUserAgent ua = fopFactory.newFOUserAgent(); + PSRenderer renderer = new PSRenderer(); + renderer.setUserAgent(ua); + PSRenderingUtil psUtil = renderer.getPSUtil(); + psUtil.setLanguageLevel(level); + psUtil.setOptimizeResources(true); + ua.setRendererOverride(renderer); + + // Prepare output file + File outputFile = renderFile(ua, "ps-jpeg-image.fo", "-rend-l" + psUtil.getLanguageLevel()); + verifyPostScriptFile(outputFile, psUtil.getLanguageLevel()); + } + + private void innerTestJPEGImageWithIF(int level) throws Exception { + FOUserAgent ua = fopFactory.newFOUserAgent(); + PSDocumentHandler handler = new PSDocumentHandler(); + handler.setUserAgent(ua); + PSRenderingUtil psUtil = handler.getPSUtil(); + psUtil.setLanguageLevel(level); + psUtil.setOptimizeResources(true); + ua.setDocumentHandlerOverride(handler); + + // Prepare output file + File outputFile = renderFile(ua, "ps-jpeg-image.fo", "-if-l" + psUtil.getLanguageLevel()); + verifyPostScriptFile(outputFile, psUtil.getLanguageLevel()); + } + + private void verifyPostScriptFile(File psFile, int level) + throws IOException, DSCException { + InputStream in = new java.io.FileInputStream(psFile); + in = new java.io.BufferedInputStream(in); + try { + DSCParser parser = new DSCParser(in); + + DSCCommentPages pages = (DSCCommentPages)gotoDSCComment(parser, DSCConstants.PAGES); + assertEquals(1, pages.getPageCount()); + + //Skip procsets and encoding + gotoDSCComment(parser, DSCConstants.BEGIN_RESOURCE); + gotoDSCComment(parser, DSCConstants.BEGIN_RESOURCE); + gotoDSCComment(parser, DSCConstants.BEGIN_RESOURCE); + + PSResource form2 = new PSResource(PSResource.TYPE_FORM, "FOPForm:2"); + checkResourceComment(parser, DSCConstants.BEGIN_RESOURCE, form2); + DSCCommentTitle title = (DSCCommentTitle)parser.nextEvent().asDSCComment(); + assertEquals("image/jpeg test/resources/images/bgimg300dpi.jpg", title.getTitle()); + + String resourceContent = getResourceContent(parser); + + if (level == 3) { + assertContains(resourceContent, "/FOPForm:2"); + assertContains(resourceContent, "/DCTDecode filter"); + assertContains(resourceContent, "/ReusableStreamDecode filter"); + } else { + assertContains(resourceContent, "/FOPForm:2"); + assertContains(resourceContent, "/DCTDecode filter"); + assertAbsent(resourceContent, "/ReusableStreamDecode filter"); + } + + //---=== Page 1 ===--- + DSCCommentPage page = (DSCCommentPage)gotoDSCComment(parser, DSCConstants.PAGE); + assertEquals(1, page.getPagePosition()); + + PSResource form1 = new PSResource(PSResource.TYPE_FORM, "FOPForm:1"); + checkResourceComment(parser, DSCConstants.BEGIN_RESOURCE, form1); + title = (DSCCommentTitle)parser.nextEvent().asDSCComment(); + assertEquals("image/jpeg test/resources/images/bgimg72dpi.jpg", title.getTitle()); + resourceContent = getResourceContent(parser); + + if (level == 3) { + assertContains(resourceContent, "/FOPForm:1"); + assertContains(resourceContent, "/DCTDecode filter"); + assertContains(resourceContent, "/ReusableStreamDecode filter"); + } else { + assertContains(resourceContent, "/FOPForm:1"); + assertContains(resourceContent, "/DCTDecode filter"); + assertAbsent(resourceContent, "/ReusableStreamDecode filter"); + } + + } finally { + IOUtils.closeQuietly(in); + } + } + + private void assertMatches(String text, String regex) { + assertTrue("Text didn't match '" + regex + "'", text.matches(regex)); + } + + private void assertContains(String text, String searchString) { + assertTrue("Text doesn't contain '" + searchString + "'", text.indexOf(searchString) >= 0); + } + + private void assertAbsent(String text, String searchString) { + assertTrue("Text contains '" + searchString + "'", text.indexOf(searchString) < 0); + } + + private String getResourceContent(DSCParser parser) throws IOException, DSCException { + StringBuffer sb = new StringBuffer(); + while (parser.hasNext()) { + DSCEvent event = parser.nextEvent(); + if (event.isLine()) { + sb.append(event.asLine().getLine()).append('\n'); + } else if (event.isDSCComment()) { + if (DSCConstants.END_RESOURCE.equals(event.asDSCComment().getName())) { + break; + } + } + } + return sb.toString(); + } + +} diff --git a/test/java/org/apache/fop/render/ps/ResourceOptimizationTestCase.java b/test/java/org/apache/fop/render/ps/ResourceOptimizationTestCase.java new file mode 100644 index 000000000..ace96e85d --- /dev/null +++ b/test/java/org/apache/fop/render/ps/ResourceOptimizationTestCase.java @@ -0,0 +1,222 @@ +/* + * 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$ */ + +package org.apache.fop.render.ps; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.util.Arrays; +import java.util.Collection; +import java.util.Set; + +import org.apache.commons.io.IOUtils; + +import org.apache.xmlgraphics.ps.DSCConstants; +import org.apache.xmlgraphics.ps.PSResource; +import org.apache.xmlgraphics.ps.dsc.DSCException; +import org.apache.xmlgraphics.ps.dsc.DSCListener; +import org.apache.xmlgraphics.ps.dsc.DSCParser; +import org.apache.xmlgraphics.ps.dsc.DefaultNestedDocumentHandler; +import org.apache.xmlgraphics.ps.dsc.events.AbstractResourcesDSCComment; +import org.apache.xmlgraphics.ps.dsc.events.DSCAtend; +import org.apache.xmlgraphics.ps.dsc.events.DSCCommentBeginDocument; +import org.apache.xmlgraphics.ps.dsc.events.DSCCommentDocumentNeededResources; +import org.apache.xmlgraphics.ps.dsc.events.DSCCommentDocumentSuppliedResources; +import org.apache.xmlgraphics.ps.dsc.events.DSCCommentEndOfFile; +import org.apache.xmlgraphics.ps.dsc.events.DSCCommentIncludeResource; +import org.apache.xmlgraphics.ps.dsc.events.DSCCommentPage; +import org.apache.xmlgraphics.ps.dsc.events.DSCCommentPages; + +import org.apache.fop.apps.FOUserAgent; + +/** + * Tests the PostScript resource optimization (selective de-duplication of + * images that are used multiple times). + */ +public class ResourceOptimizationTestCase extends AbstractPostScriptTestCase { + + /** + * Tests resource optimization with the {@link PSRenderer}. + * @throws Exception if an error occurs + */ + public void testResourceOptimizationWithRenderer() throws Exception { + FOUserAgent ua = fopFactory.newFOUserAgent(); + PSRenderer renderer = new PSRenderer(); + renderer.setUserAgent(ua); + // This is the important part: we're enabling resource optimization + renderer.getPSUtil().setOptimizeResources(true); + ua.setRendererOverride(renderer); + + // Prepare output file + File outputFile = renderFile(ua, "ps-resources.fo", + "-rend-l" + renderer.getPSUtil().getLanguageLevel()); + verifyPostScriptFile(outputFile); + } + + /** + * Tests resource optimization with the {@link PSDocumentHandler}. + * @throws Exception if an error occurs + */ + public void testResourceOptimizationWithIF() throws Exception { + FOUserAgent ua = fopFactory.newFOUserAgent(); + PSDocumentHandler handler = new PSDocumentHandler(); + handler.setUserAgent(ua); + // This is the important part: we're enabling resource optimization + handler.getPSUtil().setOptimizeResources(true); + ua.setDocumentHandlerOverride(handler); + + // Prepare output file + File outputFile = renderFile(ua, "ps-resources.fo", + "-if-l" + handler.getPSUtil().getLanguageLevel()); + verifyPostScriptFile(outputFile); + } + + private void verifyPostScriptFile(File psFile) throws IOException, DSCException { + InputStream in = new java.io.FileInputStream(psFile); + in = new java.io.BufferedInputStream(in); + try { + DSCParser parser = new DSCParser(in); + + //The first form is for arrow_down_small.png (to be reused) + PSResource form1 = new PSResource(PSResource.TYPE_FORM, "FOPForm:1"); + PSResource helvetica = new PSResource(PSResource.TYPE_FONT, "Helvetica"); + PSResource helveticaBold = new PSResource(PSResource.TYPE_FONT, "Helvetica-Bold"); + + PSResource res; + DSCCommentPages pages = (DSCCommentPages)gotoDSCComment(parser, DSCConstants.PAGES); + assertEquals(2, pages.getPageCount()); + + DSCCommentDocumentSuppliedResources supplied + = (DSCCommentDocumentSuppliedResources)gotoDSCComment(parser, + DSCConstants.DOCUMENT_SUPPLIED_RESOURCES); + Set resources = supplied.getResources(); + assertEquals(4, resources.size()); + assertTrue(resources.contains(form1)); + assertTrue("Expected barcode.eps as supplied resource", + resources.contains(new PSResource(PSResource.TYPE_FILE, + "test/resources/images/barcode.eps"))); + + DSCCommentDocumentNeededResources needed + = (DSCCommentDocumentNeededResources)gotoDSCComment(parser, + DSCConstants.DOCUMENT_NEEDED_RESOURCES); + resources = needed.getResources(); + assertEquals(2, resources.size()); + assertTrue("Expected Helvetica as needed resource", + resources.contains(new PSResource(PSResource.TYPE_FONT, "Helvetica"))); + assertTrue("Expected Helvetica-Bold as needed resource", + resources.contains(new PSResource(PSResource.TYPE_FONT, "Helvetica-Bold"))); + + //Some document structure checking + assertNotNull(gotoDSCComment(parser, DSCConstants.BEGIN_DEFAULTS)); + assertNotNull(gotoDSCComment(parser, DSCConstants.END_DEFAULTS)); + assertNotNull(gotoDSCComment(parser, DSCConstants.BEGIN_PROLOG)); + assertNotNull(gotoDSCComment(parser, DSCConstants.END_PROLOG)); + assertNotNull(gotoDSCComment(parser, DSCConstants.BEGIN_SETUP)); + + //Check includes for the two referenced base 14 fonts + DSCCommentIncludeResource include; + Collection strings = new java.util.HashSet( + Arrays.asList(new String[] {"Helvetica", "Helvetica-Bold"})); + for (int i = 0; i < 2; i++) { + include = (DSCCommentIncludeResource)gotoDSCComment( + parser, DSCConstants.INCLUDE_RESOURCE); + res = include.getResource(); + assertEquals(PSResource.TYPE_FONT, res.getType()); + strings.remove(res.getName()); + } + assertEquals(0, strings.size()); + + checkResourceComment(parser, DSCConstants.BEGIN_RESOURCE, + new PSResource(PSResource.TYPE_ENCODING, "WinAnsiEncoding")); + + //Here, we encounter form 1 again + checkResourceComment(parser, DSCConstants.BEGIN_RESOURCE, form1); + + assertNotNull(gotoDSCComment(parser, DSCConstants.END_SETUP)); + //Now the actual pages begin + + //---=== Page 1 ===--- + DSCCommentPage page = (DSCCommentPage)gotoDSCComment(parser, DSCConstants.PAGE); + assertEquals(1, page.getPagePosition()); + + assertEquals(DSCAtend.class, + gotoDSCComment(parser, DSCConstants.PAGE_RESOURCES).getClass()); + assertNotNull(gotoDSCComment(parser, DSCConstants.BEGIN_PAGE_SETUP)); + assertNotNull(gotoDSCComment(parser, DSCConstants.END_PAGE_SETUP)); + + PSResource form2 = new PSResource(PSResource.TYPE_FORM, "FOPForm:2"); + checkResourceComment(parser, DSCConstants.BEGIN_RESOURCE, form2); + assertNotNull(gotoDSCComment(parser, DSCConstants.PAGE_TRAILER)); + + AbstractResourcesDSCComment pageResources; + pageResources = (AbstractResourcesDSCComment)gotoDSCComment( + parser, DSCConstants.PAGE_RESOURCES); + resources = pageResources.getResources(); + assertEquals(5, resources.size()); + assertTrue(resources.contains(form1)); + assertTrue(resources.contains(form2)); + assertTrue(resources.contains(helvetica)); + assertTrue(resources.contains(helveticaBold)); + + //---=== Page 2 ===--- + page = (DSCCommentPage)gotoDSCComment(parser, DSCConstants.PAGE); + assertEquals(2, page.getPagePosition()); + + assertEquals(DSCAtend.class, + gotoDSCComment(parser, DSCConstants.PAGE_RESOURCES).getClass()); + assertNotNull(gotoDSCComment(parser, DSCConstants.BEGIN_PAGE_SETUP)); + assertNotNull(gotoDSCComment(parser, DSCConstants.END_PAGE_SETUP)); + + DSCCommentBeginDocument beginDocument; + beginDocument = (DSCCommentBeginDocument)gotoDSCComment( + parser, DSCConstants.BEGIN_DOCUMENT); + assertEquals("test/resources/images/barcode.eps", + beginDocument.getResource().getName()); + DSCListener listener = new DefaultNestedDocumentHandler(null); + listener.processEvent(beginDocument, parser); + + //And again (the barcode is generated twice) + beginDocument = (DSCCommentBeginDocument)gotoDSCComment( + parser, DSCConstants.BEGIN_DOCUMENT); + assertEquals("test/resources/images/barcode.eps", + beginDocument.getResource().getName()); + listener.processEvent(beginDocument, parser); + + assertNotNull(gotoDSCComment(parser, DSCConstants.PAGE_TRAILER)); + pageResources = (AbstractResourcesDSCComment)gotoDSCComment( + parser, DSCConstants.PAGE_RESOURCES); + resources = pageResources.getResources(); + assertEquals(6, resources.size()); + assertTrue(resources.contains(form1)); + assertFalse(resources.contains(form2)); + assertTrue(resources.contains(helvetica)); + assertTrue(resources.contains(helveticaBold)); + assertTrue(resources.contains(beginDocument.getResource())); + + assertNotNull(gotoDSCComment(parser, DSCConstants.TRAILER)); + //No headers in between, as they should have been put at the beginning of the file + assertEquals(DSCCommentEndOfFile.class, parser.nextEvent().asDSCComment().getClass()); + + } finally { + IOUtils.closeQuietly(in); + } + } + +} diff --git a/test/java/org/apache/fop/render/ps/ps-jpeg-image.fo b/test/java/org/apache/fop/render/ps/ps-jpeg-image.fo new file mode 100644 index 000000000..50ed2d6e4 --- /dev/null +++ b/test/java/org/apache/fop/render/ps/ps-jpeg-image.fo @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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$ --> +<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> + <fo:layout-master-set> + <fo:simple-page-master master-name="A4" page-height="29.7cm" page-width="21cm" margin="2cm"> + <fo:region-body/> + </fo:simple-page-master> + </fo:layout-master-set> + <fo:page-sequence master-reference="A4"> + <fo:flow flow-name="xsl-region-body"> + <fo:block>JPEG image:</fo:block> + <fo:block><fo:external-graphic src="test/resources/images/bgimg72dpi.jpg"/></fo:block> + <fo:block> + <fo:external-graphic src="test/resources/images/bgimg300dpi.jpg"/> + <fo:external-graphic src="test/resources/images/bgimg300dpi.jpg"/> + </fo:block> + </fo:flow> + </fo:page-sequence> +</fo:root> diff --git a/test/java/org/apache/fop/render/ps/ps-resources.fo b/test/java/org/apache/fop/render/ps/ps-resources.fo new file mode 100644 index 000000000..7982d35bd --- /dev/null +++ b/test/java/org/apache/fop/render/ps/ps-resources.fo @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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$ --> +<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> + <fo:layout-master-set> + <fo:simple-page-master master-name="A4" page-height="29.7cm" page-width="21cm" margin="2cm"> + <fo:region-body/> + </fo:simple-page-master> + </fo:layout-master-set> + <fo:page-sequence master-reference="A4"> + <fo:flow flow-name="xsl-region-body"> + <fo:block font-weight="bold">PostScript Resource Optimization Test</fo:block> + <fo:block>Used again later:</fo:block> + <fo:block><fo:external-graphic src="test/resources/images/arrow_down_small.png"/></fo:block> + <fo:block>Used only once in the whole document:</fo:block> + <fo:block><fo:external-graphic src="test/resources/images/arrow_up_small.png"/></fo:block> + </fo:flow> + </fo:page-sequence> + <fo:page-sequence master-reference="A4"> + <fo:flow flow-name="xsl-region-body"> + <fo:block font-weight="bold">PostScript Resource Optimization Test</fo:block> + <fo:block>Image already used in previous page-sequence:</fo:block> + <fo:block> + <fo:external-graphic src="test/resources/images/arrow_down_small.png" content-width="80%"/> + <fo:external-graphic src="test/resources/images/arrow_down_small.png"/> + <fo:external-graphic src="test/resources/images/arrow_down_small.png" content-width="120%"/> + </fo:block> + <fo:block>Can't currently reuse EPS images:</fo:block> + <fo:block> + <fo:external-graphic src="test/resources/images/barcode.eps"/> + <fo:external-graphic src="test/resources/images/barcode.eps"/> + </fo:block> + </fo:flow> + </fo:page-sequence> +</fo:root> |