我如何在服务器上创建pdf文件? [英] how i can create a pdf file on server?

查看:122
本文介绍了我如何在服务器上创建pdf文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请告诉我
请帮助我如何在我从中购买域名的服务器上创建pdf文件,请帮助我使用itext对象,该文件在我的本地主机上无法正常工作,在go daddy域上不起作用,请帮助我

please tell me
please help me how i can create a pdf on the server from where i purchase a domain please help me i use itext object it work on my local-host not work on go daddy domain please help me

推荐答案

在按钮单击上使用此代码肯定会起作用

use this code on button click definatly it will work

Response.ContentType = "application/pdf";
            Response.AddHeader("content-disposition", "attachment;filename=Export.pdf");
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            StringWriter sw = new StringWriter();
            HtmlTextWriter hw = new HtmlTextWriter(sw);
            HtmlForm frm = new HtmlForm();
            grdMissingBarcode.Parent.Controls.Add(frm);
            frm.Controls.Add(grdMissingBarcode);
            frm.RenderControl(hw);
            StringReader sr = new StringReader(sw.ToString());
            Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
            HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
            PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
            pdfDoc.Open();
            pdfDoc.NewPage();
            htmlparser.Parse(sr);
            pdfDoc.Close();
            Response.Write(pdfDoc);
            Response.End();


您需要与托管公司联系,以确定您的应用程序是否有权在此处创建文件.确保足够安全,可以将这些PDF文件保留在第三方硬件上.
You need to check with the hosting company if your application has access to create the files there. Make sure it is secure enough to leave those PDF files on third party hardware.


这篇关于我如何在服务器上创建pdf文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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