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 Reyal <re...@gmail.com> on 2009/04/03 04:44:39 UTC

Printing in FOP using PageableRenderer with Unicode characters

Good day,

I tried to follow this thread here.
http://www.nabble.com/Direct-Printing-and-setting-print-parameters-in-FOP-0.94-tp16747594p22087146.html

I also build my own copy from fop-trunk for my testing and
use your example. The printing looks cool but still got a warning when
using barcode and thai characters. The printed output have no barcode
and thai characters in it. What I mean is that the fonts were not applied.

Below is the code snippet:
public void printFO(File fo) throws IOException, FOPException,
			TransformerException, PrintException {

		// Set up DocPrintJob instance
		DocPrintJob printJob = createDocPrintJob();
		// Set up a custom user agent so we can supply our own renderer instance
		FOUserAgent userAgent = fopFactory.newFOUserAgent();
		
		PageableRenderer renderer = new PageableRenderer();
		renderer.setUserAgent(userAgent);
		userAgent.setRendererOverride(renderer);

		// Construct FOP with desired output format
		Fop fop = fopFactory.newFop(userAgent);
		try {
			fopFactory.setUserConfig(new File("xml/fopConf.xml"));
		} catch (SAXException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		// Setup JAXP using identity transformer
		TransformerFactory factory = TransformerFactory.newInstance();
		Transformer transformer = factory.newTransformer(); // identity
															// transformer

		// Setup input stream
		Source src = new StreamSource(fo);

		// Resulting SAX events (the generated FO) must be piped through to FOP
		Result res = new SAXResult(fop.getDefaultHandler());

		// Start XSLT transformation and FOP processing
		transformer.transform(src, res);

		Doc doc = new SimpleDoc(renderer, DocFlavor.SERVICE_FORMATTED.PAGEABLE,
				null);
		printJob.print(doc, null);
	}

------------[fopConf.xml]-------------------------
<?xml version="1.0"?>
<fop version="1.0">

  <!-- Base URL for resolving relative URLs -->
  <base>.</base>
  
  <!-- Font Base URL for resolving relative font URLs -->
  <font-base>./</font-base>
  <renderers>
     <renderer mime="application/X-fop-print">
      <fonts>
        <directory recursive="true">D:/PRINTING</directory>
        
          <font-triplet name="Barcode" style="normal" weight="normal"/>
        
                
        
          <font-triplet name="Thai" style="normal" weight="normal"/>
        
      </fonts>
    </renderer>
  </renderers>
</fop>

When I run the above, I got the warning messages below:

Apr 3, 2009 10:27:23 AM org.apache.fop.events.LoggingEventListener
processEvent
WARNING: Font "Barcode,normal,700" not found. Substituting with
"any,normal,700".
Apr 3, 2009 10:27:23 AM org.apache.fop.events.LoggingEventListener
processEvent
WARNING: Line 1 of a paragraph overflows the available area by 29345
millipoints. (See position 697:49)
Apr 3, 2009 10:27:23 AM org.apache.fop.events.LoggingEventListener
processEvent
INFO: An fo:block  (See position 708:30) is wider than the available room in
inline-progression-dimension. Adjusting end-indent based on overconstrained
geometry rules (XSL 1.1, ch. 5.3.4)
Apr 3, 2009 10:27:23 AM org.apache.fop.events.LoggingEventListener
processEvent
INFO: An fo:block  (See position 730:30) is wider than the available room in
inline-progression-dimension. Adjusting end-indent based on overconstrained
geometry rules (XSL 1.1, ch. 5.3.4)
Apr 3, 2009 10:27:23 AM org.apache.fop.events.LoggingEventListener
processEvent
WARNING: Font "Thai,normal,400" not found. Substituting with
"any,normal,400".
Success!

Any help?

-
Rey
-- 
View this message in context: http://www.nabble.com/Printing-in-FOP-using-PageableRenderer-with-Unicode-characters-tp22860872p22860872.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: Printing in FOP using PageableRenderer with Unicode characters

Posted by Reyal <re...@gmail.com>.
Thanks Jeremias, it worked like a charm.


Jeremias Maerki-2 wrote:
> 
> Hi Rey,
> 
> sorry, I should have noticed that. I've just moved the getMimeType()
> method up to PageableRenderer:
> http://svn.apache.org/viewvc?rev=761596&view=rev
> 
> However, that alone won't solve your problem as you're instantiating the
> PrintRenderer yourself. I haven't got time to test this right now, but
> you can try the following:
> 
> PageableRenderer renderer = new PageableRenderer();
> renderer.setUserAgent(userAgent);
> RendererConfigurator configurator = new
> PrintRendererConfigurator(userAgent);
> configurator.configure(renderer);
> 
> That should cause the configuration to be set on the PageableRenderer.
> 
> 
> On 03.04.2009 10:45:58 Reyal wrote:
>> 
>> Hello Jeremias,
>> 
>> Thanks for your response.
>> Anyway, I updated my code using PrintRenderer.java from fop-trunk and
>> re-build the jar file.
>> The same output was I got. I also modified my configuration file to...
>> 
>> <?xml version="1.0"?>
>> <fop version="1.0">
>>   <!-- Base URL for resolving relative URLs -->
>>   <base>.</base>
>>   
>>   <!-- Font Base URL for resolving relative font URLs -->
>>   <font-base>./</font-base>
>>  
>>   <fonts>
>>       <substitutions>
>>          <substitution>
>>             <from font-family="Barcode" font-weight="700..900"/>
>>             <to font-family="Free 3 of 9"/>
>>          </substitution>
>>          <substitution>
>>             <from font-family="Thai"/>
>>             <to font-family="Thai7BangkokSSK" font-style="normal"/>
>>          </substitution>
>>       </substitutions>
>>    </fonts>
>>    <renderers>
>>       <renderer mime="application/pdf">
>>       <filterList>
>>         <value>flate</value>
>>       </filterList>
>>       <fonts>
>>          <directory recursive="true">./fonts</directory>
>>       </fonts>
>>       </renderer>
>> 
>>      <renderer mime="application/X-fop-print">
>>       <fonts>
>>         <directory recursive="true">./fonts</directory>
>>       </fonts>
>>     </renderer>
>>    </renderers>
>> </fop>
>> 
>> Inside <proj_home>/fonts directory:
>>   - fonts
>>       - 3OF9.ttf
>>       - thai7bangkokssk.ttf
>> 
>> I also found-out that you are modifying the PrintRenderer class which
>> extends the PageableRender class.
>> I don't think this will make any sense, since I am using PageableRenderer
>> to
>> override the default renderer.
>> 
>> Thanks,
>> Rey
>> 
>> 
>> Jeremias Maerki-2 wrote:
>> > 
>> > Hi Rey,
>> > 
>> > there was a bug which I've just fixed:
>> > http://svn.apache.org/viewvc?rev=761554&view=rev
>> > 
>> > Please update your working copy, retry and let me know if it works.
>> > 
>> > BTW, you can remove the two "font-triplet" elements from the
>> > configuration. They are ignored where you placed them. "font-triplet"
>> > is only available inside a "font" element. With "directory", the
>> > font triplets are automatically generated from the information in the
>> > font itself. But that also means you have to use the font's actual name
>> > inside XSL-FO unless you use the font-substitution feature:
>> > http://xmlgraphics.apache.org/fop/trunk/fonts.html#substitution
>> > 
>> > On 03.04.2009 09:02:20 Reyal wrote:
>> >> 
>> >> As a sidenote, the same configuration file I used to generate a pdf
>> file
>> >> and
>> >> the barcode and thai characters are present. I just added new renderer
>> >> for
>> >> pdf(mime="application/pdf") with the same configuration of fonts as in
>> >> mime="application/X-fop-print" renderer. I just wonder what I have
>> done
>> >> wrong in this case.
>> >> 
>> >> Thanks in advance.
>> >> 
>> >> -
>> >> Rey
>> >> 
>> >> 
>> >> Reyal wrote:
>> >> > 
>> >> > Good day,
>> >> > 
>> >> > I tried to follow this thread here.
>> >> >
>> >>
>> http://www.nabble.com/Direct-Printing-and-setting-print-parameters-in-FOP-0.94-tp16747594p22087146.html
>> >> > 
>> >> > I also build my own copy from fop-trunk for my testing and
>> >> > use your example. The printing looks cool but still got a warning
>> when
>> >> > using barcode and thai characters. The printed output have no
>> barcode
>> >> > and thai characters in it. What I mean is that the fonts were not
>> >> applied.
>> >> > 
>> >> > Below is the code snippet:
>> >> > public void printFO(File fo) throws IOException, FOPException,
>> >> > 			TransformerException, PrintException {
>> >> > 
>> >> > 		// Set up DocPrintJob instance
>> >> > 		DocPrintJob printJob = createDocPrintJob();
>> >> > 		// Set up a custom user agent so we can supply our own renderer
>> >> instance
>> >> > 		FOUserAgent userAgent = fopFactory.newFOUserAgent();
>> >> > 		
>> >> > 		PageableRenderer renderer = new PageableRenderer();
>> >> > 		renderer.setUserAgent(userAgent);
>> >> > 		userAgent.setRendererOverride(renderer);
>> >> > 
>> >> > 		// Construct FOP with desired output format
>> >> > 		Fop fop = fopFactory.newFop(userAgent);
>> >> > 		try {
>> >> > 			fopFactory.setUserConfig(new File("xml/fopConf.xml"));
>> >> > 		} catch (SAXException e) {
>> >> > 			// TODO Auto-generated catch block
>> >> > 			e.printStackTrace();
>> >> > 		}
>> >> > 
>> >> > 		// Setup JAXP using identity transformer
>> >> > 		TransformerFactory factory = TransformerFactory.newInstance();
>> >> > 		Transformer transformer = factory.newTransformer(); // identity
>> >> > 															// transformer
>> >> > 
>> >> > 		// Setup input stream
>> >> > 		Source src = new StreamSource(fo);
>> >> > 
>> >> > 		// Resulting SAX events (the generated FO) must be piped through
>> to
>> >> FOP
>> >> > 		Result res = new SAXResult(fop.getDefaultHandler());
>> >> > 
>> >> > 		// Start XSLT transformation and FOP processing
>> >> > 		transformer.transform(src, res);
>> >> > 
>> >> > 		Doc doc = new SimpleDoc(renderer,
>> >> DocFlavor.SERVICE_FORMATTED.PAGEABLE,
>> >> > 				null);
>> >> > 		printJob.print(doc, null);
>> >> > 	}
>> >> > 
>> >> > ------------[fopConf.xml]-------------------------
>> >> > <?xml version="1.0"?>
>> >> > <fop version="1.0">
>> >> > 
>> >> >   <!-- Base URL for resolving relative URLs -->
>> >> >   <base>.</base>
>> >> >   
>> >> >   <!-- Font Base URL for resolving relative font URLs -->
>> >> >   <font-base>./</font-base>
>> >> >   <renderers>
>> >> >      <renderer mime="application/X-fop-print">
>> >> >       <fonts>
>> >> >         <directory recursive="true">D:/PRINTING</directory>
>> >> >         
>> >> >           <font-triplet name="Barcode" style="normal"
>> weight="normal"/>
>> >> >         
>> >> >                 
>> >> >         
>> >> >           <font-triplet name="Thai" style="normal" weight="normal"/>
>> >> >         
>> >> >       </fonts>
>> >> >     </renderer>
>> >> >   </renderers>
>> >> > </fop>
>> >> > 
>> >> > When I run the above, I got the warning messages below:
>> >> > 
>> >> > Apr 3, 2009 10:27:23 AM org.apache.fop.events.LoggingEventListener
>> >> > processEvent
>> >> > WARNING: Font "Barcode,normal,700" not found. Substituting with
>> >> > "any,normal,700".
>> >> > Apr 3, 2009 10:27:23 AM org.apache.fop.events.LoggingEventListener
>> >> > processEvent
>> >> > WARNING: Line 1 of a paragraph overflows the available area by 29345
>> >> > millipoints. (See position 697:49)
>> >> > Apr 3, 2009 10:27:23 AM org.apache.fop.events.LoggingEventListener
>> >> > processEvent
>> >> > INFO: An fo:block  (See position 708:30) is wider than the available
>> >> room
>> >> > in inline-progression-dimension. Adjusting end-indent based on
>> >> > overconstrained geometry rules (XSL 1.1, ch. 5.3.4)
>> >> > Apr 3, 2009 10:27:23 AM org.apache.fop.events.LoggingEventListener
>> >> > processEvent
>> >> > INFO: An fo:block  (See position 730:30) is wider than the available
>> >> room
>> >> > in inline-progression-dimension. Adjusting end-indent based on
>> >> > overconstrained geometry rules (XSL 1.1, ch. 5.3.4)
>> >> > Apr 3, 2009 10:27:23 AM org.apache.fop.events.LoggingEventListener
>> >> > processEvent
>> >> > WARNING: Font "Thai,normal,400" not found. Substituting with
>> >> > "any,normal,400".
>> >> > Success!
>> >> > 
>> >> > Any help?
>> >> > 
>> >> > -
>> >> > Rey
>> >> > 
>> >> 
>> >> -- 
>> >> View this message in context:
>> >>
>> http://www.nabble.com/Printing-in-FOP-using-PageableRenderer-with-Unicode-characters-tp22860872p22863060.html
>> >> Sent from the FOP - Users mailing list archive at Nabble.com.
>> >> 
>> > 
>> > 
>> > 
>> > Jeremias Maerki
>> > 
>> > 
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
>> > For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
>> > 
>> > 
>> > 
>> 
>> -- 
>> View this message in context:
>> http://www.nabble.com/Printing-in-FOP-using-PageableRenderer-with-Unicode-characters-tp22860872p22864382.html
>> Sent from the FOP - Users mailing list archive at Nabble.com.
>> 
> 
> 
> 
> Jeremias Maerki
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Printing-in-FOP-using-PageableRenderer-with-Unicode-characters-tp22860872p22922531.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: Printing in FOP using PageableRenderer with Unicode characters

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
Hi Rey,

sorry, I should have noticed that. I've just moved the getMimeType()
method up to PageableRenderer: http://svn.apache.org/viewvc?rev=761596&view=rev

However, that alone won't solve your problem as you're instantiating the
PrintRenderer yourself. I haven't got time to test this right now, but
you can try the following:

PageableRenderer renderer = new PageableRenderer();
renderer.setUserAgent(userAgent);
RendererConfigurator configurator = new PrintRendererConfigurator(userAgent);
configurator.configure(renderer);

That should cause the configuration to be set on the PageableRenderer.


On 03.04.2009 10:45:58 Reyal wrote:
> 
> Hello Jeremias,
> 
> Thanks for your response.
> Anyway, I updated my code using PrintRenderer.java from fop-trunk and
> re-build the jar file.
> The same output was I got. I also modified my configuration file to...
> 
> <?xml version="1.0"?>
> <fop version="1.0">
>   <!-- Base URL for resolving relative URLs -->
>   <base>.</base>
>   
>   <!-- Font Base URL for resolving relative font URLs -->
>   <font-base>./</font-base>
>  
>   <fonts>
>       <substitutions>
>          <substitution>
>             <from font-family="Barcode" font-weight="700..900"/>
>             <to font-family="Free 3 of 9"/>
>          </substitution>
>          <substitution>
>             <from font-family="Thai"/>
>             <to font-family="Thai7BangkokSSK" font-style="normal"/>
>          </substitution>
>       </substitutions>
>    </fonts>
>    <renderers>
>       <renderer mime="application/pdf">
>       <filterList>
>         <value>flate</value>
>       </filterList>
>       <fonts>
>          <directory recursive="true">./fonts</directory>
>       </fonts>
>       </renderer>
> 
>      <renderer mime="application/X-fop-print">
>       <fonts>
>         <directory recursive="true">./fonts</directory>
>       </fonts>
>     </renderer>
>    </renderers>
> </fop>
> 
> Inside <proj_home>/fonts directory:
>   - fonts
>       - 3OF9.ttf
>       - thai7bangkokssk.ttf
> 
> I also found-out that you are modifying the PrintRenderer class which
> extends the PageableRender class.
> I don't think this will make any sense, since I am using PageableRenderer to
> override the default renderer.
> 
> Thanks,
> Rey
> 
> 
> Jeremias Maerki-2 wrote:
> > 
> > Hi Rey,
> > 
> > there was a bug which I've just fixed:
> > http://svn.apache.org/viewvc?rev=761554&view=rev
> > 
> > Please update your working copy, retry and let me know if it works.
> > 
> > BTW, you can remove the two "font-triplet" elements from the
> > configuration. They are ignored where you placed them. "font-triplet"
> > is only available inside a "font" element. With "directory", the
> > font triplets are automatically generated from the information in the
> > font itself. But that also means you have to use the font's actual name
> > inside XSL-FO unless you use the font-substitution feature:
> > http://xmlgraphics.apache.org/fop/trunk/fonts.html#substitution
> > 
> > On 03.04.2009 09:02:20 Reyal wrote:
> >> 
> >> As a sidenote, the same configuration file I used to generate a pdf file
> >> and
> >> the barcode and thai characters are present. I just added new renderer
> >> for
> >> pdf(mime="application/pdf") with the same configuration of fonts as in
> >> mime="application/X-fop-print" renderer. I just wonder what I have done
> >> wrong in this case.
> >> 
> >> Thanks in advance.
> >> 
> >> -
> >> Rey
> >> 
> >> 
> >> Reyal wrote:
> >> > 
> >> > Good day,
> >> > 
> >> > I tried to follow this thread here.
> >> >
> >> http://www.nabble.com/Direct-Printing-and-setting-print-parameters-in-FOP-0.94-tp16747594p22087146.html
> >> > 
> >> > I also build my own copy from fop-trunk for my testing and
> >> > use your example. The printing looks cool but still got a warning when
> >> > using barcode and thai characters. The printed output have no barcode
> >> > and thai characters in it. What I mean is that the fonts were not
> >> applied.
> >> > 
> >> > Below is the code snippet:
> >> > public void printFO(File fo) throws IOException, FOPException,
> >> > 			TransformerException, PrintException {
> >> > 
> >> > 		// Set up DocPrintJob instance
> >> > 		DocPrintJob printJob = createDocPrintJob();
> >> > 		// Set up a custom user agent so we can supply our own renderer
> >> instance
> >> > 		FOUserAgent userAgent = fopFactory.newFOUserAgent();
> >> > 		
> >> > 		PageableRenderer renderer = new PageableRenderer();
> >> > 		renderer.setUserAgent(userAgent);
> >> > 		userAgent.setRendererOverride(renderer);
> >> > 
> >> > 		// Construct FOP with desired output format
> >> > 		Fop fop = fopFactory.newFop(userAgent);
> >> > 		try {
> >> > 			fopFactory.setUserConfig(new File("xml/fopConf.xml"));
> >> > 		} catch (SAXException e) {
> >> > 			// TODO Auto-generated catch block
> >> > 			e.printStackTrace();
> >> > 		}
> >> > 
> >> > 		// Setup JAXP using identity transformer
> >> > 		TransformerFactory factory = TransformerFactory.newInstance();
> >> > 		Transformer transformer = factory.newTransformer(); // identity
> >> > 															// transformer
> >> > 
> >> > 		// Setup input stream
> >> > 		Source src = new StreamSource(fo);
> >> > 
> >> > 		// Resulting SAX events (the generated FO) must be piped through to
> >> FOP
> >> > 		Result res = new SAXResult(fop.getDefaultHandler());
> >> > 
> >> > 		// Start XSLT transformation and FOP processing
> >> > 		transformer.transform(src, res);
> >> > 
> >> > 		Doc doc = new SimpleDoc(renderer,
> >> DocFlavor.SERVICE_FORMATTED.PAGEABLE,
> >> > 				null);
> >> > 		printJob.print(doc, null);
> >> > 	}
> >> > 
> >> > ------------[fopConf.xml]-------------------------
> >> > <?xml version="1.0"?>
> >> > <fop version="1.0">
> >> > 
> >> >   <!-- Base URL for resolving relative URLs -->
> >> >   <base>.</base>
> >> >   
> >> >   <!-- Font Base URL for resolving relative font URLs -->
> >> >   <font-base>./</font-base>
> >> >   <renderers>
> >> >      <renderer mime="application/X-fop-print">
> >> >       <fonts>
> >> >         <directory recursive="true">D:/PRINTING</directory>
> >> >         
> >> >           <font-triplet name="Barcode" style="normal" weight="normal"/>
> >> >         
> >> >                 
> >> >         
> >> >           <font-triplet name="Thai" style="normal" weight="normal"/>
> >> >         
> >> >       </fonts>
> >> >     </renderer>
> >> >   </renderers>
> >> > </fop>
> >> > 
> >> > When I run the above, I got the warning messages below:
> >> > 
> >> > Apr 3, 2009 10:27:23 AM org.apache.fop.events.LoggingEventListener
> >> > processEvent
> >> > WARNING: Font "Barcode,normal,700" not found. Substituting with
> >> > "any,normal,700".
> >> > Apr 3, 2009 10:27:23 AM org.apache.fop.events.LoggingEventListener
> >> > processEvent
> >> > WARNING: Line 1 of a paragraph overflows the available area by 29345
> >> > millipoints. (See position 697:49)
> >> > Apr 3, 2009 10:27:23 AM org.apache.fop.events.LoggingEventListener
> >> > processEvent
> >> > INFO: An fo:block  (See position 708:30) is wider than the available
> >> room
> >> > in inline-progression-dimension. Adjusting end-indent based on
> >> > overconstrained geometry rules (XSL 1.1, ch. 5.3.4)
> >> > Apr 3, 2009 10:27:23 AM org.apache.fop.events.LoggingEventListener
> >> > processEvent
> >> > INFO: An fo:block  (See position 730:30) is wider than the available
> >> room
> >> > in inline-progression-dimension. Adjusting end-indent based on
> >> > overconstrained geometry rules (XSL 1.1, ch. 5.3.4)
> >> > Apr 3, 2009 10:27:23 AM org.apache.fop.events.LoggingEventListener
> >> > processEvent
> >> > WARNING: Font "Thai,normal,400" not found. Substituting with
> >> > "any,normal,400".
> >> > Success!
> >> > 
> >> > Any help?
> >> > 
> >> > -
> >> > Rey
> >> > 
> >> 
> >> -- 
> >> View this message in context:
> >> http://www.nabble.com/Printing-in-FOP-using-PageableRenderer-with-Unicode-characters-tp22860872p22863060.html
> >> Sent from the FOP - Users mailing list archive at Nabble.com.
> >> 
> > 
> > 
> > 
> > Jeremias Maerki
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> > For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
> > 
> > 
> > 
> 
> -- 
> View this message in context: http://www.nabble.com/Printing-in-FOP-using-PageableRenderer-with-Unicode-characters-tp22860872p22864382.html
> Sent from the FOP - Users mailing list archive at Nabble.com.
> 



Jeremias Maerki


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


Re: Printing in FOP using PageableRenderer with Unicode characters

Posted by Reyal <re...@gmail.com>.
Hello Jeremias,

Thanks for your response.
Anyway, I updated my code using PrintRenderer.java from fop-trunk and
re-build the jar file.
The same output was I got. I also modified my configuration file to...

<?xml version="1.0"?>
<fop version="1.0">
  <!-- Base URL for resolving relative URLs -->
  <base>.</base>
  
  <!-- Font Base URL for resolving relative font URLs -->
  <font-base>./</font-base>
 
  <fonts>
      <substitutions>
         <substitution>
            <from font-family="Barcode" font-weight="700..900"/>
            <to font-family="Free 3 of 9"/>
         </substitution>
         <substitution>
            <from font-family="Thai"/>
            <to font-family="Thai7BangkokSSK" font-style="normal"/>
         </substitution>
      </substitutions>
   </fonts>
   <renderers>
      <renderer mime="application/pdf">
      <filterList>
        <value>flate</value>
      </filterList>
      <fonts>
         <directory recursive="true">./fonts</directory>
      </fonts>
      </renderer>

     <renderer mime="application/X-fop-print">
      <fonts>
        <directory recursive="true">./fonts</directory>
      </fonts>
    </renderer>
   </renderers>
</fop>

Inside <proj_home>/fonts directory:
  - fonts
      - 3OF9.ttf
      - thai7bangkokssk.ttf

I also found-out that you are modifying the PrintRenderer class which
extends the PageableRender class.
I don't think this will make any sense, since I am using PageableRenderer to
override the default renderer.

Thanks,
Rey


Jeremias Maerki-2 wrote:
> 
> Hi Rey,
> 
> there was a bug which I've just fixed:
> http://svn.apache.org/viewvc?rev=761554&view=rev
> 
> Please update your working copy, retry and let me know if it works.
> 
> BTW, you can remove the two "font-triplet" elements from the
> configuration. They are ignored where you placed them. "font-triplet"
> is only available inside a "font" element. With "directory", the
> font triplets are automatically generated from the information in the
> font itself. But that also means you have to use the font's actual name
> inside XSL-FO unless you use the font-substitution feature:
> http://xmlgraphics.apache.org/fop/trunk/fonts.html#substitution
> 
> On 03.04.2009 09:02:20 Reyal wrote:
>> 
>> As a sidenote, the same configuration file I used to generate a pdf file
>> and
>> the barcode and thai characters are present. I just added new renderer
>> for
>> pdf(mime="application/pdf") with the same configuration of fonts as in
>> mime="application/X-fop-print" renderer. I just wonder what I have done
>> wrong in this case.
>> 
>> Thanks in advance.
>> 
>> -
>> Rey
>> 
>> 
>> Reyal wrote:
>> > 
>> > Good day,
>> > 
>> > I tried to follow this thread here.
>> >
>> http://www.nabble.com/Direct-Printing-and-setting-print-parameters-in-FOP-0.94-tp16747594p22087146.html
>> > 
>> > I also build my own copy from fop-trunk for my testing and
>> > use your example. The printing looks cool but still got a warning when
>> > using barcode and thai characters. The printed output have no barcode
>> > and thai characters in it. What I mean is that the fonts were not
>> applied.
>> > 
>> > Below is the code snippet:
>> > public void printFO(File fo) throws IOException, FOPException,
>> > 			TransformerException, PrintException {
>> > 
>> > 		// Set up DocPrintJob instance
>> > 		DocPrintJob printJob = createDocPrintJob();
>> > 		// Set up a custom user agent so we can supply our own renderer
>> instance
>> > 		FOUserAgent userAgent = fopFactory.newFOUserAgent();
>> > 		
>> > 		PageableRenderer renderer = new PageableRenderer();
>> > 		renderer.setUserAgent(userAgent);
>> > 		userAgent.setRendererOverride(renderer);
>> > 
>> > 		// Construct FOP with desired output format
>> > 		Fop fop = fopFactory.newFop(userAgent);
>> > 		try {
>> > 			fopFactory.setUserConfig(new File("xml/fopConf.xml"));
>> > 		} catch (SAXException e) {
>> > 			// TODO Auto-generated catch block
>> > 			e.printStackTrace();
>> > 		}
>> > 
>> > 		// Setup JAXP using identity transformer
>> > 		TransformerFactory factory = TransformerFactory.newInstance();
>> > 		Transformer transformer = factory.newTransformer(); // identity
>> > 															// transformer
>> > 
>> > 		// Setup input stream
>> > 		Source src = new StreamSource(fo);
>> > 
>> > 		// Resulting SAX events (the generated FO) must be piped through to
>> FOP
>> > 		Result res = new SAXResult(fop.getDefaultHandler());
>> > 
>> > 		// Start XSLT transformation and FOP processing
>> > 		transformer.transform(src, res);
>> > 
>> > 		Doc doc = new SimpleDoc(renderer,
>> DocFlavor.SERVICE_FORMATTED.PAGEABLE,
>> > 				null);
>> > 		printJob.print(doc, null);
>> > 	}
>> > 
>> > ------------[fopConf.xml]-------------------------
>> > <?xml version="1.0"?>
>> > <fop version="1.0">
>> > 
>> >   <!-- Base URL for resolving relative URLs -->
>> >   <base>.</base>
>> >   
>> >   <!-- Font Base URL for resolving relative font URLs -->
>> >   <font-base>./</font-base>
>> >   <renderers>
>> >      <renderer mime="application/X-fop-print">
>> >       <fonts>
>> >         <directory recursive="true">D:/PRINTING</directory>
>> >         
>> >           <font-triplet name="Barcode" style="normal" weight="normal"/>
>> >         
>> >                 
>> >         
>> >           <font-triplet name="Thai" style="normal" weight="normal"/>
>> >         
>> >       </fonts>
>> >     </renderer>
>> >   </renderers>
>> > </fop>
>> > 
>> > When I run the above, I got the warning messages below:
>> > 
>> > Apr 3, 2009 10:27:23 AM org.apache.fop.events.LoggingEventListener
>> > processEvent
>> > WARNING: Font "Barcode,normal,700" not found. Substituting with
>> > "any,normal,700".
>> > Apr 3, 2009 10:27:23 AM org.apache.fop.events.LoggingEventListener
>> > processEvent
>> > WARNING: Line 1 of a paragraph overflows the available area by 29345
>> > millipoints. (See position 697:49)
>> > Apr 3, 2009 10:27:23 AM org.apache.fop.events.LoggingEventListener
>> > processEvent
>> > INFO: An fo:block  (See position 708:30) is wider than the available
>> room
>> > in inline-progression-dimension. Adjusting end-indent based on
>> > overconstrained geometry rules (XSL 1.1, ch. 5.3.4)
>> > Apr 3, 2009 10:27:23 AM org.apache.fop.events.LoggingEventListener
>> > processEvent
>> > INFO: An fo:block  (See position 730:30) is wider than the available
>> room
>> > in inline-progression-dimension. Adjusting end-indent based on
>> > overconstrained geometry rules (XSL 1.1, ch. 5.3.4)
>> > Apr 3, 2009 10:27:23 AM org.apache.fop.events.LoggingEventListener
>> > processEvent
>> > WARNING: Font "Thai,normal,400" not found. Substituting with
>> > "any,normal,400".
>> > Success!
>> > 
>> > Any help?
>> > 
>> > -
>> > Rey
>> > 
>> 
>> -- 
>> View this message in context:
>> http://www.nabble.com/Printing-in-FOP-using-PageableRenderer-with-Unicode-characters-tp22860872p22863060.html
>> Sent from the FOP - Users mailing list archive at Nabble.com.
>> 
> 
> 
> 
> Jeremias Maerki
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Printing-in-FOP-using-PageableRenderer-with-Unicode-characters-tp22860872p22864382.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: Printing in FOP using PageableRenderer with Unicode characters

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
Hi Rey,

there was a bug which I've just fixed: http://svn.apache.org/viewvc?rev=761554&view=rev

Please update your working copy, retry and let me know if it works.

BTW, you can remove the two "font-triplet" elements from the
configuration. They are ignored where you placed them. "font-triplet"
is only available inside a "font" element. With "directory", the
font triplets are automatically generated from the information in the
font itself. But that also means you have to use the font's actual name
inside XSL-FO unless you use the font-substitution feature:
http://xmlgraphics.apache.org/fop/trunk/fonts.html#substitution

On 03.04.2009 09:02:20 Reyal wrote:
> 
> As a sidenote, the same configuration file I used to generate a pdf file and
> the barcode and thai characters are present. I just added new renderer for
> pdf(mime="application/pdf") with the same configuration of fonts as in
> mime="application/X-fop-print" renderer. I just wonder what I have done
> wrong in this case.
> 
> Thanks in advance.
> 
> -
> Rey
> 
> 
> Reyal wrote:
> > 
> > Good day,
> > 
> > I tried to follow this thread here.
> > http://www.nabble.com/Direct-Printing-and-setting-print-parameters-in-FOP-0.94-tp16747594p22087146.html
> > 
> > I also build my own copy from fop-trunk for my testing and
> > use your example. The printing looks cool but still got a warning when
> > using barcode and thai characters. The printed output have no barcode
> > and thai characters in it. What I mean is that the fonts were not applied.
> > 
> > Below is the code snippet:
> > public void printFO(File fo) throws IOException, FOPException,
> > 			TransformerException, PrintException {
> > 
> > 		// Set up DocPrintJob instance
> > 		DocPrintJob printJob = createDocPrintJob();
> > 		// Set up a custom user agent so we can supply our own renderer instance
> > 		FOUserAgent userAgent = fopFactory.newFOUserAgent();
> > 		
> > 		PageableRenderer renderer = new PageableRenderer();
> > 		renderer.setUserAgent(userAgent);
> > 		userAgent.setRendererOverride(renderer);
> > 
> > 		// Construct FOP with desired output format
> > 		Fop fop = fopFactory.newFop(userAgent);
> > 		try {
> > 			fopFactory.setUserConfig(new File("xml/fopConf.xml"));
> > 		} catch (SAXException e) {
> > 			// TODO Auto-generated catch block
> > 			e.printStackTrace();
> > 		}
> > 
> > 		// Setup JAXP using identity transformer
> > 		TransformerFactory factory = TransformerFactory.newInstance();
> > 		Transformer transformer = factory.newTransformer(); // identity
> > 															// transformer
> > 
> > 		// Setup input stream
> > 		Source src = new StreamSource(fo);
> > 
> > 		// Resulting SAX events (the generated FO) must be piped through to FOP
> > 		Result res = new SAXResult(fop.getDefaultHandler());
> > 
> > 		// Start XSLT transformation and FOP processing
> > 		transformer.transform(src, res);
> > 
> > 		Doc doc = new SimpleDoc(renderer, DocFlavor.SERVICE_FORMATTED.PAGEABLE,
> > 				null);
> > 		printJob.print(doc, null);
> > 	}
> > 
> > ------------[fopConf.xml]-------------------------
> > <?xml version="1.0"?>
> > <fop version="1.0">
> > 
> >   <!-- Base URL for resolving relative URLs -->
> >   <base>.</base>
> >   
> >   <!-- Font Base URL for resolving relative font URLs -->
> >   <font-base>./</font-base>
> >   <renderers>
> >      <renderer mime="application/X-fop-print">
> >       <fonts>
> >         <directory recursive="true">D:/PRINTING</directory>
> >         
> >           <font-triplet name="Barcode" style="normal" weight="normal"/>
> >         
> >                 
> >         
> >           <font-triplet name="Thai" style="normal" weight="normal"/>
> >         
> >       </fonts>
> >     </renderer>
> >   </renderers>
> > </fop>
> > 
> > When I run the above, I got the warning messages below:
> > 
> > Apr 3, 2009 10:27:23 AM org.apache.fop.events.LoggingEventListener
> > processEvent
> > WARNING: Font "Barcode,normal,700" not found. Substituting with
> > "any,normal,700".
> > Apr 3, 2009 10:27:23 AM org.apache.fop.events.LoggingEventListener
> > processEvent
> > WARNING: Line 1 of a paragraph overflows the available area by 29345
> > millipoints. (See position 697:49)
> > Apr 3, 2009 10:27:23 AM org.apache.fop.events.LoggingEventListener
> > processEvent
> > INFO: An fo:block  (See position 708:30) is wider than the available room
> > in inline-progression-dimension. Adjusting end-indent based on
> > overconstrained geometry rules (XSL 1.1, ch. 5.3.4)
> > Apr 3, 2009 10:27:23 AM org.apache.fop.events.LoggingEventListener
> > processEvent
> > INFO: An fo:block  (See position 730:30) is wider than the available room
> > in inline-progression-dimension. Adjusting end-indent based on
> > overconstrained geometry rules (XSL 1.1, ch. 5.3.4)
> > Apr 3, 2009 10:27:23 AM org.apache.fop.events.LoggingEventListener
> > processEvent
> > WARNING: Font "Thai,normal,400" not found. Substituting with
> > "any,normal,400".
> > Success!
> > 
> > Any help?
> > 
> > -
> > Rey
> > 
> 
> -- 
> View this message in context: http://www.nabble.com/Printing-in-FOP-using-PageableRenderer-with-Unicode-characters-tp22860872p22863060.html
> Sent from the FOP - Users mailing list archive at Nabble.com.
> 



Jeremias Maerki


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


Re: Printing in FOP using PageableRenderer with Unicode characters

Posted by Reyal <re...@gmail.com>.
As a sidenote, the same configuration file I used to generate a pdf file and
the barcode and thai characters are present. I just added new renderer for
pdf(mime="application/pdf") with the same configuration of fonts as in
mime="application/X-fop-print" renderer. I just wonder what I have done
wrong in this case.

Thanks in advance.

-
Rey


Reyal wrote:
> 
> Good day,
> 
> I tried to follow this thread here.
> http://www.nabble.com/Direct-Printing-and-setting-print-parameters-in-FOP-0.94-tp16747594p22087146.html
> 
> I also build my own copy from fop-trunk for my testing and
> use your example. The printing looks cool but still got a warning when
> using barcode and thai characters. The printed output have no barcode
> and thai characters in it. What I mean is that the fonts were not applied.
> 
> Below is the code snippet:
> public void printFO(File fo) throws IOException, FOPException,
> 			TransformerException, PrintException {
> 
> 		// Set up DocPrintJob instance
> 		DocPrintJob printJob = createDocPrintJob();
> 		// Set up a custom user agent so we can supply our own renderer instance
> 		FOUserAgent userAgent = fopFactory.newFOUserAgent();
> 		
> 		PageableRenderer renderer = new PageableRenderer();
> 		renderer.setUserAgent(userAgent);
> 		userAgent.setRendererOverride(renderer);
> 
> 		// Construct FOP with desired output format
> 		Fop fop = fopFactory.newFop(userAgent);
> 		try {
> 			fopFactory.setUserConfig(new File("xml/fopConf.xml"));
> 		} catch (SAXException e) {
> 			// TODO Auto-generated catch block
> 			e.printStackTrace();
> 		}
> 
> 		// Setup JAXP using identity transformer
> 		TransformerFactory factory = TransformerFactory.newInstance();
> 		Transformer transformer = factory.newTransformer(); // identity
> 															// transformer
> 
> 		// Setup input stream
> 		Source src = new StreamSource(fo);
> 
> 		// Resulting SAX events (the generated FO) must be piped through to FOP
> 		Result res = new SAXResult(fop.getDefaultHandler());
> 
> 		// Start XSLT transformation and FOP processing
> 		transformer.transform(src, res);
> 
> 		Doc doc = new SimpleDoc(renderer, DocFlavor.SERVICE_FORMATTED.PAGEABLE,
> 				null);
> 		printJob.print(doc, null);
> 	}
> 
> ------------[fopConf.xml]-------------------------
> <?xml version="1.0"?>
> <fop version="1.0">
> 
>   <!-- Base URL for resolving relative URLs -->
>   <base>.</base>
>   
>   <!-- Font Base URL for resolving relative font URLs -->
>   <font-base>./</font-base>
>   <renderers>
>      <renderer mime="application/X-fop-print">
>       <fonts>
>         <directory recursive="true">D:/PRINTING</directory>
>         
>           <font-triplet name="Barcode" style="normal" weight="normal"/>
>         
>                 
>         
>           <font-triplet name="Thai" style="normal" weight="normal"/>
>         
>       </fonts>
>     </renderer>
>   </renderers>
> </fop>
> 
> When I run the above, I got the warning messages below:
> 
> Apr 3, 2009 10:27:23 AM org.apache.fop.events.LoggingEventListener
> processEvent
> WARNING: Font "Barcode,normal,700" not found. Substituting with
> "any,normal,700".
> Apr 3, 2009 10:27:23 AM org.apache.fop.events.LoggingEventListener
> processEvent
> WARNING: Line 1 of a paragraph overflows the available area by 29345
> millipoints. (See position 697:49)
> Apr 3, 2009 10:27:23 AM org.apache.fop.events.LoggingEventListener
> processEvent
> INFO: An fo:block  (See position 708:30) is wider than the available room
> in inline-progression-dimension. Adjusting end-indent based on
> overconstrained geometry rules (XSL 1.1, ch. 5.3.4)
> Apr 3, 2009 10:27:23 AM org.apache.fop.events.LoggingEventListener
> processEvent
> INFO: An fo:block  (See position 730:30) is wider than the available room
> in inline-progression-dimension. Adjusting end-indent based on
> overconstrained geometry rules (XSL 1.1, ch. 5.3.4)
> Apr 3, 2009 10:27:23 AM org.apache.fop.events.LoggingEventListener
> processEvent
> WARNING: Font "Thai,normal,400" not found. Substituting with
> "any,normal,400".
> Success!
> 
> Any help?
> 
> -
> Rey
> 

-- 
View this message in context: http://www.nabble.com/Printing-in-FOP-using-PageableRenderer-with-Unicode-characters-tp22860872p22863060.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