Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Print to PDF
Message
General information
Forum:
ASP.NET
Category:
Pictures and Image processing
Title:
Environment versions
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01518063
Message ID:
01518221
Views:
45
Hi Viv, thought I'd keep you updated with my progress - I opted for a free library called PdfSharp ( very impressive and overkill for my needs but ? ) this is what I have so far ( haven't prettified it yet )
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using PdfSharp;
using PdfSharp.Drawing;
using PdfSharp.Fonts;
using PdfSharp.Forms;
using PdfSharp.Internal;
using PdfSharp.Pdf;
using PdfSharp.SharpZipLib;
using System.Diagnostics;
using System.IO;
namespace BCCI.Utils
{
    public class PDFHelper
    {
        public static void CreatePdfFromForm(Form frm,string FilePath)
        {
            PdfDocument doc = new PdfDocument();
            PdfPage p = doc.AddPage();
            XGraphics xgr = XGraphics.FromPdfPage(p);

            Bitmap bm = new Bitmap(frm.Width, frm.Height);
            Graphics grfx = Graphics.FromImage(bm);
            grfx.CopyFromScreen(frm.Location.X, frm.Location.Y, 0, 0, frm.Size, CopyPixelOperation.SourceCopy);
            XImage img = XImage.FromGdiPlusImage(bm);
            
            p.Width = img.PixelWidth;
            p.Height = img.PixelHeight;
            p.Orientation = PageOrientation.Landscape;
            
            xgr.DrawImage(img,0,0);
            doc.Save(FilePath);
            doc.Close();
            bm.Dispose();
            grfx.Dispose();
            img.Dispose();
            xgr.Dispose();
        }
    }
}
Regards,
Peter J. Kane



Pete
Previous
Reply
Map
View

Click here to load this message in the networking platform