aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/org/apache/fop/render/AbstractRenderer.java13
-rw-r--r--src/org/apache/fop/render/pdf/PDFRenderer.java39
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;