Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用phantomJS生成横向PDF_C#_Asp.net_Phantomjs - Fatal编程技术网

C# 使用phantomJS生成横向PDF

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)) {

我正在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))
    {
        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'
但这是行不通的