My problem is that "itext rectangle" doesn’t appear when I’m reading in Adobe
Reader 8.0 but appear when reading in Ghost View!
This is the code...
'DOC***************************************************************************************
' CLASSE: GeneratePDF
' DESCRIÇÃO: Classe de interface para geração de relatórios simples, detalhados
e etiquetas
' CRIADA EM: 12/2007 - Rui Duarte|RDA
' ALTERADA EM:
'******************************************************************************************
Imports System
Imports System.IO
Imports iTextSharp.text
Imports iTextSharp.text.pdf
Imports epikMR.data
Imports epikMR.Common
Imports epikMR.Common.General
Public Class GeneratePDF
#Region "vars"
' Constantes
Const SRP As String = "SRP:"
Const DeliveryNumber As String = "Cliente Expedidor:"
Const YearOrderNum As String = "Ano/Num Ordem Guia"
Const Address As String = "Morada:"
Const ExpDate As String = "Data de Expedição:"
Const Quantity As String = "Quantidade de Registos:"
Const Client As String = "Cliente"
Const _Date As String = "Data"
Const Heading As String = "Rubrica"
Const EC As String = "EC aceitante"
Const ExpGuide As String = "Guia de Expedição de Registos Nº:"
Const Powered As String = "Powered by "
Const EpikPRO As String = "epikPRO™ ©"
Const DSTS As String = "DSTS, 2003"
Const marginsdefault As Single = 12.24
Const marginleft As Single = 0.0
Const marginright As Single = 70.583
Const margintop As Single = 0.0
Const marginbutton As Single = 70.583
' Variaveis Privadas da classe
Private UtilsPath As String
Private FontPath As String
Private PDFPathDel As String
Private PDFPathDelPag As String
' Documento
Private doc As Document
' BaseFontes
Private bfTimesBold As BaseFont
Private bfTimesNormal As BaseFont
Private bfArialBold As BaseFont
Private bfArialNormal As BaseFont
Private bfArialBoldItalic As BaseFont
Private bfCTTcodBar39n As BaseFont
' Fontes
Private FTimesNormal As Font
Private FTimesBold As Font
Private FCTTcodBar39n As Font
Private FArialNomal As Font
' Paragrafos
Private PSpace As Paragraph
Private PLots As Paragraph
Private PNumUsage As Paragraph
Private PHeadLots As Paragraph
Private PClientName As Paragraph
'Imagens
Private CTTImage As Image
Private Circulo As Image
' Obecto para guardar conteúdos(texto e graficos) da Pagina
Private cb As PdfContentByte
' Tabela
Private tblLot As PdfPTable
Private tblPostalObj As PdfPTable
' Celulas para as tabelas
Private CellHeadLot As PdfPCell
Private CellHeadPostalObj As PdfPCell
Private CellPostalCode As PdfPCell
Private CellAddress As PdfPCell
Private CellNumRegis As PdfPCell
Private CellName As PdfPCell
Private CellNumSeq As PdfPCell
Private CellAux As PdfPCell
Private CellAux1 As PdfPCell
Private widths As Integer() = {290, 141, 72}
Private widths1 As Integer() = {1000000000, 1, 1}
#End Region
#Region "New"
Public Sub New()
' Paths
UtilsPath = System.Web.HttpContext.Current.Server.MapPath("bin\utils\")
FontPath =
IO.Path.Combine(Environment.GetEnvironmentVariable("windir"), "Fonts")
PDFPathDel = IO.Path.Combine(IO.Path.GetTempPath, "TmpDel.pdf")
PDFPathDelPag = IO.Path.Combine(IO.Path.GetTempPath, "TmpDelPag.pdf")
CTTImage = Image.GetInstance(IO.Path.Combine(UtilsPath,
RptDelivery.CTTImage)) ' Imagem CTT
Circulo = Image.GetInstance(IO.Path.Combine(UtilsPath, "Circulo.bmp"))
' Imagem Circulo
bfTimesBold = BaseFont.CreateFont(IO.Path.Combine(FontPath, TimesBold),
BaseFont.CP1252, BaseFont.EMBEDDED)
bfTimesNormal = BaseFont.CreateFont(IO.Path.Combine(FontPath,
TimesNormal), BaseFont.CP1252, BaseFont.EMBEDDED)
bfArialBold = BaseFont.CreateFont(IO.Path.Combine(FontPath, ArialBold),
BaseFont.CP1252, BaseFont.EMBEDDED)
bfArialNormal = BaseFont.CreateFont(IO.Path.Combine(FontPath,
ArialNormal), BaseFont.CP1252, BaseFont.EMBEDDED)
bfArialBoldItalic = BaseFont.CreateFont(IO.Path.Combine(FontPath,
ArialBoldItalic), BaseFont.CP1252, BaseFont.EMBEDDED)
bfCTTcodBar39n = BaseFont.CreateFont(IO.Path.Combine(FontPath,
CTTcodBar39n), BaseFont.CP1252, BaseFont.EMBEDDED)
End Sub
#End Region
....
#Region "CreateLabels"
Public Function CreateLabels(ByVal NumBarCodeColecction As
NumBarCodeColecction, _
ByVal RptLabels As RptLabels)
Dim writer As PdfWriter
Dim aux As Integer
Dim aux1 As Integer
Dim aux2 As Integer
Dim RegistNum As String
Dim PostalObjNum As String
Dim ARegist As New ArrayList
Dim APostalObj As New ArrayList
Dim i As Integer
Dim cb1 As PdfContentByte
Dim pageSizeLabels As Rectangle = New Rectangle(0, 0, 594.72, 840.72)
'Cria um documento pdf com as medidas PageSize
doc = New Document(pageSizeLabels)
Try
' Instancia o ficheiro
writer = PdfWriter.GetInstance(doc, New FileStream(PDFPathDel,
FileMode.Create))
' Abre o documento
doc.Open()
cb1 = writer.DirectContent
For Each NumBarCode As data.NumBarCode In NumBarCodeColecction
RegistNum = NumBarCode.RegistNumber
RegistNum = RegistNum.Remove(0, 1)
RegistNum = RegistNum.Remove(RegistNum.Length - 1, 1)
ARegist.Add(RegistNum)
PostalObjNum = NumBarCode.PostalObjectSequence
APostalObj.Add(PostalObjNum)
Next
cb1.BeginText()
' Font e Tamanho|Alinhamento e Posição absuluta do texto
cb1.SetFontAndSize(bfTimesBold, 8.75)
cb1.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "Lote:" & Space(4) &
RptLabels.Lot, 70, 802, 0)
For i = 0 To ARegist.Count - 1
If Not i = 0 Then
i = i - 1
End If
For aux2 = 1 To 2
For aux1 = 1 To 11
If i <= ARegist.Count - 1 Then
cb1.SetColorFill(iTextSharp.text.Color.BLACK)
cb1.SetFontAndSize(bfCTTcodBar39n, 31.5)
cb1.ShowTextAligned(PdfContentByte.ALIGN_RIGHT,
"%", (aux2 * 226) - 110.6, 805 - (aux1 * 71), 0)
cb1.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "*"
& ARegist(i) & "*", (aux2 * 226) - 94, 805.5 - (aux1 * 71), 0)
' Caixas em branco
cb1.SetColorFill(iTextSharp.text.Color.WHITE)
cb1.Rectangle(-160, -7, 162, 15)
cb1.Fill()
cb1.SetColorFill(iTextSharp.text.Color.BLACK)
cb1.SetFontAndSize(bfArialNormal, 8.25)
cb1.ShowTextAligned(PdfContentByte.ALIGN_RIGHT,
ARegist(i), (aux2 * 226) + 15, 800 - (aux1 * 71), 0)
cb1.SetFontAndSize(bfTimesBold, 7.25)
cb1.ShowTextAligned(PdfContentByte.ALIGN_RIGHT,
APostalObj(i), (aux2 * 226) - 115, 796 - (aux1 * 71), 0)
End If
If i < ARegist.Count Then
i = i + 1
End If
Next
Next
If i <= ARegist.Count - 1 Then
cb1.EndText()
doc.NewPage()
cb1.BeginText()
cb1.SetFontAndSize(bfTimesBold, 8.75)
cb1.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "Lote:" &
Space(4) & RptLabels.Lot, 70, 802, 0)
End If
Next
cb1.EndText()
' Fecha o documento
doc.Close()
' Fecha a instancia
writer.Close()
Return SerializeFile(PDFPathDel)
'exceptions
Catch ex As Exception
Throw New Exception("Error creation Delivery File", ex)
Finally
doc.Close()
writer.Close()
End Try
End Function
#End Region
#Region "DeSerializeFile"
Public Function DeSerializeFile(ByVal strFilePath As String) As Byte()
Dim fsFileStream As IO.FileStream
Dim brFileReader As IO.BinaryReader
fsFileStream = IO.File.Open(strFilePath, IO.FileMode.Open,
IO.FileAccess.Read, IO.FileShare.None)
brFileReader = New IO.BinaryReader(fsFileStream)
Dim btFileByteArray(fsFileStream.Length() - 1) As Byte
brFileReader.Read(btFileByteArray, 0, fsFileStream.Length())
'Fecho e remoção do ficheiro
brFileReader.Close()
fsFileStream.Close()
' Apaga ficheiros temporário
IO.File.Delete(PDFPathDel)
IO.File.Delete(PDFPathDelPag)
Return btFileByteArray
End Function
#End Region
End Class
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/