Search This Blog

Wednesday, 1 February 2017

pdfButton Click

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xfinium.Pdf;
using Xfinium.Pdf.Graphics;

namespace App2
{
    public partial class MainPage : ContentPage
    {
        public MainPage()
        {
            InitializeComponent();
            btnRecord.Clicked += BtnRecord_Clicked;
        }

        private void BtnRecord_Clicked(object sender, EventArgs e)
        {
            PdfFixedDocument document = new PdfFixedDocument();
            PdfPage page = document.Pages.Add();
            PdfStandardFont helvetica = new PdfStandardFont(PdfStandardFontFace.Helvetica, 24);
            PdfBrush brush = new PdfBrush();
            page.Graphics.DrawString("World is a common name for the whole of human civilization, specifically human experience, history, or the human condition in general, worldwide, i.e. anywhere on Earth or pertaining to anywhere on earth.", helvetica, brush, 100, 100);
            MemoryStream stream = new MemoryStream();
            document.Save(stream);

            DependencyService.Get<ISaveAndLoad>().Save("HelloWorld.pdf", "application/pdf", stream);
        }
    }
}

No comments:

Post a Comment