Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET VB10.0 Gridview PDF , +
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.
Posted 30-Jul-12 8:35am
v3
Comments
Tadit Dash at 30-Jul-12 16:12pm
   
You need to add codes so that we can modify.
Please click on "Improve question" link and post your codes.
Thanks...
woutercx at 30-Jul-12 18:44pm
   
I don't understand the sentence "SO far I have code that writes data rendered from the gridview into the PDF, but except images on the web page."
What do you mean bu "but except images on the web page"?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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); 
  Permalink  
v6
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Kornfeld Eliyahu Peter 265
1 Sergey Alexandrovich Kryukov 202
2 George Jonsson 185
3 King Fisher 185
4 CPallini 155
0 OriginalGriff 6,223
1 DamithSL 4,724
2 Maciej Los 4,196
3 Kornfeld Eliyahu Peter 3,894
4 Sergey Alexandrovich Kryukov 3,496


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 31 Jul 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100