Project Description
silverPDF is a Silverlight library that makes it easier for developers to create PDF files on the client side.

silverPDF is sponsored by Aleyant Systems (http://www.aleyant.com)

silverPDF is based on two excellent open source projects: PdfSharp (http://www.pdfsharp.net) and iTextSharp (http://itextsharp.sourceforge.net)

void GenerateAndSavePDF_Button_Click(object sender, RoutedEventArgs e)
{
    SaveFileDialog d = new SaveFileDialog();
    d.Filter = "PDF file format|*.pdf";

    // Save the document...
    if (d.ShowDialog() == true)
    {
         // Create a new PDF document
         PdfDocument document = new PdfDocument();

         // Create an empty page
         PdfPage page = document.AddPage();
         //page.Contents.CreateSingleContent().Stream.UnfilteredValue;

         // Get an XGraphics object for drawing
         XGraphics gfx = XGraphics.FromPdfPage(page);

         XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always);

         // Create a font
         XFont font = new XFont("Huxtable", 20, XFontStyle.Bold, options);

         // Draw the text
         gfx.DrawString(text1.Text, font, XBrushes.Black,
             new XRect(0, 0, page.Width, page.Height),
             XStringFormats.Center);

         document.Save(d.OpenFile());
    }
}

Last edited Jul 12, 2010 at 9:30 AM by Ai_boy, version 11