Hey Mehdi, I just spent some time played around with this patch file.
I have fixed the following files, and replace the codes have "-" in front of it to the one have "+" but still can't get it to work (will double check again) src/java/org/apache/fop/render/rtf/RTFHandler.java src/java/org/apache/fop/render/rtf/TextAttributesConverter.java src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java Also there is a file name RtfPageBreak.java in the rtflib folder which never been call inside RTFHandler,I wonder if this file have anything to do with the page break. Can you please try the patch file, and let me know if it works for you. Thank you, Chen -----Original Message----- From: mehdi houshmand [mailto:med1...@gmail.com] Sent: October-21-10 9:46 AM To: fop-users@xmlgraphics.apache.org Subject: Re: FW: Can't get RTF page break working Hi Chen, I'm afraid not, the status is still "NEW" rather than "RESOLVED", which suggests the patch hasn't been implemented and another big give-away is that none of that code is in the source. I'll put an update on the bug in an attempt to get a committer to take notice of it. If the patch doesn't work, let me know and I'll take a look. Thanks Mehdi On 21 October 2010 14:28, Chen Yang <cy...@hrsg.ca> wrote: > Hey Mehdi, > Thanks for the response. I saw this bug page before, I thought it's already > been approved and Patched in current version trunk. Since this bug was report > in 2007 and got fixed in 2008. > > But anyhow, I will give the patch file a try, > > Thanks again > > Chen > -----Original Message----- > From: mehdi houshmand [mailto:med1...@gmail.com] > Sent: October-21-10 4:32 AM > To: fop-users@xmlgraphics.apache.org > Subject: Re: FW: Can't get RTF page break working > > Hi Chen, > > It seems like there's a known bug with the RTF format, it doesn't seem to > print the page breaks, you can see this in Bugzilla bug #42600 > (https://issues.apache.org/bugzilla/show_bug.cgi?id=42600). There is a patch > associated with this bug but from the looks of it, it requires approval. > > Sorry I couldn't be any more help > > Mehdi > > On 21 October 2010 08:26, mehdi houshmand <med1...@gmail.com> wrote: >> Hi Chen, >> >> I'm finding the same issue when I use your FO, just to warn you >> however, your second table cell looks as follows: >> >> <fo:block break-after="page" break-before="page" line-height="14pt" >> font-size="11pt" font-family="Times" font-weight="normal">7031968 1 >> Version </fo:block> >> >> This could have been a mistake, but what was your intention for this >> table-cell? I have changed the output to PDF and the page-breaks are >> working there, is that output you wish presented? In order to ouput >> to pdf you use a similar command: >> >> "# Fop -xml scource.xml -xsl dic_new.xsl -pdf FILENAME.pdf" >> >> Mehdi >> >> On 20 October 2010 20:13, Chen Yang <cy...@hrsg.ca> wrote: >>> Hello list, >>> >>> I have tried to get the rtf page break working with fop trunk, but >>> seem going nowhere so far. >>> >>> >>> >>> I played around with Fop 0.95 and recently upgrade to Fop 1.0 for >>> the project I am working on. But soon I discovered RTF page break is >>> only available in fop trunk with RTFlib(jfor) >>> >>> So I spend some time use ANT 1.8.1 to build fop trunk with CentOS >>> 5.5 >>> >>> >>> >>> Here is my code >>> >>> >>> >>> <fo:table xsl:use-attribute-sets="table_p" break-after="page"> >>> >>> . >>> >>> . >>> >>> . >>> >>> </fo:table> >>> >>> >>> >>> Or >>> >>> >>> >>> <fo:block xsl:use-attribute-sets="competency-group-name" >>> break-before="page"> >>> >>> <xsl:apply-templates/> >>> >>> </fo:block> >>> >>> >>> >>> And here is the command I used >>> >>> >>> >>> "# Fop -xml scource.xml -xsl dic_new.xsl -rtf test_1.1.rtf" >>> >>> >>> >>> Result was I can get the rtf file but all the tables are still stuck >>> in one page. >>> >>> >>> >>> I tried to run Page_Break.fo (see attachment) which I found from the >>> mail-list, also can't get it work. >>> >>> >>> >>> Since I am a newbie with FOP and Java, I have no idea what is wrong >>> and how I can get this working, >>> >>> >>> >>> If anyone can give me some guide on this, I'll be much appreciated, >>> >>> >>> >>> Thanks in advance >>> >>> >>> >>> Chen Yang >>> >>> Programmer / Analyst >>> >>> HRSG (Human Resource Systems Group) >>> >>> Email: cy...@hrsg.ca >>> >>> Web: www.hrsg.ca >>> >>> >>> >>> -------------------------------------------------------------------- >>> - To unsubscribe, e-mail: >>> fop-users-unsubscr...@xmlgraphics.apache.org >>> For additional commands, e-mail: >>> fop-users-h...@xmlgraphics.apache.org >>> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org > For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org > For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org
### Eclipse Workspace Patch 1.0 #P fop_trunk Index: src/java/org/apache/fop/render/rtf/RTFHandler.java =================================================================== --- src/java/org/apache/fop/render/rtf/RTFHandler.java (revision 720166) +++ src/java/org/apache/fop/render/rtf/RTFHandler.java (working copy) @@ -436,7 +436,7 @@ RtfTextrun textrun = container.getTextrun(); textrun.addParagraphBreak(); - textrun.popBlockAttributes(); + textrun.popBlockAttributes(bl.getBreakAfter()); } catch (IOException ioe) { handleIOTrouble(ioe); @@ -488,7 +488,7 @@ RtfTextrun textrun = container.getTextrun(); textrun.addParagraphBreak(); - textrun.popBlockAttributes(); + textrun.popBlockAttributes(bl.getBreakAfter()); } catch (IOException ioe) { handleIOTrouble(ioe); Index: src/java/org/apache/fop/render/rtf/TextAttributesConverter.java =================================================================== --- src/java/org/apache/fop/render/rtf/TextAttributesConverter.java (revision 720166) +++ src/java/org/apache/fop/render/rtf/TextAttributesConverter.java (working copy) @@ -35,6 +35,7 @@ import org.apache.fop.fo.flow.Inline; import org.apache.fop.fo.flow.Leader; import org.apache.fop.fo.flow.PageNumber; +import org.apache.fop.fo.flow.table.TableCell; import org.apache.fop.fo.properties.CommonBorderPaddingBackground; import org.apache.fop.fo.properties.CommonFont; import org.apache.fop.fo.properties.CommonMarginBlock; @@ -80,9 +81,39 @@ attrBlockMargin(fobj.getCommonMarginBlock(), attrib); attrBlockTextAlign(fobj.getTextAlign(), attrib); attrBorder(fobj.getCommonBorderPaddingBackground(), attrib, fobj); - + attrBreak(fobj,attrib); + return attrib; } + + private static void attrBreak(Block fobj, FOPRtfAttributes attrib) + { + if(fobj.getBreakBefore()==Constants.EN_PAGE) + { + //"sect" Creates a new section and a page break, + //a simple page break with control word "page" caused + //some problems + boolean bHasTableCellParent = false; + FONode f=fobj; + while (f.getParent() != null) { + f=f.getParent(); + if(f instanceof TableCell) + { + bHasTableCellParent = true; + break; + } + } + if(!bHasTableCellParent) + { + attrib.set("sect"); + } + else + { + log.warn("Cannot create break-before for a block inside a table"); + } + } + //Break after is handled in RtfCloseGroupMark + } /** * Converts all known text FO properties to RtfAttributes Index: src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java =================================================================== --- src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java (revision 720166) +++ src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java (working copy) @@ -25,8 +25,12 @@ import java.util.Iterator; import java.util.List; import java.util.ListIterator; +import java.util.Stack; // FOP +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.fop.fo.Constants; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfExternalGraphic; /** @@ -38,6 +42,11 @@ private boolean bSuppressLastPar = false; private RtfListItem rtfListItem; + /** + * logging instance + */ + protected static Log log = LogFactory.getLog(RtfTextrun.class); + /** Manager for handling space-* property. */ private RtfSpaceManager rtfSpaceManager = new RtfSpaceManager(); @@ -68,28 +77,52 @@ /** Class which represents the closing of a RTF group mark.*/ private class RtfCloseGroupMark extends RtfElement { + private int breakType = Constants.EN_AUTO; + + RtfCloseGroupMark(RtfContainer parent, Writer w, int breakType) + throws IOException { + super(parent, w); + this.breakType = breakType; + } + + /** + * @return true if this element would generate no "useful" RTF content + */ + public boolean isEmpty() { + return false; + } + + public int getBreakType() + { + return breakType; + } + + /** + * write RTF code of all our children + * @throws IOException for I/O problems + */ + protected void writeRtfContent() throws IOException { + writeGroupMark(false); + boolean bHasTableCellParent = + this.getParentOfClass(RtfTableCell.class) != null; + + //Unknown behavior when a table starts a new section, + //Word may crash + if(breakType == Constants.EN_PAGE) + { + if(!bHasTableCellParent) + { + writeControlWord("sect"); + } + else + { + log.warn("RtfCloseGroupMark:writeRtfContent Cannot " + + "create break-after for a block inside a table"); + } + } + } + } - RtfCloseGroupMark(RtfContainer parent, Writer w) - throws IOException { - super(parent, w); - } - - /** - * @return true if this element would generate no "useful" RTF content - */ - public boolean isEmpty() { - return false; - } - - /** - * write RTF code of all our children - * @throws IOException for I/O problems - */ - protected void writeRtfContent() throws IOException { - writeGroupMark(false); - } - } - /** Class which represents a paragraph break.*/ private class RtfParagraphBreak extends RtfElement { @@ -132,11 +165,21 @@ /** * Adds instance of <code>CloseGroupMark</code> as a child. - * + * * @throws IOException for I/O problems */ + private void addCloseGroupMark(int breakType) throws IOException { + RtfCloseGroupMark r = new RtfCloseGroupMark(this, writer, breakType); + } + + /** + * Adds instance of <code>CloseGroupMark</code> as a child, but without a break option. + * Inline attributes do not need that for example + * + * @throws IOException for I/O problems + */ private void addCloseGroupMark() throws IOException { - RtfCloseGroupMark r = new RtfCloseGroupMark(this, writer); + RtfCloseGroupMark r = new RtfCloseGroupMark(this, writer, Constants.EN_AUTO); } /** @@ -158,11 +201,11 @@ * * @throws IOException for I/O problems */ - public void popBlockAttributes() throws IOException { - rtfSpaceManager.popRtfSpaceSplitter(); - rtfSpaceManager.stopUpdatingSpaceBefore(); - addCloseGroupMark(); - } + public void popBlockAttributes(int breakType) throws IOException { + rtfSpaceManager.popRtfSpaceSplitter(); + rtfSpaceManager.stopUpdatingSpaceBefore(); + addCloseGroupMark(breakType); + } /** * Pushes inline attributes. @@ -228,28 +271,30 @@ * @throws IOException for I/O problems */ public void addParagraphBreak() throws IOException { - // get copy of children list - List children = getChildren(); + // get copy of children list + List children = getChildren(); + Stack tmp = new Stack(); - // delete all previous CloseGroupMark - int deletedCloseGroupCount = 0; + // delete all previous CloseGroupMark + int deletedCloseGroupCount = 0; - ListIterator lit = children.listIterator(children.size()); - while (lit.hasPrevious() - && (lit.previous() instanceof RtfCloseGroupMark)) { - lit.remove(); - deletedCloseGroupCount++; - } + ListIterator lit = children.listIterator(children.size()); + while (lit.hasPrevious() + && (lit.previous() instanceof RtfCloseGroupMark)) { + tmp.push(new Integer(((RtfCloseGroupMark)lit.next()).getBreakType())); + lit.remove(); + deletedCloseGroupCount++; + } - if (children.size() != 0) { - // add paragraph break and restore all deleted close group marks - setChildren(children); - new RtfParagraphBreak(this, writer); - for (int i = 0; i < deletedCloseGroupCount; i++) { - addCloseGroupMark(); - } - } - } + if (children.size() != 0) { + // add paragraph break and restore all deleted close group marks + setChildren(children); + new RtfParagraphBreak(this, writer); + for (int i = 0; i < deletedCloseGroupCount; i++) { + addCloseGroupMark(((Integer)tmp.pop()).intValue()); + } + } + } /** * Inserts a leader.
Page_Break.fo
Description: Page_Break.fo
--------------------------------------------------------------------- To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org