Blackvelvet Posted March 29, 2012 Report Share Posted March 29, 2012 Boas a todos. Parece que consegui um codigo para criar um pdf e colocar na bd tambem. O problema é que não me reconhece o "Cell " e o "Table". É um exemplo que segui num forum espanhol. Se me puderem ajudar, agradecia. A seguir o codigo onde dá o erro Dim oDoc As New Document(PageSize.LETTER, 0, 0, 0, 0) Dim pdfw As PdfWriter Dim cb As PdfContentByte 'Dim fonte As iTextSharp.text.pdf.BaseFont 'Dim pdfw As iTextSharp.text.pdf.PdfWriter 'Dim fonte As BaseFont Dim NomeArquivo As String = "C:\Comentario.pdf" Dim Conexion As New Data.SqlClient.SqlConnection("Data Source=(local)\SQLEXPRESS; " & "Initial Catalog=basededatos; " & "Integrated Security=true") Dim Comando As New Data.SqlClient.SqlCommand("", Conexion) 'Dim fonte As iTextSharp.text.pdf.BaseFont Dim leer As Data.SqlClient.SqlDataReader Try pdfw = PdfWriter.GetInstance(oDoc, New FileStream(NomeArquivo, FileMode.Create, FileAccess.Write, FileShare.None)) Dim oTabela As New Table(5, 5) oDoc.Open() Dim cell1 As New Cell("Fornecedor") Dim cell2 As New Cell(" Factura") cell1.GrayFill = 0.5F cell2.GrayFill = 0.5F oTabela.AddCell(cell1) oTabela.AddCell(cell2) Conexion.Open() Comando.CommandText = "SELECT * from teste" leer = Comando.ExecuteReader While leer.Read() oTabela.AddCell(leer.GetString(0)) oTabela.AddCell(leer.GetString(1)) End While Conexion.Close() oTabela.Cellpadding = 2 oDoc.Add(oTabela) oDoc.Close() Catch ex As Exception If File.Exists(NomeArquivo) Then If oDoc.IsOpen Then oDoc.Close() File.Delete(NomeArquivo) End If Throw New Exception("Erro ao gerar archivo PDF (" & ex.Message & ")") Finally cb = Nothing pdfw = Nothing oDoc = Nothing End Try End Sub Link to comment Share on other sites More sharing options...
Blackvelvet Posted April 2, 2012 Author Report Share Posted April 2, 2012 Viva pessoal, Ainda ando á volta disto para criar uma factura em pdf com o itextsharp...... ja começo a ficar fo**** ? Já não sei o que fazer...Quero acabar a porra da aplicação e entregar para depois decidirem a nota do estagio. Eu conto com a vossa ajuda, pessoal. Um abraço a todos Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now