HTML至PDF,带用户输入.. [英] HTML to PDF with user input ..

查看:56
本文介绍了HTML至PDF,带用户输入..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我真的很累,遇到了从HTML页面生成PDF文件的问题.
any1可以帮助我从HTML页面以及用户输入中生成PDF文件.我的Aspx页面没有表格和单元格,
它具有组合框,文本框和下拉菜单,就像用于输入详细信息的表格一样.我现在有一个代码可以工作,但是它会根据URL生成PDF.而且我的URL不会更改为每个下拉列表选择的值,因此它只是简单地生成初始表单而无需输入.
我已尝试使用所有可能的HTML到PDF的转换,即使itextSharp也无法正常工作,我正在使用WnVhtmltopdf并遇到上述问题.
任何人都可以查看我的代码,并给我一个在用户输入后获取PDF的解决方案,或者向我建议其他转换器和可行的解决方案..

Hey guys,

I am really tired running into problems on generating the PDF file form the HTML page.
Can any1 help me generate a PDF file from the HTML page along with the user input. My Aspx page does not have tables and cells,
It has combo box, text box and dropdowns just like a form used to enter details. I have a code right now working but it jus generates the PDF based on the URL. and my URL does not change for the values selected for each and every dropdowns, so it just simply generates the initial form without the inputs.
I have tried using all the possible HTML to PDF converts and nothing works even itextSharp, nw i am using WnVhtmltopdf and running into the above mentioned issue.
Can anyone look into my code and give me a solution on getting the PDF after the user input or suggest me with someother converter and working solution please..

PdfConverter pdfConverter = new PdfConverter(); 
pdfConverter.PdfDocumentOptions.PdfPageSize = PdfPageSize.A4;
pdfConverter.PdfDocumentOptions.PdfPageOrientation = PDFPageOrientation.Portrait;
pdfConverter.PdfDocumentOptions.PdfCompressionLevel = PdfCompressionLevel.Normal;
pdfConverter.PdfDocumentOptions.GenerateSelectablePdf = true;
pdfConverter.PdfDocumentOptions.ShowFooter = false;
pdfConverter.PdfDocumentOptions.ShowHeader = false;
pdfConverter.LicenseKey = "abcdefghijklmnopqrstuvwxyz";

string a = Request.Url.ToString();
byte[] downloadBytes = pdfConverter.GetPdfFromUrlBytes(a);        
System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
response.Clear();
response.AddHeader("Content-Type", "binary/octet-stream");
response.AddHeader("Content-Disposition","attachment; filename=" + "Rendered.pdf" + "; size=" + downloadBytes.Length.ToString());
response.Flush();
response.BinaryWrite(downloadBytes);
response.Flush();
response.End();



在此先感谢
Aaditya



Thanks in advance
Aaditya

推荐答案

您可以随时尝试虚拟图像打印机驱动程序 [ ^ ]-它是(惊奇的)虚拟打印机-因此您可以将html页面打印为pdf文件.

值得一试-我猜您可能没有其他选择-祝您好运!

问候
埃斯彭·哈林(Espen Harlinn)
You can always try Virtual Image Printer driver[^] - it''s (surprise) a virtual printer - so you can print the html page to a pdf file.

It''s worth a try - as I guess you are running out of other options - good luck!

Regards
Espen Harlinn


对不起,朋友,您尝试使用HTML到PDF的直接转换无法做到.您想要的只能使用PDF表单来完成.现在,我还不知道有任何工具可以将HTML转换为PDF格式,因此您需要编写自己的代码.
Sorry pal, what you trying to can''t be done with straight HTML to PDF conversion. What you want can only be done using PDF forms. Now, I am not aware of any tool that can take HTML and convert to PDF form, you would need to craft your own code to do that.


这篇关于HTML至PDF,带用户输入..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆