Page 1 of 1

pdf Conversion: support for tl2br and tr2bl

PostPosted: Wed Mar 09, 2011 8:41 pm
by Richard
Hi Jason,

I have started to add support for the tl2br and tr2bl cell borders to the XSLFO pdf creator.
I've extended the propertyFactory, added two new classes to the new org.docx4j.model.properties.table and I tried to extend the fop.xsd. Unfortunatly it is not working yet and gives me the following exception:

org.docx4j.openpackaging.exceptions.Docx4JException: FOP issues
at org.docx4j.convert.out.pdf.viaXSLFO.Conversion.output(Conversion.java:357)
at PdfGenerator.main(PdfGenerator.java:34)
Caused by: javax.xml.transform.TransformerException: org.apache.fop.fo.ValidationException: Invalid property encountered on "fo:table-cell": border-tl2br-color (Siehe Position 11:630)
at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:502)
at org.docx4j.convert.out.pdf.viaXSLFO.Conversion.output(Conversion.java:350)
... 1 more
Caused by: org.apache.fop.fo.ValidationException: Invalid property encountered on "fo:table-cell": border-tl2br-color (Siehe Position 11:630)
at org.apache.fop.events.ValidationExceptionFactory.createException(ValidationExceptionFactory.java:38)
at org.apache.fop.events.EventExceptionManager.throwException(EventExceptionManager.java:54)
at org.apache.fop.events.DefaultEventBroadcaster$1.invoke(DefaultEventBroadcaster.java:175)
at $Proxy38.invalidProperty(Unknown Source)
at org.apache.fop.fo.PropertyList.handleInvalidProperty(PropertyList.java:470)
at org.apache.fop.fo.PropertyList.convertAttributeToProperty(PropertyList.java:389)
at org.apache.fop.fo.PropertyList.addAttributesToList(PropertyList.java:319)
at org.apache.fop.fo.FObj.processNode(FObj.java:119)
at org.apache.fop.fo.flow.table.TableFObj.processNode(TableFObj.java:233)
at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.startElement(FOTreeBuilder.java:282)
at org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:171)
at org.apache.xalan.transformer.TransformerIdentityImpl.startElement(TransformerIdentityImpl.java:1073)
at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:485)
... 2 more


Can you please have a look at my patch and tell me what further work has to be done to get things going. I also attached my test document.

Thx,
Richard

Re: pdf Conversion: support for tl2br and tr2bl

PostPosted: Wed Mar 09, 2011 9:52 pm
by jason
Hi Richard

fop.xsd is a schema for valid XSL FO files.

You can't just add new attributes to it and expect FOP to process them (hence the Validation exception) .. you'd have to modify FOP as well.

docx4j uses the classes generated from fop.xsd as a way to create valid XSL FO. See LayoutMasterSetBuilder as an example. The fop.xsd classes were added relatively recently to enable that, since I found it more attractive than creating the fo XML in the XSLT, or in DOM via an extension function.

When you modify viaXSLFO.TableWriter to support cell borders, you could use the existing XSL FO classes to create the appropriate fo XML, or you could do it using the DOM consistent with the rest of that class (which predates the fop.xsd classes).

cheers .. Jason