Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Pau Larsen 15 posts 35 karma points
    Nov 07, 2012 @ 10:06
    Pau Larsen
    0

    RichTextToXML doesn't return formatted text

    Hi,

    We are trying to render RTE fields using this code:

    <fo:block font-size="7pt" color="#000000">
    <xsl:variable name="xhtml" select="FergusonMoriyama.Pdf.XsltHelper:RichTextToXml($currentProject/beskrivelse)"/> <xsl:apply-templates select="$xhtml"/>
    </fo:block>

    ...but we only get the text from RTE stripped of all formatting.

    To keep it simple we have tried to publish simple RTE content like <p><strong>Test</strong></p> - but it doesn't come out bold.

    We have also tried to preprocess the RTE content with normalize-space as some have suggested but that didn't help.

    If we render out the RTE without RichTextToXML we do see the HTML tags in the document so they are passed to RichTextToXML.

    Any suggestions for how to make it work or further debugging is very welcome - thanks.

     

    /Pau

  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    Nov 07, 2012 @ 11:03
    Darren Ferguson
    0

    Can you post your entire XSLT file?

    Do you have templates that match the strong tag and output the equivalent fo:inline tag to make it render bold?

  • Alex Reyes 10 posts 30 karma points
    Nov 07, 2012 @ 12:19
    Alex Reyes
    0

    Hello Darren,

    I've posted the code below (I've isolated the relevant RTF code).

    As for the 2nd question: no, there's no xsl:template.

    BR,
    Alex

     

    <?xml version="1.0" encoding="UTF-8"?>

    <xsl:stylesheet
      version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:msxml="urn:schemas-microsoft-com:xslt"

      xmlns:rdm="http://www.umbraco.org/"

      xmlns:umbraco.library="urn:umbraco.library"

      xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon"
      xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes"
      xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath"
      xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions"
      xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings"
      xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"

      xmlns:FergusonMoriyama.Pdf.XsltHelper="urn:FergusonMoriyama.Pdf.XsltHelper"
      xmlns:ibex="http://www.xmlpdf.com/2003/ibex/Format"
      exclude-result-prefixes="rdm msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets FergusonMoriyama.Pdf.XsltHelper">

      <xsl:output method="xml" omit-xml-declaration="yes"/>

      <xsl:param name="currentPage"/>
      <xsl:variable name="webRootPath" select="FergusonMoriyama.Pdf.XsltHelper:GetWebRootPath()"/>
      <xsl:variable name="idx" select="umbraco.library:RequestQueryString('projekt')"/>

      <xsl:template match="/">
        <xsl:if test="$idx != ''">
          <xsl:variable name="currentProject" select="umbraco.library:GetXmlNodeById($idx)" />

          <!-- These two headers tell PDF for Umbraco to render a PDF -->
          <xsl:value-of select="FergusonMoriyama.Pdf.XsltHelper:SetResponseContentType('text/xml')"/>
          <!-- If you remove this you'll see the FO output in the browser -->
          <xsl:value-of select="FergusonMoriyama.Pdf.XsltHelper:AppendResponseHeader('X-Pdf-Render', 'true')"/>
          <xsl:value-of select="FergusonMoriyama.Pdf.XsltHelper:AppendResponseHeader('X-Pdf-Force-Download', 'Test.pdf')"/>
          <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
            <fo:layout-master-set>
              <fo:simple-page-master master-name="A4"
                page-width="210mm"
                page-height="297mm"
                margin-top="13mm"
                margin-bottom="34mm"
                margin-left="55mm"
                margin-right="21mm">
                <fo:region-body margin-top="86mm" margin-right="0mm" margin-bottom="0mm" margin-left="0mm" />
                <fo:region-before extent="0mm"/>
                <fo:region-after extent="0mm"/>
                <fo:region-start extent="0mm"/>
                <fo:region-end extent="0mm"/>
              </fo:simple-page-master>
            </fo:layout-master-set>
        
            <fo:page-sequence master-reference="A4" format="A">
              <fo:static-content flow-name="xsl-region-before">
                <fo:block font-size="18pt" color="#00adee">
                  <fo:inline>
                    <xsl:value-of select="$currentProject/projektnavn"/>
                  </fo:inline>
                </fo:block>
              </fo:static-content>
              <fo:flow flow-name="xsl-region-body">

                <fo:table-and-caption>
                  <fo:table table-layout="fixed" width="100%" height="96mm">
                    <fo:table-column column-width="75mm"/> <!-- Description -->
                    <fo:table-column column-width="60mm"/> <!-- Other Content -->
                    
                    <fo:table-body>
                      <fo:table-row>

                        <!-- This is the left side of the project PDF (descriptive text) -->
                        <fo:table-cell>
                          <fo:block font-size="7pt" color="#000000">
                            <xsl:variable name="xhtml" select="FergusonMoriyama.Pdf.XsltHelper:RichTextToXml(normalize-space($currentProject/beskrivelse))"/> <xsl:apply-templates select="$xhtml"/>
                          </fo:block>
                        </fo:table-cell>
                
                        <!-- This is the right side of the project PDF (table data) -->
                        <fo:table-cell>
                          <fo:block margin-left="5mm">Other content goes here...</fo:block>
                        </fo:table-cell>
                
                      </fo:table-row>
                    </fo:table-body>
                  
                  </fo:table>
                </fo:table-and-caption>

              </fo:flow>
            </fo:page-sequence>
          </fo:root>

        </xsl:if>
      </xsl:template>
        
    </xsl:stylesheet>

  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    Nov 07, 2012 @ 13:10
    Darren Ferguson
    0

    @Alex the examples that install with PDF creator show how to provide xsl:template that match HTML tags e.g. you would need a template to match the strong tag.

    I'm not sure what you are expecting XsltHelper:RichTextToXml to do, but it just turns your rich text in to XML and you then have to use xslt to output the fo to format the rich text - it isn't automatic.

     

  • Alex Reyes 10 posts 30 karma points
    Nov 07, 2012 @ 13:51
    Alex Reyes
    0

    I was under the impression that using just the function by itself is sufficient, just like in the Razor example.

    Okay, now I've attached the templates to the xslt in the same manner as the [PDF]XsltHelloWorld.xslt and majority of the tags are now being parsed correctly.
    Thanks!

  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    Nov 07, 2012 @ 14:44
    Darren Ferguson
    0

    @Alex the Razor sample uses the same mechanism, there are specific helper functions to match html tags - it doesn't do it automatically.

Please Sign in or register to post replies

Write your reply to:

Draft