使用phantomJS生成横向PDF

时间:2017-03-27 08:34:16

标签: 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))
    {
        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'

但这不起作用。

0 个答案:

没有答案
相关问题