changing the look of the PDF output by FOP

2016-01-31 Thread Peter Michaux
Hi,

I'm new to FOP and feeling a little disoriented about the correct way to
change the look of the PDF that is output by FOP.

My source is an AsciiDoc text file and I have no trouble converting that to
a Docbook XML file.

$ asciidoc --backend=docbook45 book.txt

I can then use the fop command line tool to convert to a PDF file.

$ fop-2.1/fop -xml book.xml \
  -xsl docbook-xsl-ns-1.79.1/fo/docbook.xsl \
  -pdf book.pdf

The default look of the produced book.pdf is nice but I'd like to adjust
font families, font sizes, margins, etc.

I did discover one way to customize the fonts by creating a fop.xconf file
with the following content



















and then using the following command

$ fop-2.1/fop -c fop.xconf\
  -xml book.xml   \
  -xsl docbook-xsl-ns-1.79.1/fo/docbook.xsl   \
  -param body.font.family Minion-Regular  \
  -param title.font.family Myriad-Condensed   \
  -param monospace.font.family Andale-Mono\
  -pdf book.pdf

Even though the above font setting technique was something I learned from a
blog on the Web, at this point, I'm already unsure if I'm going in the
right to doing this kind of customization properly or not. I imagine there
is a better way to than passing a growing number of parameters to the fop
command line tool.

Then I tried to see if I could have an affect on margins and the footer
font.

$ fop-2.1/fop -c fop.xconf\
  -xml book.xml   \
  -xsl docbook-xsl-ns-1.79.1/fo/docbook.xsl   \
  -param body.font.family Minion-Regular  \
  -param title.font.family Myriad-Condensed   \
  -param page.margin.top 0\
  -param footer.content.font-family Helvetica \
  -param monospace.font.family Andale-Mono\
  -pdf book.pdf

The page.margin.top param did work. A small success!

The footer.content.font-family param did not work. I also tried
footer.content.properties.font-family, footer.content.font.family, and
footer.content.properties.font.family without finding the right solution.

What's the right way to configure things so fop is outputting the PDF I
dream of sharing with folks?

Thanks!

Peter


Re: changing the look of the PDF output by FOP

2016-01-31 Thread Glenn Adams
The first thing you need to understand is that the input to FOP is XSL-FO
[1]. Although FOP provides a built-in utility mechanism to convert
arbitrary XML to XSL-FO by means of an XSLT transformation as a
pre-processing step, this mechanism is convenience function only, and
unrelated to FOP functionality in general.

So, you should think of FOP as a transformation pipeline that converts
XSL-FO into some rendered form, like PDF. If we add the convenience
function above to the description, you get:

XML + XSLT -> XSL-FO -> {Rendered Format, e.g., PDF}

To understand what the rendered output is, you need to understand XSL-FO
enough to control the pre-processing stage (XML + XSLT -> XSL-FO). The real
functionality of FOP is all in the second part of the pipeline: XSL-FO ->
Rendered Format.

[1] https://www.w3.org/TR/xsl/




On Sun, Jan 31, 2016 at 9:23 PM, Peter Michaux 
wrote:

> Hi,
>
> I'm new to FOP and feeling a little disoriented about the correct way to
> change the look of the PDF that is output by FOP.
>
> My source is an AsciiDoc text file and I have no trouble converting that
> to a Docbook XML file.
>
> $ asciidoc --backend=docbook45 book.txt
>
> I can then use the fop command line tool to convert to a PDF file.
>
> $ fop-2.1/fop -xml book.xml \
>   -xsl docbook-xsl-ns-1.79.1/fo/docbook.xsl \
>   -pdf book.pdf
>
> The default look of the produced book.pdf is nice but I'd like to adjust
> font families, font sizes, margins, etc.
>
> I did discover one way to customize the fonts by creating a fop.xconf file
> with the following content
>
> 
> 
> 
> 
>  embed-url="fonts/MyriadPro-Cond.otf" embedding-mode="subset">
>  style="normal" weight="normal"/>
> 
>  embed-url="fonts/MinionPro-Regular.otf" embedding-mode="subset">
>  weight="normal"/>
> 
>  embedding-mode="subset">
>  weight="normal"/>
> 
> 
> 
> 
> 
>
> and then using the following command
>
> $ fop-2.1/fop -c fop.xconf\
>   -xml book.xml   \
>   -xsl docbook-xsl-ns-1.79.1/fo/docbook.xsl   \
>   -param body.font.family Minion-Regular  \
>   -param title.font.family Myriad-Condensed   \
>   -param monospace.font.family Andale-Mono\
>   -pdf book.pdf
>
> Even though the above font setting technique was something I learned from
> a blog on the Web, at this point, I'm already unsure if I'm going in the
> right to doing this kind of customization properly or not. I imagine there
> is a better way to than passing a growing number of parameters to the fop
> command line tool.
>
> Then I tried to see if I could have an affect on margins and the footer
> font.
>
> $ fop-2.1/fop -c fop.xconf\
>   -xml book.xml   \
>   -xsl docbook-xsl-ns-1.79.1/fo/docbook.xsl   \
>   -param body.font.family Minion-Regular  \
>   -param title.font.family Myriad-Condensed   \
>   -param page.margin.top 0\
>   -param footer.content.font-family Helvetica \
>   -param monospace.font.family Andale-Mono\
>   -pdf book.pdf
>
> The page.margin.top param did work. A small success!
>
> The footer.content.font-family param did not work. I also tried
> footer.content.properties.font-family, footer.content.font.family, and
> footer.content.properties.font.family without finding the right solution.
>
> What's the right way to configure things so fop is outputting the PDF I
> dream of sharing with folks?
>
> Thanks!
>
> Peter
>
>