aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2005-11-10 16:37:06 +0000
committerJeremias Maerki <jeremias@apache.org>2005-11-10 16:37:06 +0000
commita887507a4088b5374c2ec395396d48f641ea775f (patch)
tree31ef4b7fca67f179fa69e15e423213c192bb02dd
parent792c66ee02b239b857d72669697312e5e7d82932 (diff)
downloadxmlgraphics-fop-a887507a4088b5374c2ec395396d48f641ea775f.tar.gz
xmlgraphics-fop-a887507a4088b5374c2ec395396d48f641ea775f.zip
Moved PDFBridgeContext to a separate class so it can be used by both the PDFTranscoder and the PDFSVGHandler.
Added support for higher-resolution on-the-fly bitmaps from Batik for SVG inside FO documents. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@332324 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/java/org/apache/fop/render/pdf/PDFSVGHandler.java48
-rw-r--r--src/java/org/apache/fop/svg/PDFBridgeContext.java80
-rw-r--r--src/java/org/apache/fop/svg/PDFTranscoder.java42
3 files changed, 114 insertions, 56 deletions
diff --git a/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java b/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java
index 2380738e1..324c89068 100644
--- a/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java
+++ b/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java
@@ -21,10 +21,12 @@ package org.apache.fop.render.pdf;
import org.apache.fop.render.XMLHandler;
import org.apache.fop.render.RendererContext;
import org.apache.fop.pdf.PDFDocument;
+import org.apache.fop.pdf.PDFNumber;
import org.apache.fop.pdf.PDFPage;
import org.apache.fop.pdf.PDFState;
import org.apache.fop.pdf.PDFStream;
import org.apache.fop.pdf.PDFResourceContext;
+import org.apache.fop.svg.PDFBridgeContext;
import org.apache.fop.svg.PDFTextElementBridge;
import org.apache.fop.svg.PDFAElementBridge;
import org.apache.fop.svg.PDFGraphics2D;
@@ -41,12 +43,14 @@ import org.apache.commons.logging.LogFactory;
import java.io.OutputStream;
+import org.apache.batik.bridge.Bridge;
import org.apache.batik.bridge.GVTBuilder;
import org.apache.batik.bridge.BridgeContext;
import org.apache.batik.bridge.ViewBox;
import org.apache.batik.dom.svg.SVGDOMImplementation;
import org.apache.batik.gvt.GraphicsNode;
+import org.apache.batik.util.SVGConstants;
import org.w3c.dom.svg.SVGDocument;
import org.w3c.dom.svg.SVGSVGElement;
@@ -222,22 +226,26 @@ public class PDFSVGHandler implements XMLHandler {
int xOffset = pdfInfo.currentXPosition;
int yOffset = pdfInfo.currentYPosition;
- SVGUserAgent ua
- = new SVGUserAgent(context.getUserAgent().getPixelUnitToMillimeter(),
- new AffineTransform());
+ log.debug("Generating SVG at "
+ + context.getUserAgent().getResolution()
+ + "dpi.");
+
+ final int uaResolution = 72; //Should not be changed
+ final float deviceResolution
+ = context.getUserAgent().getResolution();
+ SVGUserAgent ua = new SVGUserAgent(25.4f / uaResolution, new AffineTransform());
GVTBuilder builder = new GVTBuilder();
- BridgeContext ctx = new BridgeContext(ua);
- PDFTextElementBridge tBridge = new PDFTextElementBridge(pdfInfo.fi);
- ctx.putBridge(tBridge);
-
- PDFAElementBridge aBridge = new PDFAElementBridge();
- // to get the correct transform we need to use the PDFState
- AffineTransform transform = pdfInfo.pdfState.getTransform();
- transform.translate(xOffset / 1000f, yOffset / 1000f);
- aBridge.setCurrentTransform(transform);
- ctx.putBridge(aBridge);
-
+
+ //TODO This AffineTransform here has to be fixed!!!
+ AffineTransform linkTransform = pdfInfo.pdfState.getTransform();
+ linkTransform.translate(xOffset / 1000f, yOffset / 1000f);
+
+ final boolean strokeText = false;
+ BridgeContext ctx = new PDFBridgeContext(ua,
+ (strokeText ? null : pdfInfo.fi),
+ linkTransform);
+
GraphicsNode root;
try {
root = builder.build(ctx, doc);
@@ -290,9 +298,19 @@ public class PDFSVGHandler implements XMLHandler {
pdfInfo.currentFontSize);
graphics.setGraphicContext(new org.apache.batik.ext.awt.g2d.GraphicContext());
pdfInfo.pdfState.push();
- transform = new AffineTransform();
+ AffineTransform transform = new AffineTransform();
// scale to viewbox
transform.translate(xOffset / 1000f, yOffset / 1000f);
+
+ if (deviceResolution != uaResolution) {
+ //Scale for higher resolution on-the-fly images from Batik
+ double s = uaResolution / deviceResolution;
+ at.scale(s, s);
+ pdfInfo.currentStream.add("" + PDFNumber.doubleOut(s) + " 0 0 "
+ + PDFNumber.doubleOut(s) + " 0 0 cm\n");
+ graphics.scale(1 / s, 1 / s);
+ }
+
pdfInfo.pdfState.setTransform(transform);
graphics.setPDFState(pdfInfo.pdfState);
graphics.setOutputStream(pdfInfo.outputStream);
diff --git a/src/java/org/apache/fop/svg/PDFBridgeContext.java b/src/java/org/apache/fop/svg/PDFBridgeContext.java
new file mode 100644
index 000000000..486cadb97
--- /dev/null
+++ b/src/java/org/apache/fop/svg/PDFBridgeContext.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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.svg;
+
+import java.awt.geom.AffineTransform;
+
+import org.apache.batik.bridge.BridgeContext;
+import org.apache.batik.bridge.UserAgent;
+import org.apache.fop.fonts.FontInfo;
+
+/**
+ * BridgeContext which registers the custom bridges for PDF output.
+ */
+public class PDFBridgeContext extends BridgeContext {
+
+ /** The font list. */
+ private final FontInfo fontInfo;
+
+ private AffineTransform linkTransform;
+
+ /**
+ * Constructs a new bridge context.
+ * @param userAgent the user agent
+ * @param fontInfo the font list for the text painter, may be null in which case text is
+ * painted as shapes
+ * @param linkTransform AffineTransform to properly place links, may be null
+ */
+ public PDFBridgeContext(UserAgent userAgent, FontInfo fontInfo,
+ AffineTransform linkTransform) {
+ super(userAgent);
+ this.fontInfo = fontInfo;
+ this.linkTransform = linkTransform;
+ }
+
+ /**
+ * Constructs a new bridge context.
+ * @param userAgent the user agent
+ * @param fontInfo the font list for the text painter, may be null in which case text is
+ * painted as shapes
+ */
+ public PDFBridgeContext(UserAgent userAgent, FontInfo fontInfo) {
+ this(userAgent, fontInfo, null);
+ }
+
+ /** @see org.apache.batik.bridge.BridgeContext#registerSVGBridges() */
+ public void registerSVGBridges() {
+ super.registerSVGBridges();
+
+ if (fontInfo != null) {
+ putBridge(new PDFTextElementBridge(fontInfo));
+ }
+
+ PDFAElementBridge pdfAElementBridge = new PDFAElementBridge();
+ if (linkTransform != null) {
+ pdfAElementBridge.setCurrentTransform(linkTransform);
+ } else {
+ pdfAElementBridge.setCurrentTransform(new AffineTransform());
+ }
+ putBridge(pdfAElementBridge);
+
+ putBridge(new PDFImageElementBridge());
+ }
+
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/svg/PDFTranscoder.java b/src/java/org/apache/fop/svg/PDFTranscoder.java
index a07b1c9f5..b9e2e1215 100644
--- a/src/java/org/apache/fop/svg/PDFTranscoder.java
+++ b/src/java/org/apache/fop/svg/PDFTranscoder.java
@@ -19,7 +19,6 @@
package org.apache.fop.svg;
import java.awt.Color;
-import java.awt.geom.AffineTransform;
import java.io.IOException;
import org.apache.avalon.framework.configuration.Configurable;
@@ -180,47 +179,8 @@ public class PDFTranscoder extends AbstractFOPTranscoder
/** @see org.apache.batik.transcoder.SVGAbstractTranscoder#createBridgeContext() */
protected BridgeContext createBridgeContext() {
- BridgeContext ctx = new PDFBridgeContext(userAgent);
-
+ BridgeContext ctx = new PDFBridgeContext(userAgent, graphics.getFontInfo());
return ctx;
}
- /**
- * BridgeContext which registers the custom bridges for PDF output.
- */
- public class PDFBridgeContext extends BridgeContext {
- /**
- * Constructs a new bridge context.
- * @param userAgent the user agent
- */
- public PDFBridgeContext(UserAgent userAgent) {
- super(userAgent);
- }
-
- /** @see org.apache.batik.bridge.BridgeContext#registerSVGBridges() */
- public void registerSVGBridges() {
- super.registerSVGBridges();
-
- /*
- boolean stroke = true;
- if (hints.containsKey(KEY_STROKE_TEXT)) {
- stroke = ((Boolean)hints.get(KEY_STROKE_TEXT)).booleanValue();
- }
- if (!stroke) {
- textPainter = new PDFTextPainter(graphics.getFontInfo());
- ctx.setTextPainter(textPainter);
- }
- */
-
- putBridge(new PDFTextElementBridge(graphics.getFontInfo()));
-
- PDFAElementBridge pdfAElementBridge = new PDFAElementBridge();
- pdfAElementBridge.setCurrentTransform(new AffineTransform());
- putBridge(pdfAElementBridge);
-
- putBridge(new PDFImageElementBridge());
- }
-
- }
-
}
backport/48282/stable25 Nextcloud server, a safe home for all your data: https://github.com/nextcloud/serverwww-data
summaryrefslogtreecommitdiffstats
path: root/core/Command/Maintenance/Repair.php
blob: 95e2b87222762d541068646a668397bdd5b92dfe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91