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 Breanna_Rin <br...@web.de> on 2009/10/29 14:23:04 UTC

Embed Fonts in PDF using Java

Hello,

I'm new here because I've got a problem I can't resolve by myself.
I'm generating a PDF in Java using FOP. My PDF is generated perfectly -
without embedded fonts. This is my Java-Code and my userconfig.xml:


Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out);
fopFactory.setStrictValidation(false);
            
//config-Datei für Font-Embedding einbinden
DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder();
Configuration cfg = cfgBuilder.buildFromFile(new
File(baseDir,"userconfig.xml"));
fopFactory.setUserConfig(cfg);
fopFactory.setFontBaseURL(baseDir.getAbsolutePath()+"/");
foUserAgent.setBaseURL("file://"+baseDir.getAbsolutePath()+"/");


      <fonts>
        <auto-detect/> 

//absolute_path is a correct path within my system
        
          <font-triplet name="Arial Unicode MS" style="italic"
weight="normal"/>
          <font-triplet name="Arial Unicode MS" style="normal"
weight="normal"/>
          <font-triplet name="Arial Unicode MS" style="normal"
weight="bold"/>
        
      </fonts>


I'm using FOOP 0.95 and I've tried with Java 1.4 and 1.6. I've also tried
with and without <font-base>-URL. No changes. 

Pathes are correctly because I can run it from command line without any
problems, fonts will be embedded.

I'm working on Ubuntu, could that be a problem? 
What else can it be? I've got no idea left, I've tried many things found in
the internet. Can you please help me?

Greetings,
Breanna
-- 
View this message in context: http://www.nabble.com/Embed-Fonts-in-PDF-using-Java-tp26112969p26112969.html
Sent from the FOP - Users mailing list archive at Nabble.com.


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


Re: Embed Fonts in PDF using Java

Posted by Breanna_Rin <br...@web.de>.
I resolved the problem by myself, but only with luck ...
The biggest problem was, that the java code lines below weren't positioned
directly under the instantiation of the fopFactory. Then the fonts were
discovered, but I get a outOfMemoryError, which I can resolve by adding
-Xmx512m (more memory for the VM) to the java command.
I didn't find any evidence to that solution, it was only luck that I
discovered that fonts were integrated above these code lines. So I hope I
can help some people with that.


Breanna_Rin wrote:
> 
> Hello,
> 
> I'm new here because I've got a problem I can't resolve by myself.
> I'm generating a PDF in Java using FOP. My PDF is generated perfectly -
> without embedded fonts. This is my Java-Code and my userconfig.xml:
> 
> 
> Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out);
> fopFactory.setStrictValidation(false);
>             
> //config-Datei für Font-Embedding einbinden
> DefaultConfigurationBuilder cfgBuilder = new
> DefaultConfigurationBuilder();
> Configuration cfg = cfgBuilder.buildFromFile(new
> File(baseDir,"userconfig.xml"));
> fopFactory.setUserConfig(cfg);
> fopFactory.setFontBaseURL(baseDir.getAbsolutePath()+"/");
> foUserAgent.setBaseURL("file://"+baseDir.getAbsolutePath()+"/");
> 
> 
>       <fonts>
>         <auto-detect/> 
> 
> //absolute_path is a correct path within my system
>         
>           <font-triplet name="Arial Unicode MS" style="italic"
> weight="normal"/>
>           <font-triplet name="Arial Unicode MS" style="normal"
> weight="normal"/>
>           <font-triplet name="Arial Unicode MS" style="normal"
> weight="bold"/>
>         
>       </fonts>
> 
> 
> I'm using FOOP 0.95 and I've tried with Java 1.4 and 1.6. I've also tried
> with and without <font-base>-URL. No changes. 
> 
> Pathes are correctly because I can run it from command line without any
> problems, fonts will be embedded.
> 
> I'm working on Ubuntu, could that be a problem? 
> What else can it be? I've got no idea left, I've tried many things found
> in the internet. Can you please help me?
> 
> Greetings,
> Breanna
> 

-- 
View this message in context: http://www.nabble.com/Embed-Fonts-in-PDF-using-Java-tp26112969p26114832.html
Sent from the FOP - Users mailing list archive at Nabble.com.


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


Re: Embed Fonts in PDF using Java

Posted by Breanna_Rin <br...@web.de>.
I resolved the problem by myself, but only with luck ...
The biggest problem was, that the java code lines below weren't positioned
directly under the instantiation of the fopFactory. Then the fonts were
discovered, but I get a outOfMemoryError, which I can resolve by adding
-Xmx512m (more memory for the VM) to the java command.
I didn't find any evidence to that solution, it was only luck that I
discovered that fonts were integrated above these code lines. So I hope I
can help some people with that.


Breanna_Rin wrote:
> 
> Hello,
> 
> I'm new here because I've got a problem I can't resolve by myself.
> I'm generating a PDF in Java using FOP. My PDF is generated perfectly -
> without embedded fonts. This is my Java-Code and my userconfig.xml:
> 
> 
> Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out);
> fopFactory.setStrictValidation(false);
>             
> //config-Datei für Font-Embedding einbinden
> DefaultConfigurationBuilder cfgBuilder = new
> DefaultConfigurationBuilder();
> Configuration cfg = cfgBuilder.buildFromFile(new
> File(baseDir,"userconfig.xml"));
> fopFactory.setUserConfig(cfg);
> fopFactory.setFontBaseURL(baseDir.getAbsolutePath()+"/");
> foUserAgent.setBaseURL("file://"+baseDir.getAbsolutePath()+"/");
> 
> 
>       <fonts>
>         <auto-detect/> 
> 
> //absolute_path is a correct path within my system
>         
>           <font-triplet name="Arial Unicode MS" style="italic"
> weight="normal"/>
>           <font-triplet name="Arial Unicode MS" style="normal"
> weight="normal"/>
>           <font-triplet name="Arial Unicode MS" style="normal"
> weight="bold"/>
>         
>       </fonts>
> 
> 
> I'm using FOOP 0.95 and I've tried with Java 1.4 and 1.6. I've also tried
> with and without <font-base>-URL. No changes. 
> 
> Pathes are correctly because I can run it from command line without any
> problems, fonts will be embedded.
> 
> I'm working on Ubuntu, could that be a problem? 
> What else can it be? I've got no idea left, I've tried many things found
> in the internet. Can you please help me?
> 
> Greetings,
> Breanna
> 

-- 
View this message in context: http://www.nabble.com/Embed-Fonts-in-PDF-using-Java-tp26112969p26114824.html
Sent from the FOP - Users mailing list archive at Nabble.com.


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