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 Ramakrishna <ra...@gmail.com> on 2007/02/21 01:55:40 UTC

FOP -Printing specified number of pages

Hi,

I am using Appache FOP 0.93 to create PDF output and print outs from
XML and XLS-FO file. I am invoking the FOP through the provided
FOB.bat file passing the command line arguements for xml file, xsl
file and the -print option. I would like to know how to provide the
"From Page" and "To Page" options to the FOP to print the specified
number of pages.
FOP.bat  -xml Data.xml -xsl FO_Template.xsl -print

how to specify the -Dstart=2 and -Dend=4

The following statement does not work
FOP.bat  -xml Data.xml -xsl FO_Template.xsl -print -Dstart=2 -Dend=4

Please provide inputs on this.

Thanks,
Ram

Re: FOP -Printing specified number of pages

Posted by Andreas L Delmelle <a_...@pandora.be>.
On Feb 22, 2007, at 21:47, Ramakrishna wrote:

Hi Ram,

> Thanks Andreas!

FYI: I have opened a Bugzilla entry (41687) for this issue, so we  
don't lose track of it.
If you want to be notified about changes in status, feel free to add  
yourself to the CC-list for that bug.


Cheers,

Andreas

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


Re: FOP -Printing specified number of pages

Posted by Ramakrishna <ra...@gmail.com>.
Thanks Andreas!

On 2/22/07, Andreas L Delmelle <a_...@pandora.be> wrote:
>
> On Feb 22, 2007, at 20:34, Ramakrishna wrote:
>
> Hi,
>
> > I tried to print with the .fo file instead of giving the xml and
> > xsl files but still it printed all the pages. There is slight
> > variation in the command usage
> >
> > I gave the command as
> > java -Dstart=2 -Dend=2 org.apache.fop.cli.Main infile.fo -print
> >
> > The following command gives Exception in thread "main"
> > java.lang.NoSuchMethodError: main
> > java -Dstart=2 -Dend=2 org.apache.fop.apps.Fop infile.fo -print
> From this we can tell that you use FOP 0.92b or higher.
> Unfortunately, it seems like this functionality was broken in the
> trunk code at some point. :(
>
> I'd try looking at it myself, but am currently focusing on other
> parts of the code, and don't feel much for switching context ATM, so
> it could take a while.
>
> In the meantime, a possible workaround for you could be to always
> render to PDF and print the desired pages from it with an external
> tool like GhostScript or pdftk. This has the benefit of the printed
> output matching the PDF much closer.
> While substantial efforts have been made to make the different
> renderers' outputs as close to each other as possible, this is not
> guaranteed to be the case for PDF and Print output (the PrintRenderer
> depends on Java AWT, the PDFRenderer does not; in borderline cases
> this could even lead to the printed result having slightly different
> page-breaks, although that should be very rare)
>
> If your printer understands PS, then you could also consider that
> format. The basis of the PDF and PS renderers are the same.
>
>
> HTH!
>
> Cheers,
>
> Andreas
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
>
>

Re: FOP -Printing specified number of pages

Posted by Andreas L Delmelle <a_...@pandora.be>.
On Feb 22, 2007, at 20:34, Ramakrishna wrote:

Hi,

> I tried to print with the .fo file instead of giving the xml and  
> xsl files but still it printed all the pages. There is slight  
> variation in the command usage
>
> I gave the command as
> java -Dstart=2 -Dend=2 org.apache.fop.cli.Main infile.fo -print
>
> The following command gives Exception in thread "main"  
> java.lang.NoSuchMethodError: main
> java -Dstart=2 -Dend=2 org.apache.fop.apps.Fop infile.fo -print
 From this we can tell that you use FOP 0.92b or higher.
Unfortunately, it seems like this functionality was broken in the  
trunk code at some point. :(

I'd try looking at it myself, but am currently focusing on other  
parts of the code, and don't feel much for switching context ATM, so  
it could take a while.

In the meantime, a possible workaround for you could be to always  
render to PDF and print the desired pages from it with an external  
tool like GhostScript or pdftk. This has the benefit of the printed  
output matching the PDF much closer.
While substantial efforts have been made to make the different  
renderers' outputs as close to each other as possible, this is not  
guaranteed to be the case for PDF and Print output (the PrintRenderer  
depends on Java AWT, the PDFRenderer does not; in borderline cases  
this could even lead to the printed result having slightly different  
page-breaks, although that should be very rare)

If your printer understands PS, then you could also consider that  
format. The basis of the PDF and PS renderers are the same.


HTH!

Cheers,

Andreas

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


Re: FOP -Printing specified number of pages

Posted by Ramakrishna <ra...@gmail.com>.
Hi,

I tried to print with the .fo file instead of giving the xml and xsl files
but still it printed all the pages. There is slight variation in the command
usage

I gave the command as

java -Dstart=2 -Dend=2 org.apache.fop.cli.Main infile.fo -print
The following command gives Exception in thread "main"
java.lang.NoSuchMethodError: main

java -Dstart=2 -Dend=2 org.apache.fop.apps.Fop infile.fo -print



On 2/22/07, Mukul Gandhi <ga...@gmail.com> wrote:
>
> Luis Ferro in another thread (in response to your question) explained
> about FOP -print option.
>
> Here is what I investigated just now (and agree to Luis's comments) -
> If you just type fop[.bat] on command line, various command line
> options are listed. One of them is:
> -print            input file will be rendered and sent to the printer
>                    see options with "-print help"
>
> Now when you type following on command line,
> fop[.bat] -print help
> following is displayed
> USAGE: -print [-Dstart=i] [-Dend=i] [-Dcopies=i] [-Deven=true|false]
> Example:
> java -Dstart=1 -Dend=2 org.apache.Fop.apps.Fop infile.fo -print
>
> This surely tells, that specifying various printing options from
> command line is possible. But the example suggests, that options can
> be set only with file of type .fo (this you need to investigate
> further).
>
> So your requirement that -print options should work with .xsl + .xml
> files seems to be not working. I think you can write a wrapper .bat
> file to suit your needs (if you want a 1 step process).
>
> Or otherwise, you could perform printing of .fo file in a 2 step
> manual process. i.e. in the first step use Xalan-J (bundled with FOP)
> to transform .xsl + .xml into .fo file. And in the 2nd step, you can
> print .fo file with the desired options.
>
> I haven't tried -print option with FOP before. You can perhaps try
> what I suggested, and see if it works for you.
>
> On 2/22/07, Ramakrishna <ra...@gmail.com> wrote:
> >
> > Hi
> >
> > Thanks for your comments, I found the following is the code in
> PrintRenderer
> > Class of FOP
> >
> >
> > privatevoid initializePrinterJob() throws IllegalArgumentException {
> >
> > // read from command-line options
> >
> > copies = getIntProperty("copies", 1);
> >
> > startNumber = getIntProperty("start", 1) - 1;
> >
> > endNumber = getIntProperty("end", -1);
> >
> > String str = System.getProperty("even" );
> >
> > if (str != null) {
> >
> > mode = Boolean.valueOf(str).booleanValue() ? EVEN : ODD;
> >
> > }
> >
> > printerJob = PrinterJob.getPrinterJob();
> >
> > printerJob.setJobName("FOP Document");
> >
> > printerJob.setCopies(copies);
> >
> > if (System.getProperty("dialog" ) != null) {
> >
> > if (!printerJob.printDialog()) {
> >
> > throw new IllegalArgumentException (
> >
> > "Printing cancelled by operator");
> >
> > }
> >
> > }
> >
> > printerJob.setPageable(this);
> >
> > }
> > It reads the start and end pages to print the specified pages. But not
> sure
> > of how to pass as argument.
> >
> >
> >
> > On 2/21/07, Mukul Gandhi <ga...@gmail.com> wrote:
> > >
> > > With FOP, you can just specify -print option, which sends the output
> > > to printer. But you cannot control the printing options (like start,
> > > and end pages) from FOP command line. I think the reason for this is;
> > > start and end page options is a facility provided by the printer
> > > driver. You cannot specify these options at an application level.
> > >
> > > But I think, you should get a printer dialog box (an OS feature) with
> > > -print FOP option, from where you can control start and end pages
> > > (just guessing..).
> > >
> > > Anybody might correct me, if I am wrong.
> > >
> > > On 2/21/07, Ramakrishna <ramakrishna.v@gmail.com > wrote:
> > > > Hi,
> > > >
> > > > I am using Appache FOP 0.93 to create PDF output and print outs from
> > > > XML and XLS-FO file. I am invoking the FOP through the provided
> > > > FOB.bat file passing the command line arguements for xml file, xsl
> > > > file and the -print option. I would like to know how to provide the
> > > > "From Page" and "To Page" options to the FOP to print the specified
> > > > number of pages.
> > > > FOP.bat  -xml Data.xml -xsl FO_Template.xsl -print
> > > >
> > > > how to specify the -Dstart=2 and -Dend=4
> > > >
> > > > The following statement does not work
> > > > FOP.bat  -xml Data.xml -xsl FO_Template.xsl -print -Dstart=2 -Dend=4
> > > >
> > > > Please provide inputs on this.
> > > >
> > > > Thanks,
> > > > Ram
> > > >
> > >
> > >
> > > --
> > > Regards,
> > > Mukul Gandhi
>
>
> --
> Regards,
> Mukul Gandhi
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
>
>

Re: FOP -Printing specified number of pages

Posted by Mukul Gandhi <ga...@gmail.com>.
Luis Ferro in another thread (in response to your question) explained
about FOP -print option.

Here is what I investigated just now (and agree to Luis's comments) -
If you just type fop[.bat] on command line, various command line
options are listed. One of them is:
 -print            input file will be rendered and sent to the printer
                    see options with "-print help"

Now when you type following on command line,
fop[.bat] -print help
following is displayed
USAGE: -print [-Dstart=i] [-Dend=i] [-Dcopies=i] [-Deven=true|false]
Example:
java -Dstart=1 -Dend=2 org.apache.Fop.apps.Fop infile.fo -print

This surely tells, that specifying various printing options from
command line is possible. But the example suggests, that options can
be set only with file of type .fo (this you need to investigate
further).

So your requirement that -print options should work with .xsl + .xml
files seems to be not working. I think you can write a wrapper .bat
file to suit your needs (if you want a 1 step process).

Or otherwise, you could perform printing of .fo file in a 2 step
manual process. i.e. in the first step use Xalan-J (bundled with FOP)
to transform .xsl + .xml into .fo file. And in the 2nd step, you can
print .fo file with the desired options.

I haven't tried -print option with FOP before. You can perhaps try
what I suggested, and see if it works for you.

On 2/22/07, Ramakrishna <ra...@gmail.com> wrote:
>
> Hi
>
> Thanks for your comments, I found the following is the code in PrintRenderer
> Class of FOP
>
>
> privatevoid initializePrinterJob() throws IllegalArgumentException {
>
> // read from command-line options
>
> copies = getIntProperty("copies", 1);
>
> startNumber = getIntProperty("start", 1) - 1;
>
> endNumber = getIntProperty("end", -1);
>
> String str = System.getProperty("even" );
>
> if (str != null) {
>
> mode = Boolean.valueOf(str).booleanValue() ? EVEN : ODD;
>
> }
>
> printerJob = PrinterJob.getPrinterJob();
>
> printerJob.setJobName("FOP Document");
>
> printerJob.setCopies(copies);
>
> if (System.getProperty("dialog" ) != null) {
>
> if (!printerJob.printDialog()) {
>
> throw new IllegalArgumentException (
>
> "Printing cancelled by operator");
>
> }
>
> }
>
> printerJob.setPageable(this);
>
> }
> It reads the start and end pages to print the specified pages. But not sure
> of how to pass as argument.
>
>
>
> On 2/21/07, Mukul Gandhi <ga...@gmail.com> wrote:
> >
> > With FOP, you can just specify -print option, which sends the output
> > to printer. But you cannot control the printing options (like start,
> > and end pages) from FOP command line. I think the reason for this is;
> > start and end page options is a facility provided by the printer
> > driver. You cannot specify these options at an application level.
> >
> > But I think, you should get a printer dialog box (an OS feature) with
> > -print FOP option, from where you can control start and end pages
> > (just guessing..).
> >
> > Anybody might correct me, if I am wrong.
> >
> > On 2/21/07, Ramakrishna <ramakrishna.v@gmail.com > wrote:
> > > Hi,
> > >
> > > I am using Appache FOP 0.93 to create PDF output and print outs from
> > > XML and XLS-FO file. I am invoking the FOP through the provided
> > > FOB.bat file passing the command line arguements for xml file, xsl
> > > file and the -print option. I would like to know how to provide the
> > > "From Page" and "To Page" options to the FOP to print the specified
> > > number of pages.
> > > FOP.bat  -xml Data.xml -xsl FO_Template.xsl -print
> > >
> > > how to specify the -Dstart=2 and -Dend=4
> > >
> > > The following statement does not work
> > > FOP.bat  -xml Data.xml -xsl FO_Template.xsl -print -Dstart=2 -Dend=4
> > >
> > > Please provide inputs on this.
> > >
> > > Thanks,
> > > Ram
> > >
> >
> >
> > --
> > Regards,
> > Mukul Gandhi


-- 
Regards,
Mukul Gandhi

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


Re: FOP -Printing specified number of pages

Posted by Ramakrishna <ra...@gmail.com>.
Hi

Thanks for your comments, I found the following is the code in PrintRenderer
Class of FOP


private void initializePrinterJob() throws IllegalArgumentException {

// read from command-line options

copies = getIntProperty("copies", 1);

startNumber = getIntProperty("start", 1) - 1;

endNumber = getIntProperty("end", -1);

String str = System.getProperty("even");

if (str != null) {

mode = Boolean.valueOf(str).booleanValue() ? EVEN : ODD;

}

printerJob = PrinterJob.getPrinterJob();

printerJob.setJobName("FOP Document");

printerJob.setCopies(copies);

if (System.getProperty("dialog") != null) {

if (!printerJob.printDialog()) {

throw new IllegalArgumentException(

"Printing cancelled by operator");

}

}

printerJob.setPageable(this);

}
It reads the start and end pages to print the specified pages. But not sure
of how to pass as argument.



On 2/21/07, Mukul Gandhi <ga...@gmail.com> wrote:
>
> With FOP, you can just specify -print option, which sends the output
> to printer. But you cannot control the printing options (like start,
> and end pages) from FOP command line. I think the reason for this is;
> start and end page options is a facility provided by the printer
> driver. You cannot specify these options at an application level.
>
> But I think, you should get a printer dialog box (an OS feature) with
> -print FOP option, from where you can control start and end pages
> (just guessing..).
>
> Anybody might correct me, if I am wrong.
>
> On 2/21/07, Ramakrishna <ra...@gmail.com> wrote:
> > Hi,
> >
> > I am using Appache FOP 0.93 to create PDF output and print outs from
> > XML and XLS-FO file. I am invoking the FOP through the provided
> > FOB.bat file passing the command line arguements for xml file, xsl
> > file and the -print option. I would like to know how to provide the
> > "From Page" and "To Page" options to the FOP to print the specified
> > number of pages.
> > FOP.bat  -xml Data.xml -xsl FO_Template.xsl -print
> >
> > how to specify the -Dstart=2 and -Dend=4
> >
> > The following statement does not work
> > FOP.bat  -xml Data.xml -xsl FO_Template.xsl -print -Dstart=2 -Dend=4
> >
> > Please provide inputs on this.
> >
> > Thanks,
> > Ram
> >
>
>
> --
> Regards,
> Mukul Gandhi
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
>
>

Re: FOP -Printing specified number of pages

Posted by Mukul Gandhi <ga...@gmail.com>.
With FOP, you can just specify -print option, which sends the output
to printer. But you cannot control the printing options (like start,
and end pages) from FOP command line. I think the reason for this is;
start and end page options is a facility provided by the printer
driver. You cannot specify these options at an application level.

But I think, you should get a printer dialog box (an OS feature) with
-print FOP option, from where you can control start and end pages
(just guessing..).

Anybody might correct me, if I am wrong.

On 2/21/07, Ramakrishna <ra...@gmail.com> wrote:
> Hi,
>
> I am using Appache FOP 0.93 to create PDF output and print outs from
> XML and XLS-FO file. I am invoking the FOP through the provided
> FOB.bat file passing the command line arguements for xml file, xsl
> file and the -print option. I would like to know how to provide the
> "From Page" and "To Page" options to the FOP to print the specified
> number of pages.
> FOP.bat  -xml Data.xml -xsl FO_Template.xsl -print
>
> how to specify the -Dstart=2 and -Dend=4
>
> The following statement does not work
> FOP.bat  -xml Data.xml -xsl FO_Template.xsl -print -Dstart=2 -Dend=4
>
> Please provide inputs on this.
>
> Thanks,
> Ram
>


-- 
Regards,
Mukul Gandhi

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