You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Red Light <sk...@yahoo.com> on 2010/03/09 15:27:03 UTC

embedding fonts and performance Issue

Hi,

in my reports in embedded fonts true the following configurations in my fop.cnf conf file:

*******************************************************************************************************
<font metrics-url="arialuni.xml" kerning="yes" embed-url="ARIALUNI.TTF">                  
                    <font-triplet name="Arial Unicode MS" style="normal" weight="normal"/>
                   <font-triplet name="Arial Unicode MS" style="normal" 
                 height="bold"/>                
        </font>   
        
        <font metrics-url="arial.xml" kerning="yes" embed-url="ARIAL.TTF">
          <font-triplet name="Arial" style="normal" weight="normal"/>        
        </font>
      
        <font metrics-url="arialbd.xml" kerning="yes" embed-url="file:ARIALBD.TTF">
          <font-triplet name="ArialBD" style="normal" weight="normal"/>        
        </font>
***************************************************************************************************

but i assign the generalFont path from my class ; the prob when i was using the default fonts (Times) the performance were great like 1/2s max for the generation now  when i have embedded the 3 arial font  my pdf is rendered like in 5/6s :( which too much 

any one experienced such problem (i'm using apache fop 0.95)?


part generation report class :

****************************************************************************************************

ByteArrayOutputStream out = null;
    
    try{
        System.setProperty("javax.xml.transform.TransformerFactory","org.apache.xalan.processor.TransformerFactoryImpl");
File baseDir = new File(request.getSession().getServletContext().getRealPath("/PDF"));
    File fontBaseDir = new File(request.getSession().getServletContext().getRealPath("/PDF/fonts"));

     
        Source xsltfile = new StreamSource(new File(baseDir, fileName));
         
         
         FopFactory fopFactory = FopFactory.newInstance();
         
          try {
             DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder();
             Configuration cfg = cfgBuilder.buildFromFile(baseDir+"\\fop.xconf");
             fopFactory.setFontBaseURL(fontBaseDir.toString()); 
             fopFactory.setUserConfig(cfg);    
        } catch (Exception e) {
            System.out.println("cause"+e.getCause());
            System.out.println("plz check that the conf file and the fonts are correctly deployed or give more size to the JVM !");
        }
        
        
         FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
         
         
         out = new ByteArrayOutputStream();
             
        Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF,foUserAgent, out);
                     
        TransformerFactory tranFactory = TransformerFactory.newInstance(); 
        Transformer aTransformer = tranFactory.newTransformer(xsltfile); 

        StringReader xmlfile = new StringReader(reportStr.toString());
                 
        Source src = new StreamSource(xmlfile);
              
        
        Result res = new SAXResult(fop.getDefaultHandler());        
        aTransformer.transform(src, res);
                 

    }
    catch(TransformerException e)
    {
        e.printStackTrace();
        
    }
    
    .
    .
    /** rest of the code***/

****************************************************************************************************

and thanks



      

Re: embedding fonts and performance Issue

Posted by Pascal Sancho <pa...@takoma.fr>.
Hi,

I think that the weight of the Arial Unicode MS should be the main cause
in increasing the rendering duration.

Note that with FOP 0.95, you don't need metric files for embedded fonts.

Pascal

Red Light a écrit :
> Hi,
>
> in my reports in embedded fonts true the following configurations in
> my fop.cnf conf file:
>
> *******************************************************************************************************
> <font metrics-url="arialuni.xml" kerning="yes"
> embed-url="ARIALUNI.TTF">                 
>                     <font-triplet name="Arial Unicode MS"
> style="normal" weight="normal"/>
>                    <font-triplet name="Arial Unicode MS" style="normal"
>                  height="bold"/>               
>         </font>  
>        
>         <font metrics-url="arial.xml" kerning="yes" embed-url="ARIAL.TTF">
>           <font-triplet name="Arial" style="normal"
> weight="normal"/>       
>         </font>
>      
>         <font metrics-url="arialbd.xml" kerning="yes"
> embed-url="file:ARIALBD.TTF">
>           <font-triplet name="ArialBD" style="normal"
> weight="normal"/>       
>         </font>
> ***************************************************************************************************
>
> but i assign the generalFont path from my class ; the prob when i was
> using the default fonts (Times) the performance were great like 1/2s
> max for the generation now  when i have embedded the 3 arial font  my
> pdf is rendered like in 5/6s :( which too much
>
> any one experienced such problem (i'm using apache fop 0.95)?
>
>
> part generation report class :
>
> ****************************************************************************************************
>
> ByteArrayOutputStream out = null;
>    
>     try{
>        
> System.setProperty("javax.xml.transform.TransformerFactory","org.apache.xalan.processor.TransformerFactoryImpl");
> File baseDir = new
> File(request.getSession().getServletContext().getRealPath("/PDF"));
>     File fontBaseDir = new
> File(request.getSession().getServletContext().getRealPath("/PDF/fonts"));
>
>      
>         Source xsltfile = new StreamSource(new File(baseDir, fileName));
>          
>          
>          FopFactory fopFactory = FopFactory.newInstance();
>          
>           try {
>              DefaultConfigurationBuilder cfgBuilder = new
> DefaultConfigurationBuilder();
>              Configuration cfg =
> cfgBuilder.buildFromFile(baseDir+"\\fop.xconf");
>              fopFactory.setFontBaseURL(fontBaseDir.toString());
>              fopFactory.setUserConfig(cfg);   
>         } catch (Exception e) {
>             System.out.println("cause"+e.getCause());
>             System.out.println("plz check that the conf file and the
> fonts are correctly deployed or give more size to the JVM !");
>         }
>        
>        
>          FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
>          
>          
>          out = new ByteArrayOutputStream();
>              
>         Fop fop =
> fopFactory.newFop(MimeConstants.MIME_PDF,foUserAgent, out);
>                     
>         TransformerFactory tranFactory =
> TransformerFactory.newInstance();
>         Transformer aTransformer = tranFactory.newTransformer(xsltfile);
>
>         StringReader xmlfile = new StringReader(reportStr.toString());
>                  
>         Source src = new StreamSource(xmlfile);
>              
>        
>         Result res = new SAXResult(fop.getDefaultHandler());       
>         aTransformer.transform(src, res);
>                  
>
>     }
>     catch(TransformerException e)
>     {
>         e.printStackTrace();
>        
>     }
>    
>     .
>     .
>     /** rest of the code***/
>
> ****************************************************************************************************
>
> and thanks
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org