Best way to create PDF from XML XSLT in C# -


i have requirement crate pdf of xml records. think there no way directly create pdf xml using xslt or xsl fo believe can done. have been reading lots of articles searching way using c#.

--> what's best approach of during this? example great.

my scenario:

i have xml looks like:

<products>   <brand name="test">     <quantity value="2/>      <price value="$20"/>   </brand>   <brand name="test2">     <quantity value="3/>      <price value="$30"/>   </brand>   <brand name="test3">     <quantity value="4/>      <price value="$40"/>   </brand> </products> 

how can create pdf have table showing information?

i know there lots of similar questions of them outdated. appreciated.

in past i've used commercial library called ibex pdf creator generate pdf documents xml data using xsl-fo standard has worked well.

here's example of how use it:

xml data:

<documentroot>     <!-- content --> </documentroot> 

xsl-fo layout:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform">     <xsl:template match="/documentroot">         <fo:root xmlns:fo="http://www.w3.org/1999/xsl/format" xmlns:ibex="http://www.xmlpdf.com/2003/ibex/format">             <ibex:properties                 title="some document"                 subject=""                 author=""                 keywords=""                 creator="" />             <fo:layout-master-set>                 <fo:simple-page-master master-name="a4" page-width="210mm" page-height="297mm">                     <fo:region-body margin-bottom="1cm" margin-top="3cm"/>                     <fo:region-before extent="20mm"/>                     <fo:region-after extent="8mm"/>                     <fo:region-start extent="1mm"/>                     <fo:region-end extent="1mm"/>                 </fo:simple-page-master>             </fo:layout-master-set>         </<fo:root>     </xsl:template> </xsl:stylesheet> 

generating pdf document in .net:

var data = new memorystream(databytes); var layout = new memorystream(layoutbytes); var pdf = new memorystream();  // using ibex pdf creator .net api var doc = new fodocument(); doc.generate(data, layout, pdf); 

i hope helps.


Comments