Finished initial build of the back page generator. Unable to properly merge the two tables with Pechkin so far.

This commit is contained in:
2017-05-06 01:08:38 -05:00
parent 218d5be4d6
commit 15abab5f50
12 changed files with 958 additions and 645 deletions
@@ -0,0 +1,50 @@
using System;
using System.Drawing.Printing;
using System.IO;
using System.Linq;
using System.Web.UI;
using Pechkin;
namespace AdvertsingProfitControl
{
internal class ReportGenerator
{
public readonly string Version = "1.0.0.0";
public void GeneratePdfReport(DateTime date)
{
var stringWriter = new StringWriter();
var writer = new HtmlTextWriter(stringWriter);
var front = new FrontPageGenerator();
var back = new BackPageGenerator();
front.BuildReportFrontPage(date, ref writer);
back.BuildReportBackPage(date, ref writer);
using (var streamWriter = new StreamWriter("C:\\Users\\Crypto\\Desktop\\Full.html"))
{
streamWriter.WriteLine(stringWriter.ToString());
}
}
public void RenderHtmlCodeToImage(string path, string targetPath)
{
var htmlCode = File.ReadAllLines(path);
var code = htmlCode.Aggregate("", (current, line) => current + "\r\n" + line);
try
{
var pechkin = new SimplePechkin(new GlobalConfig().SetMargins(50,0,0,0).SetPaperSize(PaperKind.A4).SetPaperOrientation(true).SetCopyCount(1));
var pdf = pechkin.Convert(new ObjectConfig().SetZoomFactor(1.25), code);
//var config = new GlobalConfig().SetPaperSize(PaperKind.A4).SetPaperOrientation(true);
//var pdfBuf = new SimplePechkin(config).Convert(code);
using (var fs = new FileStream(targetPath, FileMode.Create, FileAccess.Write))
{
fs.Write(pdf, 0, pdf.Length);
}
}
finally
{
}
}
}
}