C# 使用phantomJS生成横向PDF
我正在asp.net应用程序中使用phantomjs将html转换为PDF 首先,我使用这个c代码生成一个html页面C# 使用phantomJS生成横向PDF,c#,asp.net,phantomjs,C#,Asp.net,Phantomjs,我正在asp.net应用程序中使用phantomjs将html转换为PDF 首先,我使用这个c代码生成一个html页面 using (FileStream fs = new FileStream(HttpContext.Current.Server.MapPath("~/Phantomjs/" + HTMLfileName), FileMode.Create)) { using (StreamWriter sw = new StreamWriter(fs)) {
using (FileStream fs = new FileStream(HttpContext.Current.Server.MapPath("~/Phantomjs/" + HTMLfileName), FileMode.Create))
{
using (StreamWriter sw = new StreamWriter(fs))
{
sw.Write(GiveBodyText);
}
}
然后我使用幻影命令执行了这段代码
ExecuteCommand(string.Format("cd {0} & phantomjs rasterize.js {1} {2} \"A4\"", serverPath, HTMLfileName, filename));
但主要问题是我希望PDF是横向的,默认情况下PDF是纵向的,为了改变这一点,我尝试在rasterize.js中编辑以下属性:
page.viewportSize = { width: 1000, height: 600 };
Orientation: 'landscape'
但这是行不通的