Ignore:
Timestamp:
02/29/08 15:07:04 (4 years ago)
Author:
jharrop
Message:

Font replacement in HTML (for PDF output) is now basically working.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/docx4j/src/main/java/org/docx4j/openpackaging/packages/WordprocessingMLPackage.java

    r145 r153  
    3232 
    3333import org.apache.log4j.Logger; 
     34import org.docx4j.fonts.Substituter; 
    3435import org.docx4j.jaxb.Context; 
    3536import org.docx4j.openpackaging.Base; 
     
    210211                 
    211212                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*/               
    215229                // Now transform this into XHTML 
    216230                javax.xml.transform.TransformerFactory tfactory = javax.xml.transform.TransformerFactory.newInstance(); 
     
    228242                // Use the template to create a transformer 
    229243                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                 
    231264                //DEBUGGING  
    232265                // use the identity transform if you want to send wordDocument; 
     
    275308                // Now render the XHTML 
    276309                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                                 
    286311                // 4.  Use addFont code like that below as necessary for the fonts 
    287312                 
Note: See TracChangeset for help on using the changeset viewer.