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 Joe Pairman <jo...@gmail.com> on 2010/07/20 17:19:16 UTC

OK to rescale SVG in PDF by changing just width and height values?

I'm including SVG graphics in PDF user guides. I need to control the
displayed size programmatically, effectively scaling the SVG including
all its content. The best result I've had so far is by changing only
the values of the width and height attributes, leaving everything else
untouched, and not even changing the viewBox. This would seem to fit
with Martin Jacobson's description here:
http://old.nabble.com/Affine-Transforms-on-JSVGCanvas-Objects-to25206324.html#a25209903
"The physical (ie display/print) dimensions are given by the "width"
and "height"  attributes, while
the drawing dimensions are described by the "viewPort" attribute."

Is there anything I should beware of when using this approach to
resize/rescale SVG? Anything I'm missing?

Thanks for any tips.
Joe

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


Re: OK to rescale SVG in PDF by changing just width and height values?

Posted by Joe Pairman <jo...@gmail.com>.
Thanks, Chris. Looks like a very useful tool where cleaning up the
source is important. I think will stick with the custom XSLT for now,
though, as we want to use as few tools as possible, and inserting a
viewBox is all we want to do. Should be pretty simple.
Joe

On Thu, Jul 22, 2010 at 11:17 PM, Chris Lilley <ch...@w3.org> wrote:
> On Thursday, July 22, 2010, 4:54:02 PM, Joe wrote:
>
> JP> Thanks again, Jonathan. I didn't realize that Batik came with an XSLT
> JP> processor. I can ask someone to help me write something for that,
> JP> including inserting a viewBox with appropriate values if there isn't
> JP> one in the first place.
>
> An existing tool, Scour, can do that.
> http://www.codedread.com/scour/
>
>
> --
>  Chris Lilley                    mailto:chris@w3.org
>  Technical Director, Interaction Domain
>  W3C Graphics Activity Lead
>  Co-Chair, W3C Hypertext CG
>
>

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


Re: OK to rescale SVG in PDF by changing just width and height values?

Posted by Chris Lilley <ch...@w3.org>.
On Thursday, July 22, 2010, 4:54:02 PM, Joe wrote:

JP> Thanks again, Jonathan. I didn't realize that Batik came with an XSLT
JP> processor. I can ask someone to help me write something for that,
JP> including inserting a viewBox with appropriate values if there isn't
JP> one in the first place.

An existing tool, Scour, can do that.
http://www.codedread.com/scour/


-- 
 Chris Lilley                    mailto:chris@w3.org
 Technical Director, Interaction Domain
 W3C Graphics Activity Lead
 Co-Chair, W3C Hypertext CG


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


Re: OK to rescale SVG in PDF by changing just width and height values?

Posted by Joe Pairman <jo...@gmail.com>.
Thanks again, Jonathan. I didn't realize that Batik came with an XSLT
processor. I can ask someone to help me write something for that,
including inserting a viewBox with appropriate values if there isn't
one in the first place.

On Thu, Jul 22, 2010 at 2:37 AM, jonathan wood
<jo...@gmail.com> wrote:
> Hi Joe,
>
>   Be aware that some illustrator versions ( < CS3?) can drop viewBox's upon
> export.  This may only be true for automated exports via javascript, I don't
> recall.
>
> If you are looking to add to a command line toolkit for your automated
> document creation, you might look into using XSLT to modify the w/h values.
> Xalan is packaged with Batik.
>
> http://en.wikipedia.org/wiki/XSLT
>
> http://xml.apache.org/xalan-j/
>
>
> On Wed, Jul 21, 2010 at 9:24 AM, Joe Pairman <jo...@gmail.com> wrote:
>>
>> Hi Thomas,
>>
>> On Wed, Jul 21, 2010 at 8:15 PM,  <th...@kodak.com> wrote:
>> > Hi Joe,
>> >
>> > Joe Pairman <jo...@gmail.com> wrote on 07/21/2010 03:20:49 AM:
>> >
>> >> Thanks for the tip, Jonathan. I tried a couple of test cases and it
>> >> seems the default is fine for that.
>> >
>> >    Just a word of caution that this will only work if the document
>> > has a viewBox attribute.
>>
>> Thanks. That's good to know. It *seems* that SVGs exported from
>> Illustrator always have a viewBox, but I'll check.
>>
>> >> I have a follow-up question. Is it possible to use Batik via the
>> >> Windows command line to change the width and height values by a
>> >> certain percentage?
>> >
>> >     I'm not aware of a way to do that.  You can set the width and
>> > height from the command line but you can't change them by a percentage.
>> >
>> >> I read that the transcoder could change these
>> >> values, but all the information I can find so far concerns the
>> >> transcoder API; not anything directly accessible via the command line.
>> >
>> >    If you run the rasterizer with no arguments it should print help
>> > text.
>>
>> I should have explained more clearly. I actually want to change the
>> width and height values in the source SVG, as I'm using the SVG
>> directly in PDFs. If Batik (from the command line) offered either a
>> way to scale those by a certain percentage, or at least to get the
>> original values and then change them, that would be very helpful. But
>> it's looking like I need to use another tool.
>>
>> I'm using the rasterizer to convert the same SVGs for web output, not
>> PDF. I just thought that as I need Batik for that, it would be neat if
>> I could also use Batik to edit the source SVG for PDF output.
>>
>> Cheers,
>> Joe
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
>> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>>
>
>

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


Re: OK to rescale SVG in PDF by changing just width and height values?

Posted by jonathan wood <jo...@gmail.com>.
Hi Joe,

  Be aware that some illustrator versions ( < CS3?) can drop viewBox's upon
export.  This may only be true for automated exports via javascript, I don't
recall.

If you are looking to add to a command line toolkit for your automated
document creation, you might look into using XSLT to modify the w/h values.
Xalan is packaged with Batik.

http://en.wikipedia.org/wiki/XSLT

http://xml.apache.org/xalan-j/


On Wed, Jul 21, 2010 at 9:24 AM, Joe Pairman <jo...@gmail.com> wrote:

> Hi Thomas,
>
> On Wed, Jul 21, 2010 at 8:15 PM,  <th...@kodak.com> wrote:
> > Hi Joe,
> >
> > Joe Pairman <jo...@gmail.com> wrote on 07/21/2010 03:20:49 AM:
> >
> >> Thanks for the tip, Jonathan. I tried a couple of test cases and it
> >> seems the default is fine for that.
> >
> >    Just a word of caution that this will only work if the document
> > has a viewBox attribute.
>
> Thanks. That's good to know. It *seems* that SVGs exported from
> Illustrator always have a viewBox, but I'll check.
>
> >> I have a follow-up question. Is it possible to use Batik via the
> >> Windows command line to change the width and height values by a
> >> certain percentage?
> >
> >     I'm not aware of a way to do that.  You can set the width and
> > height from the command line but you can't change them by a percentage.
> >
> >> I read that the transcoder could change these
> >> values, but all the information I can find so far concerns the
> >> transcoder API; not anything directly accessible via the command line.
> >
> >    If you run the rasterizer with no arguments it should print help text.
>
> I should have explained more clearly. I actually want to change the
> width and height values in the source SVG, as I'm using the SVG
> directly in PDFs. If Batik (from the command line) offered either a
> way to scale those by a certain percentage, or at least to get the
> original values and then change them, that would be very helpful. But
> it's looking like I need to use another tool.
>
> I'm using the rasterizer to convert the same SVGs for web output, not
> PDF. I just thought that as I need Batik for that, it would be neat if
> I could also use Batik to edit the source SVG for PDF output.
>
> Cheers,
> Joe
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>
>

Re: OK to rescale SVG in PDF by changing just width and height values?

Posted by Joe Pairman <jo...@gmail.com>.
Hi Thomas,

On Wed, Jul 21, 2010 at 8:15 PM,  <th...@kodak.com> wrote:
> Hi Joe,
>
> Joe Pairman <jo...@gmail.com> wrote on 07/21/2010 03:20:49 AM:
>
>> Thanks for the tip, Jonathan. I tried a couple of test cases and it
>> seems the default is fine for that.
>
>    Just a word of caution that this will only work if the document
> has a viewBox attribute.

Thanks. That's good to know. It *seems* that SVGs exported from
Illustrator always have a viewBox, but I'll check.

>> I have a follow-up question. Is it possible to use Batik via the
>> Windows command line to change the width and height values by a
>> certain percentage?
>
>     I'm not aware of a way to do that.  You can set the width and
> height from the command line but you can't change them by a percentage.
>
>> I read that the transcoder could change these
>> values, but all the information I can find so far concerns the
>> transcoder API; not anything directly accessible via the command line.
>
>    If you run the rasterizer with no arguments it should print help text.

I should have explained more clearly. I actually want to change the
width and height values in the source SVG, as I'm using the SVG
directly in PDFs. If Batik (from the command line) offered either a
way to scale those by a certain percentage, or at least to get the
original values and then change them, that would be very helpful. But
it's looking like I need to use another tool.

I'm using the rasterizer to convert the same SVGs for web output, not
PDF. I just thought that as I need Batik for that, it would be neat if
I could also use Batik to edit the source SVG for PDF output.

Cheers,
Joe

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


Re: OK to rescale SVG in PDF by changing just width and height values?

Posted by th...@kodak.com.
Hi Joe,

Joe Pairman <jo...@gmail.com> wrote on 07/21/2010 03:20:49 AM:

> Thanks for the tip, Jonathan. I tried a couple of test cases and it
> seems the default is fine for that.

   Just a word of caution that this will only work if the document
has a viewBox attribute.

> I have a follow-up question. Is it possible to use Batik via the
> Windows command line to change the width and height values by a
> certain percentage?

    I'm not aware of a way to do that.  You can set the width and
height from the command line but you can't change them by a percentage.

> I read that the transcoder could change these
> values, but all the information I can find so far concerns the
> transcoder API; not anything directly accessible via the command line.

   If you run the rasterizer with no arguments it should print help text.

> I know I could use other XML tools to do this, but I'm using the Batik
> rasterizer already and would rather use Batik for all SVG conversions.
> 
> Thanks,
> Joe
> 
> On Wed, Jul 21, 2010 at 12:15 AM, jonathan wood
> <jo...@gmail.com> wrote:
> >
> > You might also keep the preserveAspectRatio attribute in mind if a 
viewBox
> > is present, although the xMidYMid default is exactly what you describe 
in
> > your use case...
> >
> > http://www.w3.org/TR/SVG/coords.html#PreserveAspectRatioAttribute
> >
> >
> > On Tue, Jul 20, 2010 at 11:19 AM, Joe Pairman <jo...@gmail.com> 
wrote:
> >>
> >> I'm including SVG graphics in PDF user guides. I need to control the
> >> displayed size programmatically, effectively scaling the SVG 
including
> >> all its content. The best result I've had so far is by changing only
> >> the values of the width and height attributes, leaving everything 
else
> >> untouched, and not even changing the viewBox. This would seem to fit
> >> with Martin Jacobson's description here:
> >>
> >> http://old.nabble.com/Affine-Transforms-on-JSVGCanvas-Objects-
> to25206324.html#a25209903
> >> "The physical (ie display/print) dimensions are given by the "width"
> >> and "height"  attributes, while
> >> the drawing dimensions are described by the "viewPort" attribute."
> >>
> >> Is there anything I should beware of when using this approach to
> >> resize/rescale SVG? Anything I'm missing?
> >>
> >> Thanks for any tips.
> >> Joe
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 


Re: OK to rescale SVG in PDF by changing just width and height values?

Posted by Joe Pairman <jo...@gmail.com>.
Thanks for the tip, Jonathan. I tried a couple of test cases and it
seems the default is fine for that.

I have a follow-up question. Is it possible to use Batik via the
Windows command line to change the width and height values by a
certain percentage? I read that the transcoder could change these
values, but all the information I can find so far concerns the
transcoder API; not anything directly accessible via the command line.

I know I could use other XML tools to do this, but I'm using the Batik
rasterizer already and would rather use Batik for all SVG conversions.

Thanks,
Joe

On Wed, Jul 21, 2010 at 12:15 AM, jonathan wood
<jo...@gmail.com> wrote:
>
> You might also keep the preserveAspectRatio attribute in mind if a viewBox
> is present, although the xMidYMid default is exactly what you describe in
> your use case...
>
> http://www.w3.org/TR/SVG/coords.html#PreserveAspectRatioAttribute
>
>
> On Tue, Jul 20, 2010 at 11:19 AM, Joe Pairman <jo...@gmail.com> wrote:
>>
>> I'm including SVG graphics in PDF user guides. I need to control the
>> displayed size programmatically, effectively scaling the SVG including
>> all its content. The best result I've had so far is by changing only
>> the values of the width and height attributes, leaving everything else
>> untouched, and not even changing the viewBox. This would seem to fit
>> with Martin Jacobson's description here:
>>
>> http://old.nabble.com/Affine-Transforms-on-JSVGCanvas-Objects-to25206324.html#a25209903
>> "The physical (ie display/print) dimensions are given by the "width"
>> and "height"  attributes, while
>> the drawing dimensions are described by the "viewPort" attribute."
>>
>> Is there anything I should beware of when using this approach to
>> resize/rescale SVG? Anything I'm missing?
>>
>> Thanks for any tips.
>> Joe

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


Re: OK to rescale SVG in PDF by changing just width and height values?

Posted by jonathan wood <jo...@gmail.com>.
You might also keep the preserveAspectRatio attribute in mind if a viewBox
is present, although the xMidYMid default is exactly what you describe in
your use case...

http://www.w3.org/TR/SVG/coords.html#PreserveAspectRatioAttribute


On Tue, Jul 20, 2010 at 11:19 AM, Joe Pairman <jo...@gmail.com> wrote:

> I'm including SVG graphics in PDF user guides. I need to control the
> displayed size programmatically, effectively scaling the SVG including
> all its content. The best result I've had so far is by changing only
> the values of the width and height attributes, leaving everything else
> untouched, and not even changing the viewBox. This would seem to fit
> with Martin Jacobson's description here:
>
> http://old.nabble.com/Affine-Transforms-on-JSVGCanvas-Objects-to25206324.html#a25209903
> "The physical (ie display/print) dimensions are given by the "width"
> and "height"  attributes, while
> the drawing dimensions are described by the "viewPort" attribute."
>
> Is there anything I should beware of when using this approach to
> resize/rescale SVG? Anything I'm missing?
>
> Thanks for any tips.
> Joe
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>
>