Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/274.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#Windows服务>;呈现网页并输出为PDF_C#_Service_Pdf Generation_Printing Web Page - Fatal编程技术网

C#Windows服务>;呈现网页并输出为PDF

C#Windows服务>;呈现网页并输出为PDF,c#,service,pdf-generation,printing-web-page,C#,Service,Pdf Generation,Printing Web Page,我不知所措,需要一些指导。我有一个对客户执行审计的windows服务。对于新客户,我需要为每个客户创建一个配置文件。我已经有了一个ASP.net C#网页,可以为用户显示单个客户配置文件: http://webserver/showprofile.aspx?id=CustomerID 我想在服务中运行某种类型的循环,以呈现每个新客户的配置文件,并将所有这些配置文件输出为PDF、Word文档等。是否有一种简单的方法使用现有的Show profile网页来实现这一点 如果没有,在C#中实现这一点的

我不知所措,需要一些指导。我有一个对客户执行审计的windows服务。对于新客户,我需要为每个客户创建一个配置文件。我已经有了一个ASP.net C#网页,可以为用户显示单个客户配置文件:

http://webserver/showprofile.aspx?id=CustomerID
我想在服务中运行某种类型的循环,以呈现每个新客户的配置文件,并将所有这些配置文件输出为PDF、Word文档等。是否有一种简单的方法使用现有的Show profile网页来实现这一点

如果没有,在C#中实现这一点的最佳方法是什么?如果它需要一个组件,我更喜欢免费的,而不是非常便宜的。我目前拥有Telerik全系列工具的许可证,如果有什么可以帮助的话。底线是,这必须以编程方式完成,因为用户将与生成/导出为PDF无关。他们将只访问最终导出的文件


提前感谢您的帮助。

您可以使用以下命令使用PdfCreator:

private PDFCreator.clsPDFCreator printer;
printer = new PDFCreator.clsPDFCreator();
printer.cDefaultPrinter = "PDFCreator";

printer.cOptions.UseAutosave = 0;

// Format in which file is to be saved. 0 if for pdf.
printer.cOptions.AutosaveFormat = 0;
printer.cClearCache();

printer.cStart();  
foreach(int CustomerId in CustomerIDs)//array of customer ids as an example
 {
printer.cPrintURL("http://webserver/showprofile.aspx?id=" + CustomerID.ToString());
 }
您可以通过以下链接下载软件和必要的dll,并查看.net文件夹中的示例


搜索“HTML到PDF”:我遇到了类似的问题,在我的一个项目中使用了ABCpdf。它真的很容易使用,但它不是免费的。你仍然可以免费试用30天,所以你可能想看看。我已经想到我必须得到某种html到pdf的组件。我的主要问题是如何呈现网页并转储html格式?类似于foreach(customerList中的var client){htmlOutput=htmlOutput+来自每个HTML呈现的转储}我最终使用ABCPDF解决了这个问题。我会给你一个答案,虽然我在这一点上不满意。