ASP,ItextSharp和图像以及Gidview和数据库 [英] ASP, ItextSharp and Images and Gidview and Database

查看:77
本文介绍了ASP,ItextSharp和图像以及Gidview和数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从事一个项目,该项目的主要目标是生成要作为电子邮件附件生成和发送的PDF.

用户登录/注册...,然后随机回答一组问题,然后提交答案.
此后,用户将被重定向到一个asp页面,该页面具有他们提交的结果.
我可以通过 Gridview 将结果打印到 pdf 中,即可以将 grid view 数据呈现为 pdf 带有 itextsharp 的文档,但 pdf 必须在特定位置具有图片,并且与此同时,此 pdf doc不应打开或提示下载,但应发送到已登录用户的电子邮件地址?请在 VB或C#
中提供帮助
到目前为止,我有将 gridview 呈现的数据写入PDF的代码,但网页上的图像除外.

NB -网格视图中没有图像.

I''m working on a project, the main goal of which is to generate a PDF to be generated and sent as an Email attachment.

A User Logs in/Registers..., then answers a set random of questions, and submits the answers.
The user is redirected to an asp page after this, which has the results as they have submitted.
Thing is I can print the Results into a pdf through the Gridview i.e.I can render the grid view data into a pdf doc with itextsharp, but the pdf is required to have images on certain positions, and at the same time, this pdf doc should not open or prompt for download, but should be sent to an email address of the user logged in?? Please help in VB or C#

SO far I have code that writes data rendered from the gridview into the PDF, but except images on the web page.

N.B- no images appear inside a gridview.

推荐答案

有关使用图像和iTextSharp的文章:
这是关于使用C#将图像放置在pdf中的特定位置.

但是您无法使用Google找到它吗?

http://www.mikesdotnetting.com/Article/87/iTextSharp-Working-with-images [ ^ ]

关于您遇到的另一个问题:此pdf doc不应打开或提示下载,而应发送到已登录用户的电子邮件地址;我展示了几个示例,您的任务是从中挑选合适的片段以使其正常工作.

-发送电子邮件-

C#中的简单SMTP电子邮件发件人...控制台应用程序 [ http://msdn.microsoft.com/en-us/library/system. net.mail.smtpclient.aspx [ ^ ]

-用pdf发送电子邮件-

http://msdn.microsoft.com/en-us/library/system. net.mail.attachment.aspx [ ^ ]

还有这里

An article about working with images and iTextSharp:
It''s about putting images at certain positions in a pdf with C#.

But couldn''t you have found it using Google?

http://www.mikesdotnetting.com/Article/87/iTextSharp-Working-with-images[^]

About the other question you had: this pdf doc should not open or prompt for download, but should be sent to an email address of the user logged in; I show a couple of examples, your task is to pick the right pieces out of it to get it working.

-- Sending Email --

Simple SMTP E-Mail Sender in C#… Console application[^]

the SmtpClient is in the System.Net.Mail namespace.

An example can be found here:

http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient.aspx[^]

-- Sending Email with pdf --

http://msdn.microsoft.com/en-us/library/system.net.mail.attachment.aspx[^]

and here

MailAddress from = new MailAddress(froma); 
MailAddress to = new MailAddress(email); 
MailMessage message = new MailMessage(from,to); 
SmtpClient client = new SmtpClient(); 
           
message.Subject = this.txtSubject.Text; 
               
message.IsBodyHtml = true; 
string attachmentPath = pdffile; 
System.Net.Mail.Attachment inline = new System.Net.Mail.Attachment(attachmentPath, MediaTypeNames.Application.Pdf); 
inline.ContentDisposition.Inline = true; 
inline.ContentDisposition.DispositionType = DispositionTypeNames.Inline; 
inline.ContentType.MediaType = MediaTypeNames.Application.Pdf; 
inline.ContentType.Name = Path.GetFileName(attachmentPath); 
message.Attachments.Add(inline); 
  
client.Host = Session["smtp"].ToString(); 
client.Port = Convert.ToInt32(Session["port"].ToString()); 
client.Send(message); 


您好.
最近,我开发了一个生成PDf的Web服务
第一步是使用图形类加载png格式的图像.然后在png上写入datagridview数据.然后使用itextsharp加载图像(字节)并以pdf格式保存.
这种方法非常好,因为使用JavaScript字段的结果小于pdf
到目前为止,我只告诉您如何执行您的项目
来自墨西哥的问候
Hello .
Recently i develop a web service that generate a PDf
the first step is to load an image in png format with graphics class . then write the datagridview data over the png . and then load with itextsharp the image (bytes) and save in pdf format .
This way is very very good cause the result is smaller than pdf with javascript fields
So far i only tell you how you can perform your project
regards from.mexico


这篇关于ASP,ItextSharp和图像以及Gidview和数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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