[ https://issues.apache.org/jira/browse/FOP-2852?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16795109#comment-16795109 ]
Matthias Reischenbacher commented on FOP-2852: ---------------------------------------------- First you transform to the intermediate tree XML format, here a code sample: {code:java} //Create a user agent FOUserAgent userAgent = this.fopFactory.newFOUserAgent(); this.configureUserAgent(userAgent, targetResolution); //Create an instance of the target document handler so the IFSerializer //can use its font setup String mime = mimeOutput == null ? MimeConstants.MIME_PDF : mimeOutput; //Create an instance of the target renderer so the XMLRenderer can use its font setup Renderer targetRenderer = userAgent.getRendererFactory().createRenderer( userAgent, mime); //Create the XMLRenderer to create the area tree XML XMLRenderer xmlRenderer = new XMLRenderer(userAgent); //Tell the XMLRenderer to mimic the target renderer xmlRenderer.mimicRenderer(targetRenderer); //Make sure the prepared XMLRenderer is used userAgent.setRendererOverride(xmlRenderer); File tempFile; // Setup output OutputStream out; try { tempFile = File.createTempFile("fop-if", ".xml"); out = new FileOutputStream(tempFile); } catch (IOException e) { throw new RuntimeException(e); } out = new BufferedOutputStream(out); Source src = new DOMSource(xslFoDoc); try { Fop fop = this.fopFactory.newFop(null, userAgent, out); // Setup XSLT TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(); // Resulting SAX events (the generated FO) must be piped through to FOP Result res = new SAXResult(fop.getDefaultHandler()); // Start XSLT transformation and FOP processing transformer.transform(src, res); } finally { IOUtils.closeQuietly(out); } {code} Then you modify the generated XML, e.g. by applying a XSL transform (make sure, to give the list-item-label elements in your FO markup an "id", that matches the XPath expression in the template): {code:java} <xsl:template match="block[starts-with(@prod-id, 'list-item-label')]"> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:variable name="currentBaseLine" select="lineArea/@bpda"/> <xsl:variable name="nextBaseLine" select="parent::block/following-sibling::block[1]/block[1]/lineArea[1]/@bpda"/> <xsl:variable name="diff" select="($nextBaseLine - $currentBaseLine)"/> <xsl:attribute name="bap"> <xsl:value-of select="concat('0 0 ', $diff, ' 0')"/> </xsl:attribute> <xsl:attribute name="padding-before"> <xsl:value-of select="$diff"/> </xsl:attribute> <xsl:apply-templates/> </xsl:copy> </xsl:template> {code} And then you convert the transformed intermediate XML format to PDF: {code:java} //Create a user agent FOUserAgent userAgent = this.fopFactory.newFOUserAgent(); this.configureUserAgent(userAgent, targetResolution); //Setup target handler String mime = mimeOutput == null ? MimeConstants.MIME_PDF : mimeOutput; try { //Setup fonts and user agent FontInfo fontInfo = new FontInfo(); //Construct the AreaTreeModel that will received the individual pages AreaTreeModel treeModel = new RenderPagesModel(userAgent, mime, fontInfo, out); //Iterate over all area tree files AreaTreeParser parser = new AreaTreeParser(); Source src = new DOMSource(xslFoDoc); parser.parse(src, treeModel, userAgent); //Signal the end of the processing. The renderer can finalize the target document. treeModel.endDocument(); } catch (SAXException e) { throw new FOPException(e); } finally { IOUtils.closeQuietly(out); } {code} As I said, all a bit hacky, but it works :). > relative-align on list-item is ignored > -------------------------------------- > > Key: FOP-2852 > URL: https://issues.apache.org/jira/browse/FOP-2852 > Project: FOP > Issue Type: Bug > Affects Versions: 2.3 > Reporter: Björn Kautler > Priority: Major > Attachments: image-2019-03-18-15-51-15-406.png > > > When you have a list-item where in the first line is an inline image, the > enumeration is too high as it is top-aligned like this: > !image-2019-03-18-15-51-15-406.png! > As far as I have seen this is ok as default behavior. > But if the `list-item` has the attribute `relative-align` set to `baseline` > it should align to the baseline as far as I understood, but it seems Fop > totally ignores this. > The screenshot is made with the attribute set. > -- This message was sent by Atlassian JIRA (v7.6.3#76005)