- How to add page numbers to your PDF
- Add text field to PDF
- Append multiple PDF documents
- Bulleted list from XML and XSL
- Merge PDF
- Calculate the height of a paragraph in PDF
- Multipage TIFF to PDF
- Convert TXT to PDF
- Convert XHTML to PDF
- Create PDF in C# - Tall Components - Check out our PDF code samples
- Text formatting
- Generate PDF form from XML
- Generate PDF with local images from XML with Xamarin.iOS
- XhtmlParagraph and TrueType fonts
- Add footer with left and right aligned text on same line
- Read and write meta data from PDF
- Stitch PDF documents
- Use multiple licenses
- What is the resulting fontsize in PDF rich text used in SimpleXhtmlShape
Bulleted list from XML and XSL
This code sample helps getting a bulleted list from XML and XSL.
See PDF output.
XML
<?xml version="1.0" encoding="utf-8" ?>
<countries>
<country>
<name>Sweden</name>
</country>
<country>
<name>Norway</name>
</country>
<country>
<name>Denmark</name>
</country>
</countries>
XSL
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<document>
<section pagesize="a4" startonnewpage="true">
<xsl:apply-templates select="countries"/>
</section>
</document>
</xsl:template>
<xsl:template match="country">
<paragraph type="NumberedItem">
<numberfragment type="fragment" font="symbol" fontsize="10">·</numberfragment>
<fragment fontsize="10">
<xsl:value-of select="name"/>
</fragment>
</paragraph>
</xsl:template>
</xsl:stylesheet>
C#
// Load XML
XmlDocument xml = new XmlDocument();
xml.Load("data.xml");
// Load XSL
XslTransform xsl = new XslTransform();
xsl.Load("transform.xsl");
// Transform
XmlReader reader = xsl.Transform(xml, null);
// Write PDF
Document doc = new Document();
doc.Read(reader);
using (FileStream file = new FileStream("out.pdf", FileMode.Create, FileAccess.ReadWrite))
{
doc.Write(file);
}