|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
PdfPCell text missingHi,
This is my first project using itextsharp and it's been a great tool and very easy to use. Currently I am creating PDF's on the fly based on reports stored in a database. This tool has met all my needs but I've run into one issue while using a PdfPTable. I create the table using the code below (example code is simplified, if it would help to show more code please let me know). The problem is when the info cell is split onto a new page it is missing some text. In the example PDF (example.pdf) you can see text from the sentence "This is the fourth line" is missing. I did notice that if I set PaddingTop and PaddingBottom for all cells to 0 then the issue does not occur. Is there anything wrong with the code I am using or could this be an itextsharp issue with cells split over two pages with rowspan greater than 1 and padding on the top and bottom. Thanks for any help. Steve Public Sub GeneratePDF() Dim pdfDocument As iTextSharp.text.Document Dim writer As iTextSharp.text.pdf.PdfWriter = Nothing Dim pdfFontSize As Integer = 9 Dim pdfFont As New iTextSharp.text.Font(iTextSharp.text.Font.HELVETICA, pdfFontSize) 'Adjust bottom margin depending on footer text pdfDocument = New iTextSharp.text.Document(iTextSharp.text.PageSize.LETTER.Rotate(), 18, 18, 30, 13) Try writer = iTextSharp.text.pdf.PdfWriter.GetInstance(pdfDocument, Response.OutputStream) pdfDocument.AddCreationDate() pdfDocument.Open() Dim pdfTable As New iTextSharp.text.pdf.PdfPTable(3) pdfTable.KeepTogether = True pdfTable.HorizontalAlignment = iTextSharp.text.Table.ALIGN_LEFT 'Set width of table and columns pdfTable.WidthPercentage = 40 pdfTable.SetWidths(New Single() {20, 60, 20}) For i = 0 To 19 Dim infoValue As String = "This is the first line with long text" & vbLf & _ "This is the second line" & vbLf & _ "This is the third line with longer text" & vbLf & _ "This is the fourth line" Dim infoCell As New iTextSharp.text.pdf.PdfPCell(New iTextSharp.text.Phrase(infoValue, pdfFont)) infoCell.Rowspan = 5 infoCell.PaddingTop = 2 infoCell.PaddingRight = 2 infoCell.PaddingBottom = 1 infoCell.PaddingLeft = 2 infoCell.UseAscender = True infoCell.UseBorderPadding = True infoCell.UseDescender = True pdfTable.AddCell(infoCell) For j = 0 To 4 Dim fieldCell As New iTextSharp.text.pdf.PdfPCell(New iTextSharp.text.Phrase("This is a field value", pdfFont)) fieldCell.PaddingTop = 2 fieldCell.PaddingRight = 2 fieldCell.PaddingBottom = 1 fieldCell.PaddingLeft = 2 fieldCell.UseAscender = True fieldCell.UseBorderPadding = True fieldCell.UseDescender = True pdfTable.AddCell(fieldCell) Dim dataCell As New iTextSharp.text.pdf.PdfPCell(New iTextSharp.text.Phrase("1,234", pdfFont)) dataCell.PaddingTop = 2 dataCell.PaddingRight = 2 dataCell.PaddingBottom = 1 dataCell.PaddingLeft = 2 dataCell.UseAscender = True dataCell.UseBorderPadding = True dataCell.UseDescender = True pdfTable.AddCell(dataCell) Next Next pdfDocument.Add(pdfTable) Finally pdfDocument.Close() End Try End Sub |
|
|
Re: PdfPCell text missingWill look into it.
Paulo > -----Original Message----- > From: steve_c22 [mailto:mobettaut@...] > Sent: Wednesday, September 02, 2009 12:22 AM > To: itextsharp-questions@... > Subject: [itextsharp-questions] PdfPCell text missing > > > Hi, > > This is my first project using itextsharp and it's been a > great tool and > very easy to use. Currently I am creating PDF's on the fly > based on reports > stored in a database. This tool has met all my needs but I've > run into one > issue while using a PdfPTable. I create the table using the code below > (example code is simplified, if it would help to show more > code please let > me know). The problem is when the info cell is split onto a > new page it is > missing some text. In the example PDF ( > http://www.nabble.com/file/p25249124/example.pdf example.pdf > ) you can see > text from the sentence "This is the fourth line" is missing. > I did notice > that if I set PaddingTop and PaddingBottom for all cells to 0 > then the issue > does not occur. Is there anything wrong with the code I am > using or could > this be an itextsharp issue with cells split over two pages > with rowspan > greater than 1 and padding on the top and bottom. Thanks for any help. > > Steve > > Public Sub GeneratePDF() > Dim pdfDocument As iTextSharp.text.Document > Dim writer As iTextSharp.text.pdf.PdfWriter = Nothing > Dim pdfFontSize As Integer = 9 > Dim pdfFont As New > iTextSharp.text.Font(iTextSharp.text.Font.HELVETICA, pdfFontSize) > > 'Adjust bottom margin depending on footer text > pdfDocument = New > iTextSharp.text.Document(iTextSharp.text.PageSize.LETTER.Rotat > e(), 18, 18, > 30, 13) > > Try > writer = > iTextSharp.text.pdf.PdfWriter.GetInstance(pdfDocument, > Response.OutputStream) > pdfDocument.AddCreationDate() > pdfDocument.Open() > Dim pdfTable As New iTextSharp.text.pdf.PdfPTable(3) > pdfTable.KeepTogether = True > pdfTable.HorizontalAlignment = > iTextSharp.text.Table.ALIGN_LEFT > > 'Set width of table and columns > pdfTable.WidthPercentage = 40 > pdfTable.SetWidths(New Single() {20, 60, 20}) > > For i = 0 To 19 > Dim infoValue As String = "This is the first > line with long > text" & vbLf & _ > "This is the second line" & vbLf & _ > "This is the third line with longer text" & vbLf & _ > "This is the fourth line" > Dim infoCell As New iTextSharp.text.pdf.PdfPCell(New > iTextSharp.text.Phrase(infoValue, pdfFont)) > infoCell.Rowspan = 5 > infoCell.PaddingTop = 2 > infoCell.PaddingRight = 2 > infoCell.PaddingBottom = 1 > infoCell.PaddingLeft = 2 > infoCell.UseAscender = True > infoCell.UseBorderPadding = True > infoCell.UseDescender = True > pdfTable.AddCell(infoCell) > > For j = 0 To 4 > Dim fieldCell As New > iTextSharp.text.pdf.PdfPCell(New > iTextSharp.text.Phrase("This is a field value", pdfFont)) > fieldCell.PaddingTop = 2 > fieldCell.PaddingRight = 2 > fieldCell.PaddingBottom = 1 > fieldCell.PaddingLeft = 2 > fieldCell.UseAscender = True > fieldCell.UseBorderPadding = True > fieldCell.UseDescender = True > pdfTable.AddCell(fieldCell) > > Dim dataCell As New > iTextSharp.text.pdf.PdfPCell(New > iTextSharp.text.Phrase("1,234", pdfFont)) > dataCell.PaddingTop = 2 > dataCell.PaddingRight = 2 > dataCell.PaddingBottom = 1 > dataCell.PaddingLeft = 2 > dataCell.UseAscender = True > dataCell.UseBorderPadding = True > dataCell.UseDescender = True > pdfTable.AddCell(dataCell) > Next > Next > pdfDocument.Add(pdfTable) > Finally > pdfDocument.Close() > End Try > End Sub Aviso Legal: Esta mensagem é destinada exclusivamente ao destinatário. Pode conter informação confidencial ou legalmente protegida. A incorrecta transmissão desta mensagem não significa a perca de confidencialidade. Se esta mensagem for recebida por engano, por favor envie-a de volta para o remetente e apague-a do seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de usar, revelar ou distribuir qualquer parte desta mensagem. Disclaimer: This message is destined exclusively to the intended receiver. It may contain confidential or legally protected information. The incorrect transmission of this message does not mean the loss of its confidentiality. If this message is received by mistake, please send it back to the sender and delete it from your system immediately. It is forbidden to any person who is not the intended receiver to use, distribute or copy any part of this message. ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ itextsharp-questions mailing list itextsharp-questions@... https://lists.sourceforge.net/lists/listinfo/itextsharp-questions |
| Free embeddable forum powered by Nabble | Forum Help |