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 Lea Thurman <le...@onesoon.co.uk> on 2008/06/05 11:24:12 UTC

PDF Size When Referencing External Fonts

Jeremais, 

Thanks. It works when running against FOP 0.95-beta(Batik 1.7). I was
running against FOP-0.94(batik 1.6) originally. (I put 0.95 in error in the
original post). Sorry.

I am hijacking the thread a little but I am surprised by the size of the
resulting PDF. Its seems that each font I reference or embed akes up about
300K per page in the resulting PDF file. A 2 page PDF with 2 referenced
fonts generates a 1.1MB PDF, without fonts it is 84K.

Does this seem normal to you? I suspect that because I am using FOP to to
render a number of SVG documents generated by batik and each SVG document
has the same referenced fonts then the PDF transcoder is duplicating the
fonts for each page.

Does this sound correct? It seems regardless of whether I reference or embed
the font in the SVG multiple fonts of the same type are embedded in the PDF.

I am going to see what happens if I specify the fonts in FOP and see if the
file size is reduced.

Failing this we are going to try and remove FOP from the equation and amend
batik to support multiple pages via the nextPage() method.

As always any pointers would be much appreciated. 

Regards
Lea.


Jeremias Maerki-2 wrote:
> 
> Sorry for the delay. I seemed to have missed this.
> 
> My suspicion is that the "No ImagePreloader found" is only a follow-up
> error of an error thrown when parsing the SVG. Are there no other error
> messages before the above error in the log? Lea, would you send me your
> SVG font file you referenced in your testfile below so I don't have to
> spend too much time trying to set up the same testcase? I'm not too
> familiar with SVG fonts. I will then try to reproduce the problem ASAP
> so I can provide better feedback. Otherwise, please try to set this up
> for debugging and try to figure out by
> org.apache.fop.image.loader.batik.PreloaderSVG fails to recognize your
> SVG as a valid SVG file.
> 
> On 02.06.2008 18:04:40 Lea Thurman wrote:
>> 
>> Hi,
>> 
>> I am using batik 1.7 to render an SVG document. I then create a FOP
>> document
>> and reference the generated SVG which is then converted into PDF using
>> FOP
>> 0.95beta.  The FOP document is below (but I suspect not the issue):
>> 
>> <?xml version="1.0" encoding="utf-8"?>
>> <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
>> xmlns:fox="http://xmlgraphics.apache.org/fop/extensions">
>>       <fo:layout-master-set>
>>         <fo:simple-page-master master-name="A4-portrait"
>> page-height="29.7cm" page-width="21.0cm" margin="2cm">
>>           <fo:region-body/>
>>         </fo:simple-page-master>
>>       </fo:layout-master-set>
>>       <fox:external-document id="img1"
>> src="/Users/temp/project/page1.svg"/>
>> </fo:root>
>> 
>> Everything has been working well until I attempted to reference an
>> external
>> font in the SVG file.
>> 
>> I get a 'No ImagePreloader found" error when I reference the SVG document
>> below. The error seems to be as a result of the following SVG element
>> which
>> is referencing an external font file. I know the external font file is
>> good
>> since this can be converted successfully into PDF using the testcard
>> characters. The SVG file is below:
>> 
>> <?xml version="1.0" standalone="yes"?>
>> <svg width="400px" height="300px" version="1.1"
>> xmlns='http://www.w3.org/2000/svg'>  
>>  <defs>
>>  <font-face font-family="Swiss721NarrowSWA">
>>    <font-face-src>
>>      <font-face-uri
>> xlink:href="file:///Users/temp/project/myfont.svg#Font1"/>
>>    </font-face-src>     
>>  </font-face>
>>  </defs>
>> <g style="font-family: Swiss721NarrowSWA; font-size:18;fill:black"> 
>>   <text x="20" y="120">@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_</text> 
>> </g>
>> </svg>
>> 
>> Everything works as expected if I embed the font into the SVG document
>> rather than referencing it.
>> 
>> I am not sure if it is something I have done with Batik or it is a FOP
>> error
>> so I decided to post here first. Apologies if this is clearly a FOP
>> problem
>> however FOP is able to handle to conversion with an embedded font so
>> maybe I
>> have referenced the font incorrectly in SVG.
>> 
>> Any help would be much appreciated.
>> 
>> Regards
>> Lea.
>> -- 
>> View this message in context:
>> http://www.nabble.com/%22No-ImagePreloader-found%22-when-attempting-to-reference-external-font-tp17604859p17604859.html
>> Sent from the Batik - Users mailing list archive at Nabble.com.
>> 
> 
> 
> 
> Jeremias Maerki
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/%22No-ImagePreloader-found%22-when-attempting-to-reference-external-font-tp17604859p17665735.html
Sent from the Batik - Users mailing list archive at Nabble.com.


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


Re: PDF Size When Referencing External Fonts

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

lpbill <ga...@gmail.com> wrote on 10/08/2008 10:34:19 PM:

> Thank you very much for your reply! That does explain why the fonts are 
not
> getting embedded properly. I think I may have a bigger underlying 
problem in
> that I can verify that even when I embed the fonts in the svg file e.g.:

> <defs id="genericDefs"
>   /><g
>   ><defs id="defs1"
>     ><font-face ascent="100.53711" descent="21.972656" 
units-per-em="100"
> style="font-style:normal; font-family:AnnabelleJF; font-weight:normal;"
> ...

    Umm, That doesn't look like a good font-face element to me.
font-style, font-family and font-weight need to be attributes not
CSS properties on the font-face element.

> that the text does still not show up properly when I just view the SVG 
file.
> I'm going to keep digging down on it and if you have any suggestions 
please
> let me know.

   I suggest you cut and past one of the examples from fontFace.svg
get it working, then slowly start modifying it to do what you need it to.

> When I have some results I'll post them here. 
> 
> 
> Hi LPBill,
> 
> lpbill <ga...@gmail.com> wrote on 10/07/2008 10:05:58 PM:
> 
> > I would just like to post a follow up to the problem that Lea found. 
> Here
> > are the details:
> > 
> > - Creating SVG and not converting fonts to shapes and not embedding 
svg
> > fonts.
> > - Converting to a PDF using FOP 0.95
> > - I am using the FOPFactory user config to specify directories of 
fonts
> > using the specified format (<directory>DIR_HERE</directory>).
> > 
> > Results:
> > - If the font is installed on the system AND the directory containing 
> the
> > font is referenced in the FOPFactory config then it works properly.
> > - If the font is not installed, or the directory is not referenced 
then 
> the
> > font is not embedded.
> > 
> > 
> > Is this the expected result? 
> 
>    Yes, it is expected, it probably isn't desired but it's expected.
> I suppose ideally FOP would automatically notify Batik about the fonts
> in that directory, so that Batik would consider them as candidates for
> rendering text.
> 
> > I was expecting that as long as I referenced the directory where the 
> > font was then it would be embedded properly. Any feedback is 
> appreciated.
> 
>    The problem is that Batik doesn't know about any of the fonts
> in the FOP font directory.  So when it does font matching it ends up
> replacing the desired font with one it can find (that is installed
> on the system).  You could also notify Batik of the font either through
> CSS (@font-face) or SVG (<font-face/> element) - see 
> samples/tests/spec/font/fontFace.svg for an example of using them.
> 
> 
> -- 
> View this message in context: http://www.nabble.com/%22No-
> ImagePreloader-found%22-when-attempting-to-reference-external-font-
> tp17604859p19891233.html
> Sent from the Batik - Users mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 

Re: PDF Size When Referencing External Fonts

Posted by lpbill <ga...@gmail.com>.
Hi Thomas,

Thank you very much for your reply! That does explain why the fonts are not
getting embedded properly. I think I may have a bigger underlying problem in
that I can verify that even when I embed the fonts in the svg file e.g.:

----------------
...
<defs id="genericDefs"
  /><g
  ><defs id="defs1"
    ><font-face ascent="100.53711" descent="21.972656" units-per-em="100"
style="font-style:normal; font-family:AnnabelleJF; font-weight:normal;"
...
----------------

that the text does still not show up properly when I just view the SVG file.
I'm going to keep digging down on it and if you have any suggestions please
let me know.

When I have some results I'll post them here. 


Hi LPBill,

lpbill <ga...@gmail.com> wrote on 10/07/2008 10:05:58 PM:

> I would just like to post a follow up to the problem that Lea found. 
Here
> are the details:
> 
> - Creating SVG and not converting fonts to shapes and not embedding svg
> fonts.
> - Converting to a PDF using FOP 0.95
> - I am using the FOPFactory user config to specify directories of fonts
> using the specified format (<directory>DIR_HERE</directory>).
> 
> Results:
> - If the font is installed on the system AND the directory containing 
the
> font is referenced in the FOPFactory config then it works properly.
> - If the font is not installed, or the directory is not referenced then 
the
> font is not embedded.
> 
> 
> Is this the expected result? 

   Yes, it is expected, it probably isn't desired but it's expected.
I suppose ideally FOP would automatically notify Batik about the fonts
in that directory, so that Batik would consider them as candidates for
rendering text.

> I was expecting that as long as I referenced the directory where the 
> font was then it would be embedded properly. Any feedback is 
appreciated.

   The problem is that Batik doesn't know about any of the fonts
in the FOP font directory.  So when it does font matching it ends up
replacing the desired font with one it can find (that is installed
on the system).  You could also notify Batik of the font either through
CSS (@font-face) or SVG (<font-face/> element) - see 
samples/tests/spec/font/fontFace.svg for an example of using them.


-- 
View this message in context: http://www.nabble.com/%22No-ImagePreloader-found%22-when-attempting-to-reference-external-font-tp17604859p19891233.html
Sent from the Batik - Users mailing list archive at Nabble.com.


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


Re: PDF Size When Referencing External Fonts

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

lpbill <ga...@gmail.com> wrote on 10/07/2008 10:05:58 PM:

> I would just like to post a follow up to the problem that Lea found. 
Here
> are the details:
> 
> - Creating SVG and not converting fonts to shapes and not embedding svg
> fonts.
> - Converting to a PDF using FOP 0.95
> - I am using the FOPFactory user config to specify directories of fonts
> using the specified format (<directory>DIR_HERE</directory>).
> 
> Results:
> - If the font is installed on the system AND the directory containing 
the
> font is referenced in the FOPFactory config then it works properly.
> - If the font is not installed, or the directory is not referenced then 
the
> font is not embedded.
> 
> 
> Is this the expected result? 

   Yes, it is expected, it probably isn't desired but it's expected.
I suppose ideally FOP would automatically notify Batik about the fonts
in that directory, so that Batik would consider them as candidates for
rendering text.

> I was expecting that as long as I referenced the directory where the 
> font was then it would be embedded properly. Any feedback is 
appreciated.

   The problem is that Batik doesn't know about any of the fonts
in the FOP font directory.  So when it does font matching it ends up
replacing the desired font with one it can find (that is installed
on the system).  You could also notify Batik of the font either through
CSS (@font-face) or SVG (<font-face/> element) - see 
samples/tests/spec/font/fontFace.svg for an example of using them.


> 
> Thanks,
> Bill
> 
> 
> 
> Hi,
> 
> I just thought I would post an update.
> 
> I am now specifying my fonts via FOP and the result has been remarkable. 
A 5
> page PDF with one embedded font is now approximately 200K! I could not 
of
> hoped for a better result.
> 
> As an aside, I have encountered a number of issues with FOP not picking 
up
> my fonts unless installed but I will get some concrete use cases before 
I
> post regarding this. 
> 
> I am running on Mac OS X 10.5 so maybe this is contributing to it.
> 
> Finally thank you for your help it is much appreciated.
> 
> Regards
> Lea.
> 
> -- 
> View this message in context: http://www.nabble.com/%22No-
> ImagePreloader-found%22-when-attempting-to-reference-external-font-
> tp17604859p19871032.html
> Sent from the Batik - Users mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 

Re: PDF Size When Referencing External Fonts

Posted by lpbill <ga...@gmail.com>.
Hello,

I would just like to post a follow up to the problem that Lea found. Here
are the details:

- Creating SVG and not converting fonts to shapes and not embedding svg
fonts.
- Converting to a PDF using FOP 0.95
- I am using the FOPFactory user config to specify directories of fonts
using the specified format (<directory>DIR_HERE</directory>).

Results:
- If the font is installed on the system AND the directory containing the
font is referenced in the FOPFactory config then it works properly.
- If the font is not installed, or the directory is not referenced then the
font is not embedded.


Is this the expected result? I was expecting that as long as I referenced
the directory where the font was then it would be embedded properly. Any
feedback is appreciated.

Thanks,
Bill



Hi,

I just thought I would post an update.

I am now specifying my fonts via FOP and the result has been remarkable. A 5
page PDF with one embedded font is now approximately 200K! I could not of
hoped for a better result.

As an aside, I have encountered a number of issues with FOP not picking up
my fonts unless installed but I will get some concrete use cases before I
post regarding this. 

I am running on Mac OS X 10.5 so maybe this is contributing to it.

Finally thank you for your help it is much appreciated.

Regards
Lea.

-- 
View this message in context: http://www.nabble.com/%22No-ImagePreloader-found%22-when-attempting-to-reference-external-font-tp17604859p19871032.html
Sent from the Batik - Users mailing list archive at Nabble.com.


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


Re: PDF Size When Referencing External Fonts

Posted by Lea Thurman <le...@onesoon.co.uk>.
Hi,

I just thought I would post an update.

I am now specifying my fonts via FOP and the result has been remarkable. A 5
page PDF with one embedded font is now approximately 200K! I could not of
hoped for a better result.

As an aside, I have encountered a number of issues with FOP not picking up
my fonts unless installed but I will get some concrete use cases before I
post regarding this. 

I am running on Mac OS X 10.5 so maybe this is contributing to it.

Finally thank you for your help it is much appreciated.

Regards
Lea.



Jeremias Maerki-2 wrote:
> 
> On 05.06.2008 11:24:12 Lea Thurman wrote:
>> 
>> Jeremais, 
>> 
>> Thanks. It works when running against FOP 0.95-beta(Batik 1.7). I was
>> running against FOP-0.94(batik 1.6) originally. (I put 0.95 in error in
>> the
>> original post). Sorry.
>> 
>> I am hijacking the thread a little but I am surprised by the size of the
>> resulting PDF. Its seems that each font I reference or embed akes up
>> about
>> 300K per page in the resulting PDF file. A 2 page PDF with 2 referenced
>> fonts generates a 1.1MB PDF, without fonts it is 84K.
>> 
>> Does this seem normal to you? I suspect that because I am using FOP to to
>> render a number of SVG documents generated by batik and each SVG document
>> has the same referenced fonts then the PDF transcoder is duplicating the
>> fonts for each page.
> 
> Not duplicating the fonts. Rather rendering all text as shapes. We don't
> have support for Type 3 fonts, yet, which could be used for SVG fonts.
> So the PDF size is completely expected.
> 
>> Does this sound correct? It seems regardless of whether I reference or
>> embed
>> the font in the SVG multiple fonts of the same type are embedded in the
>> PDF.
> 
> In both cases they are SVG fonts, the way you do it. If you just remove
> the font-face elements from the SVGs I expect improvements of PDF sizes.
> 
>> I am going to see what happens if I specify the fonts in FOP and see if
>> the
>> file size is reduced.
> 
> That's exactly what you should do instead of using SVG fonts. If you use
> FOP 0.95beta special font configuration should actually be unnecessary 
> (except for an "<auto-detect/>" in the FOP configuration if you
> transform FO+SVG rather than SVG). This way, the fonts get embedded
> natively which should reduce PDF size and add copy/paste support for all
> but the most complex SVG text.
> 
>> Failing this we are going to try and remove FOP from the equation and
>> amend
>> batik to support multiple pages via the nextPage() method.
> 
> Difficult as the PDF output support for Batik is still part of FOP. ;-)
> But I know what you mean. I think both approaches should work. Only the
> configuration is different because two different APIs are used.
> 
> Good luck!
> 
>> As always any pointers would be much appreciated. 
>> 
>> Regards
>> Lea.
>> 
>> 
>> Jeremias Maerki-2 wrote:
>> > 
>> > Sorry for the delay. I seemed to have missed this.
>> > 
>> > My suspicion is that the "No ImagePreloader found" is only a follow-up
>> > error of an error thrown when parsing the SVG. Are there no other error
>> > messages before the above error in the log? Lea, would you send me your
>> > SVG font file you referenced in your testfile below so I don't have to
>> > spend too much time trying to set up the same testcase? I'm not too
>> > familiar with SVG fonts. I will then try to reproduce the problem ASAP
>> > so I can provide better feedback. Otherwise, please try to set this up
>> > for debugging and try to figure out by
>> > org.apache.fop.image.loader.batik.PreloaderSVG fails to recognize your
>> > SVG as a valid SVG file.
>> > 
>> > On 02.06.2008 18:04:40 Lea Thurman wrote:
>> >> 
>> >> Hi,
>> >> 
>> >> I am using batik 1.7 to render an SVG document. I then create a FOP
>> >> document
>> >> and reference the generated SVG which is then converted into PDF using
>> >> FOP
>> >> 0.95beta.  The FOP document is below (but I suspect not the issue):
>> >> 
>> >> <?xml version="1.0" encoding="utf-8"?>
>> >> <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
>> >> xmlns:fox="http://xmlgraphics.apache.org/fop/extensions">
>> >>       <fo:layout-master-set>
>> >>         <fo:simple-page-master master-name="A4-portrait"
>> >> page-height="29.7cm" page-width="21.0cm" margin="2cm">
>> >>           <fo:region-body/>
>> >>         </fo:simple-page-master>
>> >>       </fo:layout-master-set>
>> >>       <fox:external-document id="img1"
>> >> src="/Users/temp/project/page1.svg"/>
>> >> </fo:root>
>> >> 
>> >> Everything has been working well until I attempted to reference an
>> >> external
>> >> font in the SVG file.
>> >> 
>> >> I get a 'No ImagePreloader found" error when I reference the SVG
>> document
>> >> below. The error seems to be as a result of the following SVG element
>> >> which
>> >> is referencing an external font file. I know the external font file is
>> >> good
>> >> since this can be converted successfully into PDF using the testcard
>> >> characters. The SVG file is below:
>> >> 
>> >> <?xml version="1.0" standalone="yes"?>
>> >> <svg width="400px" height="300px" version="1.1"
>> >> xmlns='http://www.w3.org/2000/svg'>  
>> >>  <defs>
>> >>  <font-face font-family="Swiss721NarrowSWA">
>> >>    <font-face-src>
>> >>      <font-face-uri
>> >> xlink:href="file:///Users/temp/project/myfont.svg#Font1"/>
>> >>    </font-face-src>     
>> >>  </font-face>
>> >>  </defs>
>> >> <g style="font-family: Swiss721NarrowSWA; font-size:18;fill:black"> 
>> >>   <text x="20" y="120">@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_</text> 
>> >> </g>
>> >> </svg>
>> >> 
>> >> Everything works as expected if I embed the font into the SVG document
>> >> rather than referencing it.
>> >> 
>> >> I am not sure if it is something I have done with Batik or it is a FOP
>> >> error
>> >> so I decided to post here first. Apologies if this is clearly a FOP
>> >> problem
>> >> however FOP is able to handle to conversion with an embedded font so
>> >> maybe I
>> >> have referenced the font incorrectly in SVG.
>> >> 
>> >> Any help would be much appreciated.
>> >> 
>> >> Regards
>> >> Lea.
>> >> -- 
>> >> View this message in context:
>> >>
>> http://www.nabble.com/%22No-ImagePreloader-found%22-when-attempting-to-reference-external-font-tp17604859p17604859.html
>> >> Sent from the Batik - Users mailing list archive at Nabble.com.
>> >> 
>> > 
>> > 
>> > 
>> > Jeremias Maerki
>> > 
>> > 
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
>> > For additional commands, e-mail:
>> batik-users-help@xmlgraphics.apache.org
>> > 
>> > 
>> > 
>> 
>> -- 
>> View this message in context:
>> http://www.nabble.com/%22No-ImagePreloader-found%22-when-attempting-to-reference-external-font-tp17604859p17665735.html
>> Sent from the Batik - Users mailing list archive at Nabble.com.
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
>> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 
> 
> 
> 
> Jeremias Maerki
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/%22No-ImagePreloader-found%22-when-attempting-to-reference-external-font-tp17604859p17673451.html
Sent from the Batik - Users mailing list archive at Nabble.com.


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


Re: PDF Size When Referencing External Fonts

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
On 05.06.2008 11:24:12 Lea Thurman wrote:
> 
> Jeremais, 
> 
> Thanks. It works when running against FOP 0.95-beta(Batik 1.7). I was
> running against FOP-0.94(batik 1.6) originally. (I put 0.95 in error in the
> original post). Sorry.
> 
> I am hijacking the thread a little but I am surprised by the size of the
> resulting PDF. Its seems that each font I reference or embed akes up about
> 300K per page in the resulting PDF file. A 2 page PDF with 2 referenced
> fonts generates a 1.1MB PDF, without fonts it is 84K.
> 
> Does this seem normal to you? I suspect that because I am using FOP to to
> render a number of SVG documents generated by batik and each SVG document
> has the same referenced fonts then the PDF transcoder is duplicating the
> fonts for each page.

Not duplicating the fonts. Rather rendering all text as shapes. We don't
have support for Type 3 fonts, yet, which could be used for SVG fonts.
So the PDF size is completely expected.

> Does this sound correct? It seems regardless of whether I reference or embed
> the font in the SVG multiple fonts of the same type are embedded in the PDF.

In both cases they are SVG fonts, the way you do it. If you just remove
the font-face elements from the SVGs I expect improvements of PDF sizes.

> I am going to see what happens if I specify the fonts in FOP and see if the
> file size is reduced.

That's exactly what you should do instead of using SVG fonts. If you use
FOP 0.95beta special font configuration should actually be unnecessary 
(except for an "<auto-detect/>" in the FOP configuration if you
transform FO+SVG rather than SVG). This way, the fonts get embedded
natively which should reduce PDF size and add copy/paste support for all
but the most complex SVG text.

> Failing this we are going to try and remove FOP from the equation and amend
> batik to support multiple pages via the nextPage() method.

Difficult as the PDF output support for Batik is still part of FOP. ;-)
But I know what you mean. I think both approaches should work. Only the
configuration is different because two different APIs are used.

Good luck!

> As always any pointers would be much appreciated. 
> 
> Regards
> Lea.
> 
> 
> Jeremias Maerki-2 wrote:
> > 
> > Sorry for the delay. I seemed to have missed this.
> > 
> > My suspicion is that the "No ImagePreloader found" is only a follow-up
> > error of an error thrown when parsing the SVG. Are there no other error
> > messages before the above error in the log? Lea, would you send me your
> > SVG font file you referenced in your testfile below so I don't have to
> > spend too much time trying to set up the same testcase? I'm not too
> > familiar with SVG fonts. I will then try to reproduce the problem ASAP
> > so I can provide better feedback. Otherwise, please try to set this up
> > for debugging and try to figure out by
> > org.apache.fop.image.loader.batik.PreloaderSVG fails to recognize your
> > SVG as a valid SVG file.
> > 
> > On 02.06.2008 18:04:40 Lea Thurman wrote:
> >> 
> >> Hi,
> >> 
> >> I am using batik 1.7 to render an SVG document. I then create a FOP
> >> document
> >> and reference the generated SVG which is then converted into PDF using
> >> FOP
> >> 0.95beta.  The FOP document is below (but I suspect not the issue):
> >> 
> >> <?xml version="1.0" encoding="utf-8"?>
> >> <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
> >> xmlns:fox="http://xmlgraphics.apache.org/fop/extensions">
> >>       <fo:layout-master-set>
> >>         <fo:simple-page-master master-name="A4-portrait"
> >> page-height="29.7cm" page-width="21.0cm" margin="2cm">
> >>           <fo:region-body/>
> >>         </fo:simple-page-master>
> >>       </fo:layout-master-set>
> >>       <fox:external-document id="img1"
> >> src="/Users/temp/project/page1.svg"/>
> >> </fo:root>
> >> 
> >> Everything has been working well until I attempted to reference an
> >> external
> >> font in the SVG file.
> >> 
> >> I get a 'No ImagePreloader found" error when I reference the SVG document
> >> below. The error seems to be as a result of the following SVG element
> >> which
> >> is referencing an external font file. I know the external font file is
> >> good
> >> since this can be converted successfully into PDF using the testcard
> >> characters. The SVG file is below:
> >> 
> >> <?xml version="1.0" standalone="yes"?>
> >> <svg width="400px" height="300px" version="1.1"
> >> xmlns='http://www.w3.org/2000/svg'>  
> >>  <defs>
> >>  <font-face font-family="Swiss721NarrowSWA">
> >>    <font-face-src>
> >>      <font-face-uri
> >> xlink:href="file:///Users/temp/project/myfont.svg#Font1"/>
> >>    </font-face-src>     
> >>  </font-face>
> >>  </defs>
> >> <g style="font-family: Swiss721NarrowSWA; font-size:18;fill:black"> 
> >>   <text x="20" y="120">@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_</text> 
> >> </g>
> >> </svg>
> >> 
> >> Everything works as expected if I embed the font into the SVG document
> >> rather than referencing it.
> >> 
> >> I am not sure if it is something I have done with Batik or it is a FOP
> >> error
> >> so I decided to post here first. Apologies if this is clearly a FOP
> >> problem
> >> however FOP is able to handle to conversion with an embedded font so
> >> maybe I
> >> have referenced the font incorrectly in SVG.
> >> 
> >> Any help would be much appreciated.
> >> 
> >> Regards
> >> Lea.
> >> -- 
> >> View this message in context:
> >> http://www.nabble.com/%22No-ImagePreloader-found%22-when-attempting-to-reference-external-font-tp17604859p17604859.html
> >> Sent from the Batik - Users mailing list archive at Nabble.com.
> >> 
> > 
> > 
> > 
> > Jeremias Maerki
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> > For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> > 
> > 
> > 
> 
> -- 
> View this message in context: http://www.nabble.com/%22No-ImagePreloader-found%22-when-attempting-to-reference-external-font-tp17604859p17665735.html
> Sent from the Batik - Users mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org




Jeremias Maerki


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


Re: PDF Size When Referencing External Fonts

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

Thomas DeWeese | CDG Advanced Development | 
Eastman Kodak Company | 343 State Street | Rochester, NY 14650-0128 | 
Thomas.DeWeese@Kodak.com | 585 781-9059 | 
www.kodak.com 


Lea Thurman <le...@onesoon.co.uk> wrote on 06/05/2008 05:24:12 AM:

> I am hijacking the thread a little but I am surprised by the size of the
> resulting PDF. Its seems that each font I reference or embed akes up 
about
> 300K per page in the resulting PDF file. A 2 page PDF with 2 referenced
> fonts generates a 1.1MB PDF, without fonts it is 84K.

   Unfortunately this is not too surprising for me.

> Does this seem normal to you? I suspect that because I am using FOP to 
to
> render a number of SVG documents generated by batik and each SVG 
document
> has the same referenced fonts then the PDF transcoder is duplicating the
> fonts for each page.

    No it's worse than that.  The capabilities of an SVG font are much
greater than the capabilities of a PDF font. Each glyph can at least in
theory make use of all of the features of SVG, multiple colors, stroking,
filters, animation... (I don't think we support animated fonts BTW, but
the spec does).  So there is no usage of PDF fonts when you use an SVG
Font, we simply draw the text (character) content in the PDF.  So if
'e' is present a bazillion times in the document there will be a 
bazillion copies of the data for the 'e' glyph.

> Failing this we are going to try and remove FOP from the equation and 
amend
> batik to support multiple pages via the nextPage() method.

   This won't help the file size problem.

> Jeremias Maerki-2 wrote:
> > 
> > Sorry for the delay. I seemed to have missed this.
> > 
> > My suspicion is that the "No ImagePreloader found" is only a follow-up
> > error of an error thrown when parsing the SVG. Are there no other 
error
> > messages before the above error in the log? Lea, would you send me 
your
> > SVG font file you referenced in your testfile below so I don't have to
> > spend too much time trying to set up the same testcase? I'm not too
> > familiar with SVG fonts. I will then try to reproduce the problem ASAP
> > so I can provide better feedback. Otherwise, please try to set this up
> > for debugging and try to figure out by
> > org.apache.fop.image.loader.batik.PreloaderSVG fails to recognize your
> > SVG as a valid SVG file.
> > 
> > On 02.06.2008 18:04:40 Lea Thurman wrote:
> >> 
> >> Hi,
> >> 
> >> I am using batik 1.7 to render an SVG document. I then create a FOP
> >> document
> >> and reference the generated SVG which is then converted into PDF 
using
> >> FOP
> >> 0.95beta.  The FOP document is below (but I suspect not the issue):
> >> 
> >> <?xml version="1.0" encoding="utf-8"?>
> >> <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
> >> xmlns:fox="http://xmlgraphics.apache.org/fop/extensions">
> >>       <fo:layout-master-set>
> >>         <fo:simple-page-master master-name="A4-portrait"
> >> page-height="29.7cm" page-width="21.0cm" margin="2cm">
> >>           <fo:region-body/>
> >>         </fo:simple-page-master>
> >>       </fo:layout-master-set>
> >>       <fox:external-document id="img1"
> >> src="/Users/temp/project/page1.svg"/>
> >> </fo:root>
> >> 
> >> Everything has been working well until I attempted to reference an
> >> external
> >> font in the SVG file.
> >> 
> >> I get a 'No ImagePreloader found" error when I reference the SVG 
document
> >> below. The error seems to be as a result of the following SVG element
> >> which
> >> is referencing an external font file. I know the external font file 
is
> >> good
> >> since this can be converted successfully into PDF using the testcard
> >> characters. The SVG file is below:
> >> 
> >> <?xml version="1.0" standalone="yes"?>
> >> <svg width="400px" height="300px" version="1.1"
> >> xmlns='http://www.w3.org/2000/svg'> 
> >>  <defs>
> >>  <font-face font-family="Swiss721NarrowSWA">
> >>    <font-face-src>
> >>      <font-face-uri
> >> xlink:href="file:///Users/temp/project/myfont.svg#Font1"/>
> >>    </font-face-src> 
> >>  </font-face>
> >>  </defs>
> >> <g style="font-family: Swiss721NarrowSWA; font-size:18;fill:black"> 
> >>   <text x="20" y="120">@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_</text> 
> >> </g>
> >> </svg>
> >> 
> >> Everything works as expected if I embed the font into the SVG 
document
> >> rather than referencing it.
> >> 
> >> I am not sure if it is something I have done with Batik or it is a 
FOP
> >> error
> >> so I decided to post here first. Apologies if this is clearly a FOP
> >> problem
> >> however FOP is able to handle to conversion with an embedded font so
> >> maybe I
> >> have referenced the font incorrectly in SVG.
> >> 
> >> Any help would be much appreciated.
> >> 
> >> Regards
> >> Lea.
> >> -- 
> >> View this message in context:
> >> http://www.nabble.com/%22No-ImagePreloader-found%22-when-
> attempting-to-reference-external-font-tp17604859p17604859.html
> >> Sent from the Batik - Users mailing list archive at Nabble.com.
> >> 
> > 
> > 
> > 
> > Jeremias Maerki
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> > For additional commands, e-mail: 
batik-users-help@xmlgraphics.apache.org
> > 
> > 
> > 
> 
> -- 
> View this message in context: http://www.nabble.com/%22No-
> ImagePreloader-found%22-when-attempting-to-reference-external-font-
> tp17604859p17665735.html
> Sent from the Batik - Users mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>