Necesito de su ayuda, ya que he probado varias cosas pero no he logrado solucionar un problema que tengo, tengo una RECIBO que tiene muchos documentos, y cuando sucede esto la tabla que genera el PDF me genera un gran espacio en blanco y comienza en una hoja nueva.
Como en el siguiente ejemplo:
enter image description here
Para llenar la tabla
`PdfPTable tablaGral = new PdfPTable(1);
PdfPTable tablaItems = new PdfPTable(9);
float[] widths2 = new float[] { 90f, 40f, 50f, 50f, 60f, 60f, 60f, 50f, 50f };
tablaItems.SetWidths(widths2);
PdfPCell pdfCellTipoComprobate = AgregarCelda("Tipo Comprobante", FontEncabezados6, 0, Element.ALIGN_CENTER, Element.ALIGN_CENTER, true);
pdfCellTipoComprobate.BorderWidthTop = 0f;
pdfCellTipoComprobate.BorderWidthLeft = 0f;
pdfCellTipoComprobate.BorderWidthBottom = 0.5f;
tablaItems.AddCell(pdfCellTipoComprobate);
tablaItems.AddCell(AgregarCelda("Pto. Venta", FontEncabezados6, 0, Element.ALIGN_CENTER, Element.ALIGN_CENTER, false));
tablaItems.AddCell(AgregarCelda("Nro", FontEncabezados6, 0, Element.ALIGN_CENTER, Element.ALIGN_CENTER, false));
tablaItems.AddCell(AgregarCelda("Fecha", FontEncabezados6, 0, Element.ALIGN_CENTER, Element.ALIGN_CENTER, false));
tablaItems.AddCell(AgregarCelda("Total", FontEncabezados6, 0, Element.ALIGN_CENTER, Element.ALIGN_CENTER, false));
tablaItems.AddCell(AgregarCelda("Monto Aplicado", FontEncabezados6, 0, Element.ALIGN_CENTER, Element.ALIGN_CENTER, false));
tablaItems.AddCell(AgregarCelda("Saldo", FontEncabezados6, 0, Element.ALIGN_CENTER, Element.ALIGN_CENTER, false));
tablaItems.AddCell(AgregarCelda("Moneda", FontEncabezados6, 0, Element.ALIGN_CENTER, Element.ALIGN_CENTER, false));
PdfPCell pdfCellPTotal = AgregarCelda("Cotizacion", FontEncabezados6, 0, Element.ALIGN_CENTER, Element.ALIGN_CENTER, true);
pdfCellPTotal.BorderWidthTop = 0f;
pdfCellPTotal.BorderWidthBottom = 0.5f;
pdfCellPTotal.BorderWidthRight = 0f;
tablaItems.AddCell(pdfCellPTotal);
int contador = 0;
int cantidad = lstReciboFactura.Count;
foreach (ReciboFactura rf in lstReciboFactura)
{
string tipoDocumento = rf.TipoComprobanteNombre;
PdfPCell pdfCellTipoComprobanteValue = AgregarCelda(tipoDocumento, FontDetalle6, 0, Element.ALIGN_LEFT, Element.ALIGN_CENTER, true);
pdfCellTipoComprobanteValue.BorderWidthLeft = 0f;
pdfCellTipoComprobanteValue.BorderWidthRight = 0f;
tablaItems.AddCell(pdfCellTipoComprobanteValue);
string ptoVenta = rf.PtoVenta == 0 ? "" : rf.PtoVenta.ToString("0000");
PdfPCell pdfCellPtoVentaValue = AgregarCelda(ptoVenta, FontDetalle6, 0, Element.ALIGN_CENTER, Element.ALIGN_RIGHT, true);
pdfCellPtoVentaValue.BorderWidthRight = 0f;
tablaItems.AddCell(pdfCellPtoVentaValue);
PdfPCell pdfCellNroValue = AgregarCelda(rf.NroComprobante.ToString("000000000"), FontDetalle6, 0, Element.ALIGN_RIGHT, Element.ALIGN_CENTER, true);
pdfCellNroValue.BorderWidthRight = 0f;
tablaItems.AddCell(pdfCellNroValue);
PdfPCell pdfCellPUnitarionValue = AgregarCelda(rf.FechaStr, FontDetalle6, 0, Element.ALIGN_RIGHT, Element.ALIGN_CENTER, true);
pdfCellPUnitarionValue.BorderWidthRight = 0f;
tablaItems.AddCell(pdfCellPUnitarionValue);
PdfPCell pdfCellPUnitarionGravadoValue = AgregarCelda((rf.Importe).ToString("0,0.00"), FontDetalle6, 0, Element.ALIGN_RIGHT, Element.ALIGN_CENTER, true);
pdfCellPUnitarionGravadoValue.BorderWidthRight = 0f;
tablaItems.AddCell(pdfCellPUnitarionGravadoValue);
PdfPCell pdfCellPUnitarionNoGravadoValue = AgregarCelda(rf.MontoAplicado.ToString("0,0.00"), FontDetalle6, 0, Element.ALIGN_RIGHT, Element.ALIGN_CENTER, true);
pdfCellPUnitarionNoGravadoValue.BorderWidthRight = 0f;
tablaItems.AddCell(pdfCellPUnitarionNoGravadoValue);
PdfPCell pdfCellSaldoFacturaValue = AgregarCelda(rf.SaldoFactura.ToString("0,0.00"), FontDetalle6, 0, Element.ALIGN_RIGHT, Element.ALIGN_CENTER, true);
pdfCellSaldoFacturaValue.BorderWidthRight = 0f;
tablaItems.AddCell(pdfCellSaldoFacturaValue);
PdfPCell pdfCellMonedaValue = AgregarCelda(rf.MonedaStr, FontDetalle6, 0, Element.ALIGN_RIGHT, Element.ALIGN_CENTER, true);
pdfCellMonedaValue.BorderWidthRight = 0f;
tablaItems.AddCell(pdfCellMonedaValue);
string cotizacion = rf.MonedaId == 4 ? "1" : rf.Cotizacion.ToString("0,0.00");
PdfPCell pdfCellCotizacionValue = AgregarCelda(cotizacion, FontDetalle6, 0, Element.ALIGN_RIGHT, Element.ALIGN_CENTER, true);
pdfCellCotizacionValue.BorderWidthRight = 0f;
tablaItems.AddCell(pdfCellCotizacionValue);
contador++;
if (contador == 30 || contador == cantidad) //Se usa para hacer una linea cada 30 comprobantes.
{
PdfPCell celdaTable2 = new PdfPCell(tablaItems);
tablaGral.AddCell(celdaTable2);
//PdfPCell celdaGral2 = new PdfPCell(tablaGral);
//celdaGral2.MinimumHeight = 390f;
//celdaGral.Border = 0;
//table.AddCell(celdaGral2);
//tablaItems.DeleteRow(20);
tablaItems.DeleteBodyRows();
contador = 0;
}
}
PdfPCell celdaGral2 = new PdfPCell(tablaGral);
celdaGral2.MinimumHeight = 300f;// : 440f;
table.AddCell(celdaGral2);
`
Se revisaron varias opciones, pero siempre genera ese espacio en blanco
Ronald Petrussa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.