i have to render on QTextDocument XSL-FO file and
all QTextBlockFormat, QTextCharFormat, QTextTableCell QText format class
its does not know to make border color and border size left 3pt bottom 10pt as example..

i found to be useful use the inline svg to thisplay border ....

the tag sample... ( fo:block is like html <P>)

[HTML]
<fo:block>
A text line below the instream object.
</fo:block>
<fo:block>
<fo:instream-foreign-object>
<svg:svg width="250" height="50">
<svg:g style="fill:red; stroke:#000000">
<svg:rect x="0" y="0" width="15" height="15"/>
<svg:rect x="5" y="5" width="15" height="15"/>
</svg:g>
<svg:text x="10" y="30">SVG placed in a block</svg:text>
</svg:svg>
</fo:instream-foreign-object>
</fo:block>
[/HTML]

here is the svg class function that render & take domelement svg transorm and paint..
the problem if i not fill pix.fill(QColor("#ffffff")); the svg is display black ...
now to display varius layer on a scene how i can make this background color transparent?
To to overlap 3 or moore layer ...


Qt Code:
  1. QPixmap FopFormat::RenderSvg( const QDomElement e )
  2. {
  3. nrloop++; /* count element to addresource ! */
  4. /* QString trytosave = QString("svg_%1.svg").arg(nrloop); */
  5. QDomProcessingInstruction header = em.createProcessingInstruction( "xml", "version=\"1.0\" standalone=\"no\"" );
  6. em.appendChild( header );
  7. em.appendChild( e.firstChildElement() );
  8. QDomElement root = em.documentElement();
  9. root.setAttribute ("xmlns","http://www.w3.org/2000/svg");
  10. root.setAttribute ("version","1.2");
  11. root.setAttribute ("baseProfile","tiny");
  12. QString srcsv = em.toString();
  13. if (srcsv.contains("svg:svg")) {
  14. srcsv = srcsv.replace("svg:","");
  15. }
  16. /* try to save to show on firefox if work
  17.   QFile f( trytosave );
  18.   if ( f.open( QFile::WriteOnly | QFile::Text ) )
  19.   {
  20.   QTextStream sw( &f );
  21.   sw << srcsv;
  22.   f.close();
  23.   }
  24.   */
  25. QByteArray streamsvg;
  26. streamsvg.append ( srcsv );
  27. QSvgRenderer svgRenderer( streamsvg );
  28. QPixmap pix( svgRenderer.defaultSize() );
  29. pix.fill(QColor("#ffffff"));
  30. QPainter paint(&pix);
  31. svgRenderer.render(&paint);
  32. if (pix.isNull() ) {
  33. QPixmap pixe(22,22);
  34. pixe.fill(QColor("crimson")); /* a error red pixel */
  35. return pixe;
  36. } else {
  37. return pix;
  38. }
  39. }
  40.  
  41.  
  42. bool FopFormat::ObjectParserTag( const QDomElement &e )
  43. {
  44. nrloop++;
  45. QDomElement domObject = e.firstChildElement();
  46. if ( domObject.tagName().toLower() == "svg:svg" || domObject.tagName().toLower() == "svg" ) {
  47. QPixmap paintsvg = RenderSvg(e);
  48. Tdoc->addResource( QTextDocument::ImageResource, QUrl(QString("%1").arg(nrloop)), paintsvg );
  49. format.setName( QString("%1").arg(nrloop) );
  50. format.setToolTip(QString("SVG dom."));
  51. Tcursor.insertImage( format ); /* cursor insert image QPixmap */
  52. return true;
  53. }
  54.  
  55. return false;
  56. }
To copy to clipboard, switch view to plain text mode