using System;
using System.Windows.Forms;
using System.IO;
using PDFlibDLL;

namespace Hello_World
{
    public partial class Form1 : Form
    {
        // losLab PDF Library DLL Edition setup
        PDFlibrary PDF;

        public Form1()
        {
            InitializeComponent();

            // Different filename for 32-bit and 64-bit DLL
            string dllName;

            // Check to see if IntPtr size is 4.
            // If 4 then it's 32-bit, if 8 then it is 64-bit.
            if (IntPtr.Size == 4)
            {
                dllName = "PDFlibDLL32.dll"; // 32 bits 
            }
            else
            {
                dllName = "PDFlibDLL64.dll"; // 64 bits 
            }

            // Load the library
            if (!(File.Exists(dllName) || File.Exists(Environment.SystemDirectory + @"\" + dllName)))
                dllName = @"..\..\..\..\DLL\" + dllName;

            PDF = new PDFlibrary(dllName);

            if (PDF.LibraryLoaded()) ;
            else
                MessageBox.Show("Could not locate the PDF Library DLL!");
        }

        private void btnHelloWorld_Click(object sender, EventArgs e)
        {
            string fileName = @".\drawText.pdf";
            PDF.SetOrigin(1);
            PDF.DrawText(100, 100, "HelloWorld from C#");
            PDF.SaveToFile(fileName);
            System.Diagnostics.Process.Start(fileName);
        }
    }
}