You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Yanick Gaudet <YG...@DINMAR.COM> on 2002/08/15 17:56:51 UTC

Printing Multi-page document

Hi,

I need to print a Multi-page document. The JSVGCanvas Renders the document
perfectly, but when I try to print the Document using the PrintTranscoder
all of the document is printed on one sheet of paper. (Good for the trees
not for the users).

I need some hints as soon as possible to be able to prove that the concept
works.

I'm using batik 1.5b3 on Java 1.4.

Everything else works like a charm and the component(s) are relatively easy
to use

Thank you very much.
Yanick



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


RE: Printing Multi-page document

Posted by Yanick Gaudet <YG...@DINMAR.COM>.
Thanks for all you help, I'll give that a shot and keep you posted.
Yanick
-----Original Message-----
From: Thomas E Deweese [mailto:thomas.deweese@kodak.com]
Sent: August 19, 2002 9:59 AM
To: Batik Users
Subject: RE: Printing Multi-page document


>>>>> "YG" == Yanick Gaudet <YG...@dinmar.com> writes:

YG> I'd be happy to create KEY_MULTI_PAGE_PRINT hint for the
YG> printTrancoder.  Would you mind telling me how you would do that?
YG> Since I'm pretty new with the SVG/Batik detail will be
YG> appreciated.

    If you look at the PrintTranscoder class you will see where all
the other KEY's are defined, you should add your's to the list.  I
would suggest splitting the definition into pages across/down (you
could extend the types supported for keys to include Dimension - see
what is done for Rectangle2D in
org.apache.batik.transcoder.keys.Rectangle2DKey).

    Then in the 'print(Graphics _g, PageFormat pageFormat, int
pageIndex) method you can figure out what part of what image is being
printed by taking 'pageIndex % (pagesAcrosss*pagesDown)'.  Then update
the computation of the transform so it scales/translates the image so
just the desired part fills the current page. (note that 'bounds' in
this code is the section of the document to print with everything
factored in, so this is what you want to spread across multiple
pages).

    Setting up the affine transform may be a bit tricky but there
isn't much I can do to help you there (other than write the code :).

YG> Thanks you very much.  Yanick

    Good luck, I look forward to hearing back from you.

    Ohh, if you aren't using CVS yet I would suggest using it for this
as it makes it very easy to submit the changes (just 'cvs diff').

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





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


RE: Printing Multi-page document

Posted by Thomas E Deweese <th...@kodak.com>.
>>>>> "YG" == Yanick Gaudet <YG...@dinmar.com> writes:

YG> I'd be happy to create KEY_MULTI_PAGE_PRINT hint for the
YG> printTrancoder.  Would you mind telling me how you would do that?
YG> Since I'm pretty new with the SVG/Batik detail will be
YG> appreciated.

    If you look at the PrintTranscoder class you will see where all
the other KEY's are defined, you should add your's to the list.  I
would suggest splitting the definition into pages across/down (you
could extend the types supported for keys to include Dimension - see
what is done for Rectangle2D in
org.apache.batik.transcoder.keys.Rectangle2DKey).

    Then in the 'print(Graphics _g, PageFormat pageFormat, int
pageIndex) method you can figure out what part of what image is being
printed by taking 'pageIndex % (pagesAcrosss*pagesDown)'.  Then update
the computation of the transform so it scales/translates the image so
just the desired part fills the current page. (note that 'bounds' in
this code is the section of the document to print with everything
factored in, so this is what you want to spread across multiple
pages).

    Setting up the affine transform may be a bit tricky but there
isn't much I can do to help you there (other than write the code :).

YG> Thanks you very much.  Yanick

    Good luck, I look forward to hearing back from you.

    Ohh, if you aren't using CVS yet I would suggest using it for this
as it makes it very easy to submit the changes (just 'cvs diff').

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


RE: Printing Multi-page document

Posted by Yanick Gaudet <YG...@DINMAR.COM>.
I'd be happy to create KEY_MULTI_PAGE_PRINT hint for the printTrancoder.
Would you mind telling me how you would do that? Since I'm pretty new with
the SVG/Batik detail will be appreciated.

Thanks you very much.
Yanick

-----Original Message-----
From: Thomas E Deweese [mailto:thomas.deweese@kodak.com]
Sent: August 19, 2002 9:25 AM
To: Batik Users
Subject: RE: Printing Multi-page document


>>>>> "YG" == Yanick Gaudet <YG...@dinmar.com> writes:

YG> the AOI is propably the best option. I can just loop through the
YG> pages.  How would I find the rectangle for the page to print?

    Parse and understand the attributes on the outermost SVG :)

    Roughly speaking if it has a viewBox attribute then that will give
the bounds of the image to render.  So then you can just divide w/h by
pages across/down (probably paying attention to the aspect ratio in
the process) and add in the viewbox's x/y.

    If it just has width/height attributes then you may need to deal
with units, but in the end it's the same as above except x/y are
always zero.

    Once again all this stuff is much easier inside the
PrintTranscoder since it has parsed and understood all the attributes
and so all the information is immediately available and it is much
more likely to be correct (there are cases where the outermost svg has
no w/h or viewbox in which case you want to use the bounding box of
the contents of the SVG which would essentially require you to build
the GVT tree to get)

    I think your time would be better spend adding a Multi-Page hint
to the PrintTranscoder directly, this is where the functionality
belongs, plus you would be able to give something back to the
community. :)

   Anyway, good luck!

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




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


RE: Printing Multi-page document

Posted by Thomas E Deweese <th...@kodak.com>.
>>>>> "YG" == Yanick Gaudet <YG...@dinmar.com> writes:

YG> the AOI is propably the best option. I can just loop through the
YG> pages.  How would I find the rectangle for the page to print?

    Parse and understand the attributes on the outermost SVG :)

    Roughly speaking if it has a viewBox attribute then that will give
the bounds of the image to render.  So then you can just divide w/h by
pages across/down (probably paying attention to the aspect ratio in
the process) and add in the viewbox's x/y.

    If it just has width/height attributes then you may need to deal
with units, but in the end it's the same as above except x/y are
always zero.

    Once again all this stuff is much easier inside the
PrintTranscoder since it has parsed and understood all the attributes
and so all the information is immediately available and it is much
more likely to be correct (there are cases where the outermost svg has
no w/h or viewbox in which case you want to use the bounding box of
the contents of the SVG which would essentially require you to build
the GVT tree to get)

    I think your time would be better spend adding a Multi-Page hint
to the PrintTranscoder directly, this is where the functionality
belongs, plus you would be able to give something back to the
community. :)

   Anyway, good luck!

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


RE: Printing Multi-page document

Posted by Yanick Gaudet <YG...@DINMAR.COM>.
Yeah,

the AOI is propably the best option. I can just loop through the pages.
How would I find the rectangle for the page to print?

Thanks again
Yanick

-----Original Message-----
From: Thomas E Deweese [mailto:thomas.deweese@kodak.com]
Sent: August 19, 2002 8:44 AM
To: Batik Users
Subject: RE: Printing Multi-page document


>>>>> "YG" == Yanick Gaudet <YG...@dinmar.com> writes:

YG> Hi, Since I already have the document within the App can't I just
YG> modify the Document and set it to the PrintTranscoder?

YG> Question: How would you set the viewBox?

    If you are talking directly to the transcoder the easiest way to
put part of an image on the page is the AOI hint
(SVGAbstractTranscoder.KEY_AOI).  It takes a Rectangle2D that
indicates the rectangle to print.  However since there is only one AOI
hint per transcoder you can use the PrintTranscoder with multiple
TranscoderInputs and this feature.  You might be able to get the
correct behaviour by providing a fake URL that included the viewBox
when you construct the TranscoderInput, but this would be a hack that
might break in the future.  Really the PrintTranscoder should be
updated to allow users to specify '1/N up' printing.


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





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


RE: Printing Multi-page document

Posted by Thomas E Deweese <th...@kodak.com>.
>>>>> "YG" == Yanick Gaudet <YG...@dinmar.com> writes:

YG> Hi, Since I already have the document within the App can't I just
YG> modify the Document and set it to the PrintTranscoder?

YG> Question: How would you set the viewBox?

    If you are talking directly to the transcoder the easiest way to
put part of an image on the page is the AOI hint
(SVGAbstractTranscoder.KEY_AOI).  It takes a Rectangle2D that
indicates the rectangle to print.  However since there is only one AOI
hint per transcoder you can use the PrintTranscoder with multiple
TranscoderInputs and this feature.  You might be able to get the
correct behaviour by providing a fake URL that included the viewBox
when you construct the TranscoderInput, but this would be a hack that
might break in the future.  Really the PrintTranscoder should be
updated to allow users to specify '1/N up' printing.


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


RE: Printing Multi-page document

Posted by Yanick Gaudet <YG...@DINMAR.COM>.
Hi,

Since I already have the document within the App can't I just modify the
Document
and set it to the PrintTranscoder?

Question: How would you set the viewBox?

Thanks
Yanick

-----Original Message-----
From: Thomas E Deweese [mailto:thomas.deweese@kodak.com]
Sent: August 19, 2002 7:53 AM
To: Batik Users
Subject: Re: Printing Multi-page document


>>>>> "J" == J Aaron Farr <ja...@yahoo.com> writes:

J> --- Keiron Liddle <ke...@aftexsw.com> wrote:
>> On Thu, 2002-08-15 at 17:56, Yanick Gaudet wrote: > Hi,
>> >
>> > I need to print a Multi-page document. The JSVGCanvas Renders the
>> > document perfectly, but when I try to print the Document using
>> > the PrintTranscoder all of the document is printed on one sheet
>> > of paper. (Good for the trees not for the users).

   The architecture of Batik makes this pretty easy to do but
currently there isn't any way to do this from a really simple command
line or API.  You could call the PrintTranscoder repeatedly with a URL
that had a different svg viewBox fragment (checkout chapter 17 of the
SVG spec).  This won't be particularly efficent as it will read/parse
the document multiple times but this may meet your needs.

>> One possible way would be to create a pdf document with the
>> different areas on different pages.
>>

J> SVG to PDF?  Using what, XSL?  Anyone have an example or something
J> about this?

   You want to look at the FOP project: 'xml.apache.org/fop'.  It
allows you to use XSL-FO with embedded svg.

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





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


Re: Printing Multi-page document

Posted by Thomas E Deweese <th...@kodak.com>.
>>>>> "J" == J Aaron Farr <ja...@yahoo.com> writes:

J> --- Keiron Liddle <ke...@aftexsw.com> wrote:
>> On Thu, 2002-08-15 at 17:56, Yanick Gaudet wrote: > Hi,
>> > 
>> > I need to print a Multi-page document. The JSVGCanvas Renders the
>> > document perfectly, but when I try to print the Document using
>> > the PrintTranscoder all of the document is printed on one sheet
>> > of paper. (Good for the trees not for the users).

   The architecture of Batik makes this pretty easy to do but
currently there isn't any way to do this from a really simple command
line or API.  You could call the PrintTranscoder repeatedly with a URL
that had a different svg viewBox fragment (checkout chapter 17 of the
SVG spec).  This won't be particularly efficent as it will read/parse
the document multiple times but this may meet your needs.

>> One possible way would be to create a pdf document with the
>> different areas on different pages.
>> 

J> SVG to PDF?  Using what, XSL?  Anyone have an example or something
J> about this?

   You want to look at the FOP project: 'xml.apache.org/fop'.  It
allows you to use XSL-FO with embedded svg.

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


Re: Printing Multi-page document

Posted by J Aaron Farr <ja...@yahoo.com>.
--- Keiron Liddle <ke...@aftexsw.com> wrote:
> On Thu, 2002-08-15 at 17:56, Yanick Gaudet wrote:
> > Hi,
> > 
> > I need to print a Multi-page document. The JSVGCanvas Renders the document
> > perfectly, but when I try to print the Document using the PrintTranscoder
> > all of the document is printed on one sheet of paper. (Good for the trees
> > not for the users).
> 
> One possible way would be to create a pdf document with the different
> areas on different pages.
> 

SVG to PDF?  Using what, XSL?  Anyone have an example or something about this?

Thanks,
jaaron

__________________________________________________
Do You Yahoo!?
HotJobs - Search Thousands of New Jobs
http://www.hotjobs.com

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


Re: Printing Multi-page document

Posted by J Aaron Farr <ja...@yahoo.com>.
--- Keiron Liddle <ke...@aftexsw.com> wrote:
> On Thu, 2002-08-15 at 17:56, Yanick Gaudet wrote:
> > Hi,
> > 
> > I need to print a Multi-page document. The JSVGCanvas Renders the document
> > perfectly, but when I try to print the Document using the PrintTranscoder
> > all of the document is printed on one sheet of paper. (Good for the trees
> > not for the users).
> 
> One possible way would be to create a pdf document with the different
> areas on different pages.
> 

SVG to PDF?  Using what, XSL?  Anyone have an example or something about this?

Thanks,
jaaron

__________________________________________________
Do You Yahoo!?
HotJobs - Search Thousands of New Jobs
http://www.hotjobs.com

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


Re: Printing Multi-page document

Posted by J Aaron Farr <ja...@yahoo.com>.
--- Keiron Liddle <ke...@aftexsw.com> wrote:
> On Thu, 2002-08-15 at 17:56, Yanick Gaudet wrote:
> > Hi,
> > 
> > I need to print a Multi-page document. The JSVGCanvas Renders the document
> > perfectly, but when I try to print the Document using the PrintTranscoder
> > all of the document is printed on one sheet of paper. (Good for the trees
> > not for the users).
> 
> One possible way would be to create a pdf document with the different
> areas on different pages.
> 

SVG to PDF?  Using what, XSL?  Anyone have an example or something about this?

Thanks,
jaaron

__________________________________________________
Do You Yahoo!?
HotJobs - Search Thousands of New Jobs
http://www.hotjobs.com

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


Re: Printing Multi-page document

Posted by Keiron Liddle <ke...@aftexsw.com>.
On Thu, 2002-08-15 at 17:56, Yanick Gaudet wrote:
> Hi,
> 
> I need to print a Multi-page document. The JSVGCanvas Renders the document
> perfectly, but when I try to print the Document using the PrintTranscoder
> all of the document is printed on one sheet of paper. (Good for the trees
> not for the users).

One possible way would be to create a pdf document with the different
areas on different pages.

> I need some hints as soon as possible to be able to prove that the concept
> works.
> 
> I'm using batik 1.5b3 on Java 1.4.



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