Torna al Thread
var document = new Document(PageSize.A4, 50, 50, 25, 25);
var output = new MemoryStream();
var writer = PdfWriter.GetInstance(document, output);
document.Open();
BaseColor testoChiaro = new BaseColor(128,128,128);
BaseColor testoScuro = new BaseColor(77,77,77);
BaseColor contornoCelle = new BaseColor(153, 153, 153);
BaseColor coloreCelle = new BaseColor(242, 242, 242);
document.Add(new Paragraph(""));
PdfPCell cellavuota = new PdfPCell(new Phrase(" "));
cellavuota.FixedHeight = 30;
cellavuota.UseVariableBorders = true;
cellavuota.BorderColorLeft = contornoCelle;
cellavuota.BorderColorRight = contornoCelle;
cellavuota.BorderWidthBottom = 0;
cellavuota.BorderWidthTop = 0;
PdfPCell cellavuota0 = new PdfPCell(new Phrase(" "));
cellavuota0.FixedHeight = 30;
cellavuota0.UseVariableBorders = true;
cellavuota0.BorderWidthBottom = 0;
cellavuota0.BorderWidthTop = 0;
cellavuota0.BorderWidthLeft = 0;
cellavuota0.BorderWidthRight = 0;
PdfPTable tabDatiAziendali = new PdfPTable(new float[] { 492 });
tabDatiAziendali.TotalWidth = 492;//500 massima lunghezza
tabDatiAziendali.LockedWidth = true;
Phrase testoDatiAz1 = new Phrase(new Chunk("Motor & Brakets", FontFactory.GetFont("Arial", 12, Font.BOLD, testoScuro)));
PdfPCell cellAz1 = new PdfPCell(testoDatiAz1);
cellAz1.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
cellAz1.VerticalAlignment = PdfPCell.ALIGN_CENTER;
cellAz1.FixedHeight = 20;
cellAz1.UseVariableBorders = true;
cellAz1.Border = PdfPCell.NO_BORDER;
tabDatiAziendali.AddCell(cellavuota0);
tabDatiAziendali.AddCell(cellAz1);
Phrase testoDatiAz2;
PdfPCell cellAz2;
if (!String.IsNullOrEmpty(datiAzienda2))
{
testoDatiAz2 = new Phrase(new Chunk("Riparazione e Ricambi per motori
", FontFactory.GetFont("Arial", 11, Font.BOLD, testoScuro)));
cellAz2 = new PdfPCell(testoDatiAz2);
cellAz2.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
cellAz2.VerticalAlignment = PdfPCell.ALIGN_CENTER;
cellAz2.FixedHeight = 20;
cellAz2.UseVariableBorders = true;
cellAz2.Border = PdfPCell.NO_BORDER;
tabDatiAziendali.AddCell(cellAz2);
}
tabDatiAziendali.AddCell(cellavuota0);
tabDatiAziendali.AddCell(cellavuota0);
document.Add(tabDatiAziendali);
PdfPTable table = new PdfPTable(new float[] { 246, 98, 148 });
table.TotalWidth = 492;//500 massima lunghezza
table.LockedWidth = true;
Phrase testoDataPrenotazione = new Phrase(new Chunk("data prenotazione: ", FontFactory.GetFont("Arial", 12, Font.BOLDITALIC, testoChiaro )));
testoDataPrenotazione.Add(new Phrase(new Chunk(" 12/02/2016", FontFactory.GetFont("Arial", 12, Font.BOLD, testoScuro))));
PdfPCell cell = new PdfPCell(testoDataPrenotazione);
cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
cell.VerticalAlignment = PdfPCell.ALIGN_CENTER;
cell.BackgroundColor = coloreCelle;
cell.FixedHeight = 20;
cell.UseVariableBorders = true;
cell.BorderColor = contornoCelle;
table.AddCell(cell);
Phrase testoOraPrenotazione = new Phrase(new Chunk("ore: ", FontFactory.GetFont("Arial", 12, Font.BOLDITALIC, testoChiaro)));
testoOraPrenotazione.Add(new Phrase(new Chunk("08:10", FontFactory.GetFont("Arial", 12, Font.BOLD, testoScuro))));
PdfPCell cell2 = new PdfPCell(testoOraPrenotazione);
cell2.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
cell2.VerticalAlignment = PdfPCell.ALIGN_CENTER;
cell2.BackgroundColor = coloreCelle;
cell2.FixedHeight = 20;
cell2.UseVariableBorders = true;
cell2.BorderColor = contornoCelle;
table.AddCell(cell2);
Phrase testoOrePreviste = new Phrase(new Chunk("ore previste: ", FontFactory.GetFont("Arial", 12, Font.BOLDITALIC, testoChiaro)));
testoOrePreviste.Add(new Phrase(new Chunk("7", FontFactory.GetFont("Arial", 12, Font.BOLD, testoScuro))));
PdfPCell cell3 = new PdfPCell(testoOrePreviste);
cell3.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
cell3.VerticalAlignment = PdfPCell.ALIGN_CENTER;
cell3.BackgroundColor = coloreCelle;
cell3.UseVariableBorders = true;
cell3.FixedHeight = 20;
cell3.BorderColor = contornoCelle;
table.AddCell(cell3);
document.Add(table);
PdfPTable table2 = new PdfPTable(new float[] {492});
table2.TotalWidth = 492;
table2.LockedWidth = true;
table2.AddCell(cellavuota);
Phrase testoNominativo = new Phrase(new Chunk("Mirko Zucchettini", FontFactory.GetFont("Arial", 12, Font.BOLD, testoScuro)));
PdfPCell cell4 = new PdfPCell(testoNominativo);
cell4.HorizontalAlignment = PdfPCell.ALIGN_LEFT;
cell4.VerticalAlignment = PdfPCell.ALIGN_CENTER;
cell4.UseVariableBorders = true;
cell4.FixedHeight = 20;
cell4.PaddingLeft = 10;
cell4.BorderColor = contornoCelle;
cell4.BorderWidthBottom = 0;
cell4.BorderWidthTop = 0;
table2.AddCell(cell4);
Phrase testoTelefono = new Phrase(new Chunk("Tel. ", FontFactory.GetFont("Arial", 12, Font.BOLDITALIC, testoChiaro)));
testoTelefono.Add(new Phrase(new Chunk("1234567890", FontFactory.GetFont("Arial", 12, Font.BOLD, testoScuro))));
PdfPCell cell5 = new PdfPCell(testoTelefono);
cell5.HorizontalAlignment = PdfPCell.ALIGN_LEFT;
cell5.VerticalAlignment = PdfPCell.ALIGN_CENTER;
cell5.UseVariableBorders = true;
cell5.BorderWidthBottom = 0;
cell5.BorderWidthTop = 0;
cell5.PaddingLeft = 10;
cell5.FixedHeight = 20;
cell5.BorderColor = contornoCelle;
table2.AddCell(cell5);
table2.AddCell(cellavuota);
Phrase testoVeicolo = new Phrase(new Chunk("Veicolo: ", FontFactory.GetFont("Arial", 12, Font.BOLDITALIC, testoChiaro)));
testoVeicolo.Add(new Phrase(new Chunk("Skoda Fabia", FontFactory.GetFont("Arial", 12, Font.BOLD, testoScuro))));
PdfPCell cell6 = new PdfPCell(testoVeicolo);
cell6.HorizontalAlignment = PdfPCell.ALIGN_LEFT;
cell6.VerticalAlignment = PdfPCell.ALIGN_CENTER;
cell6.UseVariableBorders = true;
cell6.BorderWidthBottom = 0;
cell6.BorderWidthTop = 0;
cell6.PaddingLeft = 10;
cell6.FixedHeight = 20;
cell6.BorderColor = contornoCelle;
table2.AddCell(cell6);
Phrase testoTarga = new Phrase(new Chunk("Targa: ", FontFactory.GetFont("Arial", 12, Font.BOLDITALIC, testoChiaro)));
testoTarga.Add(new Phrase(new Chunk("HG678GH", FontFactory.GetFont("Arial", 12, Font.BOLD, testoScuro))));
PdfPCell cell7 = new PdfPCell(testoTarga);
cell7.HorizontalAlignment = PdfPCell.ALIGN_LEFT;
cell7.VerticalAlignment = PdfPCell.ALIGN_CENTER;
cell7.UseVariableBorders = true;
cell7.BorderWidthBottom = 0;
cell7.BorderWidthTop = 0;
cell7.FixedHeight = 20;
cell7.PaddingLeft = 10;
cell7.BorderColor = contornoCelle;
table2.AddCell(cell7);
table2.AddCell(cellavuota);
Phrase testoTipologia = new Phrase(new Chunk("Tipologia intervento: ", FontFactory.GetFont("Arial", 12, Font.BOLDITALIC, testoChiaro)));
testoTipologia.Add(new Phrase(new Chunk("non definita", FontFactory.GetFont("Arial", 12, Font.BOLD, testoScuro))));
PdfPCell cell8 = new PdfPCell(testoTipologia);
cell8.HorizontalAlignment = PdfPCell.ALIGN_LEFT;
cell8.VerticalAlignment = PdfPCell.ALIGN_CENTER;
cell8.UseVariableBorders = true;
cell8.BorderWidthBottom = 0;
cell8.BorderWidthTop = 0;
cell8.FixedHeight = 20;
cell8.PaddingLeft = 10;
cell8.BorderColor = contornoCelle;
table2.AddCell(cell8);
table2.AddCell(cellavuota);
PdfPTable table3 = new PdfPTable(new float[] { 472 });
table3.TotalWidth = 472;
table3.LockedWidth = true;
Phrase testoNote = new Phrase(new Chunk("Prova", FontFactory.GetFont("Arial", 12, Font.BOLD, testoScuro)));
PdfPCell cell9 = new PdfPCell(testoNote);
cell9.HorizontalAlignment = PdfPCell.ALIGN_LEFT;
cell9.VerticalAlignment = PdfPCell.ALIGN_CENTER;
cell9.BackgroundColor = coloreCelle;
cell9.UseVariableBorders = true;
cell9.BorderColor = contornoCelle;
cell9.FixedHeight = 151;
cell9.PaddingLeft = 10;
cell9.BorderColor = contornoCelle;
table3.AddCell(cell9);
table2.AddCell(table3);
document.Add(table2);
document.Close();
Response.ContentType = "application/pdf";
Response.BinaryWrite(output.ToArray());