- Timestamp:
- 02/29/08 15:07:04 (4 years ago)
- Location:
- trunk/docx4j/src/main/java/org/docx4j/openpackaging/packages
- Files:
-
- 2 edited
-
WordprocessingMLPackage.java (modified) (4 diffs)
-
wordml2html-2007.xslt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/docx4j/src/main/java/org/docx4j/openpackaging/packages/WordprocessingMLPackage.java
r145 r153 32 32 33 33 import org.apache.log4j.Logger; 34 import org.docx4j.fonts.Substituter; 34 35 import org.docx4j.jaxb.Context; 35 36 import org.docx4j.openpackaging.Base; … … 210 211 211 212 log.info("wordDocument created for PDF rendering!"); 212 213 214 213 214 /* 215 * We want to use plain old Xalan J, not xsltc 216 * 217 * Following is not necessary provided Xalan is on the classpath. 218 * ================================== 219 * 220 System.setProperty("javax.xml.transform.TransformerFactory", "FQCN"); 221 222 examples of FQCN: 223 224 com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl 225 org.apache.xalan.xsltc.trax.TransformerFactoryImpl 226 227 228 */ 215 229 // Now transform this into XHTML 216 230 javax.xml.transform.TransformerFactory tfactory = javax.xml.transform.TransformerFactory.newInstance(); … … 228 242 // Use the template to create a transformer 229 243 javax.xml.transform.Transformer xformer = template.newTransformer(); 230 244 245 log.error(xformer.getClass().getName() ); 246 // com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl won't work 247 // with our extension function. 248 249 // Handle fonts - this is platform specific 250 // Algorithm - to be implemented: 251 // 1. Get a list of all the fonts in the document 252 java.util.Map fontsInUse = this.getMainDocumentPart().fontsInUse(); 253 254 // 2. For each font, find the closest match on the system (use OO's VCL.xcu to do this) 255 // - do this in a general way, since docx4all needs this as well to display fonts 256 Substituter s = new Substituter(); 257 s.populateFontMappings(fontsInUse); 258 259 // 3. Ensure that the font names in the XHTML have been mapped to these matches 260 // possibly via an extension function in the XSLT 261 xformer.setParameter("substituterInstance", s); 262 263 231 264 //DEBUGGING 232 265 // use the identity transform if you want to send wordDocument; … … 275 308 // Now render the XHTML 276 309 org.xhtmlrenderer.pdf.ITextRenderer renderer = new org.xhtmlrenderer.pdf.ITextRenderer(); 277 278 // TODO: Handle fonts 279 // - this is platform specific 280 // Algorithm - to be implemented: 281 // 1. Get a list of all the fonts in the document 282 // 2. For each font, find the closest match on the system (use OO's VCL.xcu to do this) 283 // - do this in a general way, since docx4all needs this as well to display fonts 284 // 3. Ensure that the font names in the XHTML have been mapped to these matches 285 // possibly via an extension function in the XSLT 310 286 311 // 4. Use addFont code like that below as necessary for the fonts 287 312 -
trunk/docx4j/src/main/java/org/docx4j/openpackaging/packages/wordml2html-2007.xslt
r139 r153 25 25 xmlns:msxsl="urn:schemas-microsoft-com:xslt" 26 26 xmlns:ext="http://www.xmllab.net/wordml2html/ext" 27 xmlns:java="http://xml.apache.org/xalan/java" 27 28 version="1.0" 28 exclude-result-prefixes="msxsl ext w o v WX aml w10"> 29 30 29 exclude-result-prefixes="java msxsl ext w o v WX aml w10"> 30 31 <!-- xmlns:substituterClass= "org.docx4j.fonts.Substituter" 32 extension-element-prefixes="substituterClass" 33 --> 34 31 35 <xsl:output method="xml" encoding="utf-8" omit-xml-declaration="no" indent="yes" /> 32 36 <!-- doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" --> 33 37 38 <!-- Used in extension function for mapping fonts --> 39 <xsl:param name="substituterInstance"/> <!-- select="'passed in'"--> 40 34 41 35 42 <xsl:variable name="paraStyleID_Default">Normal</xsl:variable> … … 2623 2630 2624 2631 Basic support for fonts --> 2632 2633 2634 <!-- 2625 2635 <xsl:template match="w:rFonts" mode="rpr">font-family:<xsl:value-of select="@w:ascii"/>;</xsl:template> 2626 2636 --> 2637 2638 <xsl:template match="w:rFonts" mode="rpr"> 2639 <xsl:variable name="documentFont"><xsl:value-of select="string(@w:ascii)"/></xsl:variable> 2640 <xsl:variable name="targetFont" select="java:org.docx4j.fonts.Substituter.getPdfSubstituteFont($substituterInstance, string($documentFont))" /> 2641 font-family:<xsl:value-of select="$targetFont"/>; 2642 </xsl:template> 2627 2643 2628 2644
Note: See TracChangeset
for help on using the changeset viewer.
