Created
October 2, 2012 16:27
-
-
Save manuelnelson/3820718 to your computer and use it in GitHub Desktop.
Pechkin PDF Print form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public JsonResult PrintForm(string html) | |
{ | |
try | |
{ | |
var contentPath = Server.MapPath("~/Content/"); | |
var css = System.IO.File.ReadAllText(Path.Combine(contentPath + "bootstrap.css")); | |
var fullHtml = string.Format(@"<!DOCTYPE html> <html> <head><style type='text/css'> {0} </style></head><body> {1} </body></html>",css, html); | |
var config = new ObjectConfig(); | |
config.SetAllowLocalContent(true); | |
//config.SetUserStylesheetUri("bootstrap.css"); | |
var pdfBuf = _synchronizedPechkin.Convert(config, fullHtml); | |
contentPath = Path.Combine(contentPath, "Pdfs/newPdf.pdf"); | |
System.IO.File.WriteAllBytes(contentPath, pdfBuf); | |
return Json("success"); | |
} | |
catch (Exception ex) | |
{ | |
return Json("unable to make pdf"); | |
} | |
} |
Hi, Di you manage to add your CSS? I have the same problem
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
do you know by any chance how to include images??
I have used both Url.Content and Server.MapPath, both doesnt work .. how do i reference path..?