-2
Hello would like a help please regarding a problem I’m having to insert an image into my console application project. I can only use the absolute path when sending the project the client will have to change how I do not need to happen?
Private Function cabecalhoPolicardPDF() As PdfPTable
Try
Dim img = iTextSharp.text.Image.GetInstance("G:\projetolimpo\up_sgp-master\RotinaRelacaoLimiteComplementar\img\logo-sombra.jpg")
Dim table = New PdfPTable(2)
table.HorizontalAlignment = Element.ALIGN_LEFT
table.TotalWidth = 500
Dim widths() As Integer = {190, 310}
table.SetWidths(widths)
Dim cell As New PdfPCell(img)
cell.Border = 0
cell.HorizontalAlignment = Element.ALIGN_RIGHT
cell.VerticalAlignment = Element.ALIGN_MIDDLE
Dim cell2 As New PdfPCell()
Dim VerdanaCab As iTextSharp.text.Font = FontFactory.GetFont("Verdana", 13, iTextSharp.text.Font.BOLD)
VerdanaCab.SetColor(245, 145, 0)
Dim Verdana As iTextSharp.text.Font = FontFactory.GetFont("Verdana", 9, iTextSharp.text.Font.BOLD)
Dim VerdanaN As iTextSharp.text.Font = FontFactory.GetFont("Verdana", 9, iTextSharp.text.Font.NORMAL)
Dim p0 As New Phrase()
Dim c1 As New Chunk("SISTEMA UP BRASIL" & Environment.NewLine & Environment.NewLine, VerdanaCab)
p0.Add(c1)
p0.Leading = 50
cell2.AddElement(p0)
cell2.SetLeading(0.0F, 0.0F)
c1 = New Chunk("Razão Social: ", Verdana)
Dim c2 As New Chunk("Policard Systems e Serviços S/A" & Environment.NewLine, VerdanaN)
Dim p1 As New Phrase()
p1.Leading = 10
p1.Add(c1)
p1.Add(c2)
cell2.AddElement(p1)
cell2.Border = 0
cell2.HorizontalAlignment = Element.ALIGN_LEFT
table.AddCell(cell2)
table.AddCell(cell)
table.HorizontalAlignment = Element.ALIGN_LEFT
Return table
Catch ex As Exception
Throw ex
End Try
End Function
Include your actual code and not a screen print... Will the file be in the same structure as the executable? will use some environment variable? save to.Settings app or some config file?
– Leandro Angelo
Hello Leandro, sure I’ll put the code, well yes it will be in the same structure, it will work so I will have a console application that used these methods to create a PDF and need in the pdf have this logo.
– Rodrigo de Souza silva