C# 如何用c实现“打印媒体类型”?

C# 如何用c实现“打印媒体类型”?,c#,asp.net,pdf-generation,wkhtmltopdf,C#,Asp.net,Pdf Generation,Wkhtmltopdf,我目前正在使用wkhtmltopdf和c以PDF格式下载我的网页。但是,我希望生成的PDF显示为使用print.css 其他详情: 我正在使用microsoft visual studio 2010 这是我的代码: protected void ImageButton2_Click(object sender, ImageClickEventArgs e) { string args = string.Format("\"{0}\" - ", Request.Url.AbsoluteUr

我目前正在使用wkhtmltopdf和c以PDF格式下载我的网页。但是,我希望生成的PDF显示为使用print.css

其他详情: 我正在使用microsoft visual studio 2010

这是我的代码:

protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
{
    string args = string.Format("\"{0}\" - ", Request.Url.AbsoluteUri);
    var startInfo = new ProcessStartInfo(Server.MapPath("~/wkhtmltoPDF/") + "wkhtmltopdf.exe", args)
    {
        UseShellExecute = false,
        RedirectStandardOutput = true
    };

    var proc = new Process { StartInfo = startInfo };
    proc.Start();

    Response.AddHeader("Content-Disposition", string.Format("attachment;filename=StaffDetails.pdf", Guid.NewGuid()));
    Response.AddHeader("Content-Type", "application/pdf"); string output = proc.StandardOutput.ReadToEnd();
    byte[] buffer = proc.StandardOutput.CurrentEncoding.GetBytes(output);
    proc.Close();
    Response.BinaryWrite(buffer);
    }
}

只需将其添加为参数。试试像这样的东西

string args = string.Format("--print-media-type \"{0}\" - ", Request.Url.AbsoluteUri);