diff options
author | Karen Lease <klease@apache.org> | 2002-02-23 16:48:59 +0000 |
---|---|---|
committer | Karen Lease <klease@apache.org> | 2002-02-23 16:48:59 +0000 |
commit | a007e39924f89ff45a9905c2a714712bd4cde732 (patch) | |
tree | c24671cb27e8efc87fc6e3ff5d9a1be4abb2b0c2 /src/org/apache | |
parent | 4a9677a4032f4a32e38dbd492cc99f70fae79a27 (diff) | |
download | xmlgraphics-fop-a007e39924f89ff45a9905c2a714712bd4cde732.tar.gz xmlgraphics-fop-a007e39924f89ff45a9905c2a714712bd4cde732.zip |
Take CTM into account for PDF rendering (small test)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194668 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/org/apache')
-rw-r--r-- | src/org/apache/fop/render/AbstractRenderer.java | 13 | ||||
-rw-r--r-- | src/org/apache/fop/render/pdf/PDFRenderer.java | 39 |
2 files changed, 46 insertions, 6 deletions
diff --git a/src/org/apache/fop/render/AbstractRenderer.java b/src/org/apache/fop/render/AbstractRenderer.java index 4d6584b38..bfcf41f75 100644 --- a/src/org/apache/fop/render/AbstractRenderer.java +++ b/src/org/apache/fop/render/AbstractRenderer.java @@ -134,19 +134,28 @@ public abstract class AbstractRenderer implements Renderer { protected void renderRegionViewport(RegionViewport port) { if (port != null) { Rectangle2D view = port.getViewArea(); - currentBPPosition = (int) (view.getY() / 1000); - currentIPPosition = (int) (view.getX() / 1000); + // The CTM will transform coordinates relative to + // this region-reference area into page coords, so + // set origin for the region to 0,0. + currentBPPosition = 0; // (int) (view.getY() / 1000); + currentIPPosition = 0; // (int) (view.getX() / 1000); currentBlockIPPosition = currentIPPosition; RegionReference region = port.getRegion(); + startVParea(region.getCTM()); if (region.getRegionClass() == Region.BODY) { renderBodyRegion((BodyRegion) region); } else { renderRegion(region); } + endVParea(); } } + protected void startVParea(CTM ctm) { } + + protected void endVParea() { } + protected void renderRegion(RegionReference region) { List blocks = region.getBlocks(); diff --git a/src/org/apache/fop/render/pdf/PDFRenderer.java b/src/org/apache/fop/render/pdf/PDFRenderer.java index a8ba5ad93..ea6a579e5 100644 --- a/src/org/apache/fop/render/pdf/PDFRenderer.java +++ b/src/org/apache/fop/render/pdf/PDFRenderer.java @@ -204,18 +204,48 @@ public class PDFRenderer extends PrintRenderer { pageReferences.put(page, currentPage.referencePDF()); } currentStream = this.pdfDoc.makeStream(); - currentStream.add("BT\n"); + // Transform origin at top left to origin at bottom left + currentStream.add("1 0 0 -1 0 " + + (int) Math.round(pageHeight / 1000) + " cm\n"); + //currentStream.add("BT\n"); Page p = page.getPage(); renderPageAreas(p); - currentStream.add("ET\n"); + //currentStream.add("ET\n"); currentPage.setContents(currentStream); this.pdfDoc.addPage(currentPage); this.pdfDoc.output(ostream); } + + protected void startVParea(CTM ctm) { + // Set the given CTM in the graphics state + currentStream.add("q\n"); + // multiply with current CTM + currentStream.add(ctm.toPDFctm() + " cm\n"); + // Set clip? + } + + protected void endVParea() { + currentStream.add("Q\n"); + } + + protected void renderRegion(RegionReference region) { + // Draw a rectangle so we can see it! + // x=0,y=0,w=ipd,h=bpd + currentStream.add("BT\n"); + super.renderRegion(region); + currentStream.add("ET\n"); + } + + + protected void renderLineArea(LineArea line) { + super.renderLineArea(line); + closeText(); + } + public void renderCharacter(Character ch) { super.renderCharacter(ch); @@ -248,7 +278,8 @@ public class PDFRenderer extends PrintRenderer { updateColor(true, pdf); int rx = currentBlockIPPosition; - int bl = pageHeight - currentBPPosition; + // int bl = pageHeight - currentBPPosition; + int bl = currentBPPosition; // Set letterSpacing //float ls = fs.getLetterSpacing() / this.currentFontSize; @@ -257,7 +288,7 @@ public class PDFRenderer extends PrintRenderer { if (!textOpen || bl != prevWordY) { closeText(); - pdf.append("1 0 0 1 " + (rx / 1000f) + " " + (bl / 1000f) + pdf.append("1 0 0 -1 " + (rx / 1000f) + " " + (bl / 1000f) + " Tm [" + startText); prevWordY = bl; textOpen = true; |