Visual Basic.NET - Problema con iTextSharp, al generar pdf

 
Vista:

Problema con iTextSharp, al generar pdf

Publicado por 3rick (1 intervención) el 31/08/2012 00:55:17
Buenas, tengo un code que envia un correo electronico mediante outlook, jalando la variable de Mail To del lable, que asu vez la extraigo de un .txt, hasta ahi todo bien, me envia los correos y todo, pero quiero generar un reporte en pdf con datos de una bd en SQL, descargue el iTextsharp, pero no me doy ..perdon por la palabra..ni p*ta idea de como hacerlo xD


aqui esta mi codigo del correo, ojala alguien me ayude con un ejemplo del itextsharp, que si bien encuentro muchos ninguno me ah servido.....


Imports Microsoft.Office.Interop
Imports Microsoft.Office.Interop.Outlook
Imports System
Imports System.IO
Public Class Form1
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Dim adDate As DateTime = DateTime.Now
Dim aDate As String = adDate.ToString("MM/dd/yyyy")
Dim lineas() As String = File.ReadAllLines("C:\Users\Training\Desktop\DoppControl\TestFile.txt")
'Reading the data from the .txt
For Each linea As String In lineas
Label1.Text = linea
Next
If aDate = adDate.ToString("MM/01/yyyy") Then
'if Current date = Condition Date then do this
Dim m_OutLook As Application
Dim objMail As Outlook.MailItem
'Creating the mail Obj/Send Params/Destroy the Obj
m_OutLook = New Outlook.Application
objMail = CType(m_OutLook.CreateItem(Outlook.OlItemType.olMailItem), MailItem)
'Set the Mail2 the data from teh .txt
objMail.To = Label1.ToString
objMail.Subject = "Report From Dopping Control For This Month"
objMail.Body = "Testing (:"
objMail.Send()
'Testing Messege
'MessageBox.Show("Envìo exitoso.", "Enviar Mail", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
m_OutLook = Nothing
End
End If
'Testing Messege
'MessageBox.Show("lol")
End
End Sub
End Class

Pensandolo bien aqui tengo este codigo simple de Hello world, pero quieo saber como hacerle para guardarlo osea como le puedo hacer para que se guarde en un lugar donde lo pueda tomar como attachment del mail del codigo de arriba, aqui esta el codigo que hasta ahorita es el unico que me ah funcionado:



Dim WorkingFolder = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)

''//The file that we are creating
Dim WorkingFile = Path.Combine(WorkingFolder, "Output.pdf")

''//Create our file with an exclusive writer lock
Using FS As New FileStream(WorkingFile, FileMode.Create, FileAccess.Write, FileShare.None)
''//Create our PDF document
Using Doc As New Document(PageSize.LETTER)
''//Bind our PDF object to the physical file using a PdfWriter
Using Writer = PdfWriter.GetInstance(Doc, FS)
''//Open our document for writing
Doc.Open()

''//Insert a blank page
Doc.NewPage()

''//Add a simple paragraph with text
Doc.Add(New Paragraph("Hello World"))

''//Close our document
Doc.Close()
End Using
End Using
End Using



Perdon si es muy confuso pero realmente necesito su apoyo como siempre amigos, aqui es donde resuelvo todas mis dudas, de antemano se les agradece su lectura (:
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder