Re: Manual line breaks

2003-04-14 Thread Joop Vriend
I haven't tried this myself yet, but see:
http://marc.theaimsgroup.com/?l=fop-userm=102469565909328w=2 :
'If you want to have your line breaks preserved, you
should set linefeed-treatment to preserve. Unfortunately,
FOP doesn't implement this. You can set white-space-collapse
to false, which will not only keep runs of spaces but also
the linefeeds intact (which is actually a bug).
If you want to have white space collapsed, you can
- do this at a transformation level
- use a transformation which transforms each run of characters
   between two line bbreaks into a separate fo:block
- translate the CR to #x2028; (Unicode LINE SEPARATOR) which
   is apparently treated specially'
Good luck, Joop.
Matthias Brunner wrote:
Hello!
In a perfect XML world content is always separatable from 
presentation. Unfortunately, there are cases (at least in 
publishing) when this is simply not possible. For example, we need 
to provide the possibility to insert manual breaks into text 
(especially titles).

Web research tells me that whitespace-treatment=preserve is a 
solution to this, yet unimplemented by FOP.
The only workaround I have found so far is to sorround the position 
at which the line should be broken with non-break spaces.
(Example: this#xA0;is#xA0;a#xA0;test !-- intended break position 
-- this#xA0;is#xA0;a#xA0;test.)

Has anyone found a better solution to this?
Cheers,
Matthias Brunner
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Letter-spacing / kerning between words in PDFRenderer

2003-03-12 Thread Joop Vriend
Hi,
To begin with: we use FOP 0.20.4, and this mail is about a partly fix 
for missing letter-spacing/kerning between words in PDF's.

In PDF's produced with FOP compared to PDF's from other an other source, 
we noticed that FOP doesn't apply kerning (letter-spacing) to spaces 
between words, most obviously at the end of sentences. I.e., no kerning 
is applied to the character pairs

word-characterspace  (for example, . ) and
spaceword-character  (for example,  V).
The cause, or in any case, the place where it can (partly?) be fixed, 
can be found in the method renderWordArea(WordArea area) in 
PDFRenderer.java.

The latter case (spaceword-character) I could easily fix. All I 
had to do was move the lines

String s;
if (area.getPageNumberID()
!= null) {// this text is a page number, so resolve it
s = idReferences.getPageNumber(area.getPageNumberID());
if (s == null) {
s = ;
}
} else {
s = area.getText();
}
int l = s.length();
up a few lines so they precede 'if (!textOpen || bl != prevWordY)',
and add the following lines in the else-part of
'if (!textOpen || bl != prevWordY)':
if (kerningAvailable  l  0) {
addKerning(pdf, (new Integer((int) ' ')),
 (new Integer((int) area.getFontState().mapChar(s.charAt(0,
   kerning, startText, endText);
}
I've attached the complete code of the method renderWordArea separately.
But..., that's only half of the solution! The first case 
(word-characterspace) is more difficult. I think that in 
renderWordArea we can not be sure that a space is following the word we 
just rendered - or can we? And we don't have the last character of the 
previous word available. Anyone has any ideas?

Regards, Joop Vriend.
/**
 * render inline area to PDF
 *
 * @param area  inline area to render
 */
public void renderWordArea(WordArea area) {
synchronized (_wordAreaPDF) {
StringBuffer pdf = _wordAreaPDF;
pdf.setLength(0);

Hashtable kerning = null;
boolean kerningAvailable = false;

kerning = area.getFontState().getKerning();
if (kerning != null  !kerning.isEmpty()) {
kerningAvailable = true;
}

String name = area.getFontState().getFontName();
int size = area.getFontState().getFontSize();

// This assumes that *all* CIDFonts use a /ToUnicode mapping
boolean useMultiByte = false;
Font f = (Font) area.getFontState().
getFontInfo().getFonts().get(name);
if (f instanceof LazyFont) {
if (((LazyFont) f).getRealFont() instanceof CIDFont) {
useMultiByte = true;
}
} else if (f instanceof CIDFont) {
useMultiByte = true;
}
// String startText = useMultiByte ? FEFF : (;
String startText = useMultiByte ?  : (;
String endText = useMultiByte ?   : ) ;

if ((!name.equals(this.currentFontName))
|| (size != this.currentFontSize)) {
closeText();

this.currentFontName = name;
this.currentFontSize = size;
pdf = pdf.append(/ + name +   + ((float)size / 1000) +  Tf\n);
}

//Do letter spacing (must be outside of [..] TJ)
float letterspacing =
((float) area.getFontState().getLetterSpacing()) / 1000;
if (letterspacing != this.currentLetterSpacing) {
this.currentLetterSpacing = letterspacing;
closeText();
pdf.append(letterspacing).append( Tc\n);
}

PDFColor areaColor = null;
if (this.currentFill instanceof PDFColor) {
areaColor = (PDFColor) this.currentFill;
}

if (areaColor == null || areaColor.red() != (double) area.getRed()
|| areaColor.green() != (double) area.getGreen()
|| areaColor.blue() != (double) area.getBlue()) {

areaColor = new PDFColor((double) area.getRed(),
(double) area.getGreen(),
(double) area.getBlue());

closeText();
this.currentFill = areaColor;
pdf.append(this.currentFill.getColorSpaceOut(true));
}

int rx = this.currentXPosition;
int bl = this.currentYPosition;

addWordLines(area, rx, bl, size, areaColor);

String s;
if (area.getPageNumberID() != null) {// this text is a page number, so 
resolve it
s = idReferences.getPageNumber(area.getPageNumberID());
if (s == null) {
s = ;
}
} else {
s = area.getText();
}

int l = s.length();

if (!textOpen || bl != prevWordY) {
closeText();

pdf.append(1 0 0 1  + (rx / 1000f) +   + (bl / 1000f)
+  Tm [ + startText);
prevWordY = bl;
textOpen = true;
} else {
// express the space between words in thousandths of an em

Re: Batik error opening SVG (Was: Re: EPS images not shown in Acrobat)

2003-02-19 Thread Joop Vriend
Jeremias Maerki wrote:
snip/
When we used outlines instead of an embedded font, the result in the PDF 
was rather ugly, not smooth. While the SVG looks perfect in Internet 
Explorer (Adobe SVG Viewer) and in Squiggle.

There's a setting in Acrobat Reader (Preferences/Display) where you can
turn on Smoothing for line art. The SVG should then look like in SVG
Viewer and Squiggle.
That works! Thanks. Strange that's an option - or at least, that it's 
not turned on by default.

snip/
Squiggle can't open the generated SVG either when the font is embedded, 
it generates the same CSS stylesheet document error.

So I guess you know now whom to address for this one. Isn't there a
setting in Illustrator not to use a CSS stylesheet? I know there is one
in CorelDraw. Maybe that could help.
No, can't find such an option I'm afraid.
snip/
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Batik error opening SVG (Was: Re: EPS images not shown in Acrobat)

2003-02-18 Thread Joop Vriend
Jeremias Maerki wrote:
I haven't used Illustrator myself before but have you tried playing
around with the export setting such as convert text to graphics or not
embedding but only referencing the fonts?
When we used outlines instead of an embedded font, the result in the PDF 
was rather ugly, not smooth. While the SVG looks perfect in Internet 
Explorer (Adobe SVG Viewer) and in Squiggle.

And with linked fonts FOP (Batik) doesn't include the font in the 
resulting PDF, and that's not acceptable because we can't expect all 
users to have the font installed. Ofcourse that's the reason we want to 
embed the font in the first place.

If you download Batik standalone and start Squiggle (the SVG browser)
can it display the generated SVG? If no, then it's a Batik problem and
the Batik team should be contacted.
Squiggle can't open the generated SVG either when the font is embedded, 
it generates the same CSS stylesheet document error.

On 14.02.2003 22:39:43 Joop Vriend wrote:
3) Batik produces an error on the embedded font in the SVG saved by
  Illustrator (10):
[ERROR] svg graphic could not be built: file:/tmp/logo.svg:
The following stylesheet represents an invalid
CSS document.

And if you tell Illustrator not to embed fonts? Or try 0.20.5rc. It
contains a more current Batik version.
We (already) tried it with the latest version of Batik. Still no luck.
Joop Vriend.
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Different page layout using pdf renderer or awt renderer

2003-02-18 Thread Joop Vriend
Jeremias Maerki wrote:
This happens because the two renderer use a different font source which
results in slightly different font metrics for the same fonts. This in
turn has consequences on the layout. There's currently nothing you can
do to get the same output other than by switching renderers. PDF and
PostScript, for example, should produce almost exactly the same output
because they can use the same font source. That's not possible with AWT.
But PostScript output still has some limitations as pointed out at
http://xml.apache.org/fop/output.html#xpointer(/document[1]/body[1]/section[1]/section[4])
Indeed I have experienced differences in character spacing. Perhaps 
because we used *negative* letter-spacing, while on line 691 of the 
PSRenderer.java of the FOP 0.20.4 source, the check for letter-spacing 
is as follows:

if (area.getFontState().getLetterSpacing()  0) ...
??
snip/
Joop Vriend.
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: EPS images not shown in Acrobat

2003-02-14 Thread Joop Vriend
snip/
Does anybody know why EPS-images are not shown in Acrobat? Is it going 
to change in coming versions of FOP? We are currently using FOP 0.20.4. 
Can we fix it ourselves or is it very complicated?

Acrobat doesn't support displaying EPS files because that would involve
having a PostScript interpreter built-in. If you open it in
GhostScript/GhostView you will see it because the PDF is internally
converted to PostScript and GhostScript is a PostScript interpreter. So
you cannot fix it by modifying FOP.

Actually, I *can't* open it with GhostScript (6.53)/GhostView (3.5.8), 
because it crashes with an error, seemingly not coping with an embedded 
font ('Error: /undefined in dobeFont-1.0').

Could you check if the same happens with 0.20.5rc?
I tried it with FOP 0.20.5rc - still got an error, though different:
'Error: /syntaxerror in stream'
Also found out that it's not an EPS that's causing this error, but 
simply an text-block which uses a Type 1 font we added/registered in 
userconfig.xml. This font we converted from Mac Type1 Printer Font to PC 
Type1 Printer Font (.pfb) using CrossFont.

snip/
3) Batik produces an error on the embedded font in the SVG saved by
   Illustrator (10):
[ERROR] svg graphic could not be built: file:/tmp/logo.svg:
The following stylesheet represents an invalid
CSS document.

And if you tell Illustrator not to embed fonts? Or try 0.20.5rc. It
contains a more current Batik version.
We (already) tried it with the latest version of Batik. Still no luck.
snip/
OK, that's clear. You wouldn't happen to know of a tool or Java class 
with full Distiller capabilities?

There's currently no decent Java-based PostScript interpreter I know of.
That would be one of these cool projects for an IT student. :-)
Yep! Couldn't agree more... Was actually rather surprised I couldn't 
find something on the internet.

If the EPS image is absolutely placed on the page you could try to
generate a PDF with one page and the EPS image already distilled at the
right position. Then you could combine the FOP-generated PDF with the
one containing the EPS image superimposing one over the other. Tools for
that are iText and Etymon PJ. But the question is whether this would
really be faster than working with SVG.
Thanks for the tip, but the images aren't always absolutely positioned.
Joop Vriend.
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


EPS images not shown in Acrobat

2003-02-13 Thread Joop Vriend
Hi there,
Does anybody know why EPS-images are not shown in Acrobat? Is it going 
to change in coming versions of FOP? We are currently using FOP 0.20.4. 
Can we fix it ourselves or is it very complicated?

Or can the resulting PDF from FOP be post-processed (from PDF to PDF), 
so EPS-images can be shown in Acrobat? (Possibly also shrinking the size 
of the PDF file?) I know the data of the EPS is in the PDF. If I print 
the FOP PDF to Acrobat Distiller, the image shows up.

Kind regards, Joop Vriend.
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]