thanks so much for your reply, i was able to get the project started but now i am having some issues adding an image to the pdf. i reviewed many samples but keep getting errors that the section is not part of the current context or that i am missing using or references. here is the code to generate my pdf, can you help me figure out why i can get an image to dispaly or how to remove the errors.
Code:
using PdfSharp.Drawing;
using PdfSharp.Pdf;
using PdfSharp.Fonts;
using PdfSharp;
using System;
using System.Collections.Generic;
using ArdentMC.DHS.COP.Mobile.MVC.Models;
using System.Linq;
using System.Text;
using System.IO;
using MigraDoc.DocumentObjectModel.Shapes;
using System.Drawing;
using PdfSharp.Drawing.Layout;
using System.Web.Mvc;
using System.Web;
using System.Text.RegularExpressions;
using MigraDoc.DocumentObjectModel;
using System.Drawing.Imaging;
using HtmlRenderer;
namespace ArdentMC.DHS.COP.Mobile.MVC.Controllers
{
class ReportPdfManager
{
protected int lineHeight = 10;
protected int currentTop = 10;
public static int margin = 20;
protected int currentLeft = margin;
public static int indentedMargin = margin + 20;
protected PdfPage currentPage;
public PdfDocument GenerateReport(Reports report)
{
var document = new PdfDocument();
document.Info.Title = "";
var page = document.AddPage();
var graphics = XGraphics.FromPdfPage(page);
var font = new XFont("Verdana", 10, XFontStyle.BoldItalic);
//HtmlRenderer.HtmlContainer c = new HtmlRenderer.HtmlContainer();
//c.SetHtml(report.Description);
string ImageArea = @C:\TFS\DHS GMO\ArdentMC.DHS.COP.MapShell-PDFSharpDemoAlana\ArdentMC.DHS.COP.Mobile.MVC\Images\dhslogo.png;
Image image = section.AddImage(ImageArea + "dhslogo.png");
image.Width = "2.5cm";
image.LockAspectRatio = true;
image.RelativeHorizontal = RelativeHorizontal.Margin;
image.WrapFormat.Style = WrapStyle.Through;
graphics.DrawString("UNCLASSIFIED/FOR OFFICAL USE ONLY", font, XBrushes.Red, new XRect(margin, currentTop, page.Width, currentTop), XStringFormats.TopCenter);
currentTop += lineHeight;
graphics.DrawString(" " + report.Phase + "-" + report.NocNumber + " " + report.Title + "-" + report.Location, font, XBrushes.Black, new XRect(margin, currentTop, page.Width, page.Height), XStringFormats.TopCenter);
currentTop += lineHeight;
graphics.DrawString("US Department of Homeland Security Report as of:" + report.ReportDateText, font, XBrushes.Black, new XRect(margin, currentTop, page.Width, page.Height), XStringFormats.TopCenter);
currentTop += lineHeight;
graphics.DrawString("" + report.Description, font, XBrushes.Black, new XRect(margin, page.Height - (lineHeight * 35), page.Width, page.Height), XStringFormats.TopCenter);
currentTop += lineHeight;
graphics.DrawString("Prepared by the DHS National Operations Center", font, XBrushes.Black, new XRect(margin, page.Height - (lineHeight * 4), page.Width, page.Height), XStringFormats.TopCenter);
currentTop += lineHeight;
graphics.DrawString("UNCLASSIFIED/FOR OFFICAL USE ONLY", font, XBrushes.Red, new XRect(margin, page.Height - (lineHeight * 3), page.Width, page.Height), XStringFormats.TopCenter);
return document;
}
}
}
thank you so much