Dear Team,
I temporarily resolve it with two cell as a fake one cell:
// !!!!!!!!!!!!
table.DefaultCell.HorizontalAlignment = Element.ALIGN_RIGHT;
table.DefaultCell.Border = Rectangle.LEFT_BORDER |
Rectangle.TOP_BORDER | Rectangle.BOTTOM_BORDER;
table.AddCell(new Phrase(kulcs.ToString(), font));
table.DefaultCell.Border = Rectangle.TOP_BORDER |
Rectangle.RIGHT_BORDER | Rectangle.BOTTOM_BORDER;
table.AddCell(new Phrase(afa.ToString(), font));
// !!!!!!!!!!!!
I think this behaviour is a bug which based on "\n" that I used in
header cells:
table.AddCell(new Phrase(" ÁFA\n% érték", font));
thus appear an double lined simple width column to me in a header
(which is a correct looks, what I wants)
If I put a one row table in this header's data cell possible the with
calculated
to double.
Attila.
Idézet ([email protected]):
> Dear Team,
>
> I just examining iTextSharp 5.1.3 (11.30.2011) and I tried to make an
> invoice looks whit it.
> I would like to add an one lined table with two cell (aligned left and
> right) into another tablle's cell.
> But not all situation working well for me, in the TaxLine method it
> working, but in the ItemLine method (between "!!!!!!!!!!!!"):
> -if the parent cell is aligned right i see the one lined table's right cell
> -if the parent cell is aligned left i see the one lined table's left cell
> -if the parent cell is unaligned i can not see one lined table's cell,
> the cell is empty
>
> It is seems to me the cell inlined table's width is not equal with the
> cell width.
>
> What is the error which i made in ItemLine method?
>
> Best Regards,
> Attila.
>
>
> using System;
> using System.Collections.Generic;
> using System.IO;
> using System.Linq;
> using System.Text;
> using iTextSharp.text;
> using iTextSharp.text.pdf;
> using iTextSharp.text.pdf.draw;
> using iTextSharp.text.pdf.codec;
>
> namespace ConsoleApplication1
> {
> class PdfInvoice
> {
>
> public virtual void Write(Stream stream)
> {
> // step 1
> using (Document document = new Document(PageSize.A4, 34,
> 34, 36, 12))
> {
> // step 2
> PdfWriter writer = PdfWriter.GetInstance(document, stream);
> writer.PageEvent = new PdfPageEvent();
> (writer.PageEvent as PdfPageEvent).Header = "Számla";
> (writer.PageEvent as PdfPageEvent).Footer = "I01110055203";
> // step 3
> document.Open();
> // step 4
> PdfPTable itemTable = ItemHeader(11);
> ItemLine(itemTable, 1, "852432000", "50991817110929",
> "Koncz Zsuzsa | \"...Elmondom hát mindenkinek...\" (CD)", 1, 2850,
> 2850, 0, 2280, 2280, "25", 570, 2850);
> ItemLine(itemTable, 2, "852439000", "50991817123653",
> "Koncz Zsuzsa | Budapest Sportaréna 2006 (DVD)", 1, 4387.5, 4387.5, 0,
> 3510, 3510, "25", 877.5, 4387.5);
> ItemLine(itemTable, 3, "852432000", "50099945742729",
> "Halász Judit | Csiribiri (CD)", 1, 2973.8, 2973.8, 0, 2143, 2143,
> "25", 594.75, 2973.75);
> ItemLine(itemTable, 4, "852432000", "50991817111421",
> "Koncz Zsuzsa | ...Fordul a világ (CD)", 1, 2850, 2850, 0, 2280, 2280,
> "25", 570, 2850);
> ItemLine(itemTable, 5, "852432000", "00886976803223",
> "Halász Judit,Alma eg | Nagy gyerek lemez (CD)", 1, 2678.8, 2678.8, 0,
> 2143, 2143, "25", 535.75, 2678.75);
> ItemLine(itemTable, 6, "852439000", "50999543395467",
> "Irigy Hónaljmirigy | Retro Klub (DVD+CD)", 1, 999, 999, 0, 799.2,
> 799.2, "25", 199.8, 999);
> ItemLine(itemTable, 7, "852432000", "50051865037521",
> "Zoltán Erika | Retrodisco Best Of+ (CD)", 1, 1140, 1140, 0, 1140,
> 1140, "25", 228, 1140);
> ItemLine(itemTable, 8, "852432000", "50399830101625",
> "Levantis,Tacoa | Tai Chi (3 CD)", 3, 1612.5, 4837.5, 0, 1290, 3870,
> "25", 967.5, 4837.5);
> ItemLine(itemTable, 9, "852432000", "50999880481458",
> "Vigh Dániel | Zimme-Zum (CD)", 1, 2560, 2560, 0, 2048, 2048, "25",
> 512, 2560);
> int c = 0;
> /*for (int i = 10; i <= 200; i++)
> {
> ItemLine(itemTable, i, "852432000",
> "50991817110929", "Levantis,Tacoa | Tai Chi (3 CD)", 3, 1612.5,
> 4837.5, 0, 1290, 3870, "25", 967.5, 4837.5);
> c += 3;
> }*/
> ItemSummaLine(itemTable, 11 + c);
> document.Add(itemTable);
> //
> document.Add(new Paragraph("\n",
> FontFactory.GetFont("Courier", 4)));
> //
> PdfPTable taxTable = TaxHeader();
> TaxLine(taxTable, "A", "5", 0, 0, 0, 0, 0, 0);
> TaxLine(taxTable, "B", "15", 0, 0, 0, 0, 0, 0);
> TaxLine(taxTable, "C", "20", 0, 0, 0, 0, 0, 0);
> TaxLine(taxTable, "D", "25", 25277, 20221, 0, 20221,
> 5055, 25277);
> TaxLine(taxTable, "E", "", 0, 0, 0, 0, 0, 0);
> TaxLine(taxTable, "", "", 25277, 20221, 0, 20221,
> 5055, 25277);
> document.Add(taxTable);
> //
> document.Add(new Chunk(new VerticalPositionMark()));
> PdfPTable pays = new PdfPTable(1);
> pays.TotalWidth = 380;
> pays.LockedWidth = true;
> pays.DefaultCell.Padding = 0;
> PdfPTable pay = new PdfPTable(2);
> pay.SetWidths(new int[] { 65, 316 });
> pay.DefaultCell.BackgroundColor = BaseColor.LIGHT_GRAY;
> pay.DefaultCell.Border = Rectangle.NO_BORDER;
> pay.AddCell(new Phrase("Fizetendö:",
> FontFactory.GetFont("Courier", 10)));
> pay.AddCell(new Phrase("25 277 HUF",
> FontFactory.GetFont("Courier", 10)));
> pays.AddCell(pay);
> pays.DefaultCell.Border = Rectangle.NO_BORDER;
> pays.AddCell(new Phrase("Huszontötezer -
> kettöszázhetvenhét HUF", FontFactory.GetFont("Courier", 8)));
> document.Add(pays);
> }
> }
>
> private PdfPTable ItemHeader(Double quantity)
> {
> Font font = FontFactory.GetFont("Courier", 5);
> PdfPTable table = new PdfPTable(new float[] { 2, 3, 7,
> 16, 3, 4, 5, 2, 5, 6, 6, 6 });
> table.WidthPercentage = 100f;
> table.DefaultCell.Padding = 1;
> table.DefaultCell.BackgroundColor = BaseColor.LIGHT_GRAY;
> table.AddCell(new Phrase("\nSSz", font));
> table.DefaultCell.BackgroundColor = BaseColor.WHITE;
> table.AddCell(new Phrase("\nKSH", font));
> table.DefaultCell.BackgroundColor = BaseColor.LIGHT_GRAY;
> table.AddCell(new Phrase("\nEgyedi, EAN", font));
> table.DefaultCell.BackgroundColor = BaseColor.WHITE;
> table.AddCell(new Phrase("\nMegnevezés", font));
> table.DefaultCell.BackgroundColor = BaseColor.LIGHT_GRAY;
> table.AddCell(new Phrase("Menny.\n db", font));
> table.DefaultCell.BackgroundColor = BaseColor.WHITE;
> table.AddCell(new Phrase("Fogy.ár.\nÁFA-val", font));
> table.DefaultCell.BackgroundColor = BaseColor.LIGHT_GRAY;
> table.AddCell(new Phrase("Fogy.érték\nÁFA-val", font));
> table.DefaultCell.BackgroundColor = BaseColor.WHITE;
> table.AddCell(new Phrase("Eng\n %", font));
> table.DefaultCell.BackgroundColor = BaseColor.LIGHT_GRAY;
> table.AddCell(new Phrase("Eng.egy.ár\nÁFA nélkül", font));
> table.DefaultCell.BackgroundColor = BaseColor.WHITE;
> table.AddCell(new Phrase("Engedm. ért.\nÁFA nélkül", font));
> table.DefaultCell.BackgroundColor = BaseColor.LIGHT_GRAY;
> table.AddCell(new Phrase(" ÁFA\n% érték", font));
> table.DefaultCell.BackgroundColor = BaseColor.WHITE;
> table.AddCell(new Phrase(" Eng. ért.\n ÁFA-val", font));
> table.HeaderRows = 1;
> return table;
> }
>
> private void ItemLine(PdfPTable table, int idx, string ksh,
> string ean, string megn, Double menny, Double brEar, Double br, Double
> eng, Double neEar, Double ne, string kulcs, Double afa, Double brEng)
> {
> PdfPTable afaTable = new PdfPTable(new float[] { 1, 5 });
> PdfPCell ck = new PdfPCell(new Phrase(kulcs,
> FontFactory.GetFont("Courier", 5)));
> ck.Padding = 0;
> ck.NoWrap = true;
> ck.HorizontalAlignment = Element.ALIGN_LEFT;
> ck.Border = Rectangle.NO_BORDER;
> afaTable.AddCell(ck);
> PdfPCell cv = new PdfPCell(new Phrase(afa.ToString(),
> FontFactory.GetFont("Courier", 5)));
> cv.Padding = 0;
> cv.NoWrap = true;
> cv.HorizontalAlignment = Element.ALIGN_RIGHT;
> cv.Border = Rectangle.NO_BORDER;
> afaTable.AddCell(cv);
> //
> Font font = FontFactory.GetFont("Courier", 6);
> table.DefaultCell.NoWrap = true;
> table.DefaultCell.BackgroundColor = BaseColor.LIGHT_GRAY;
> table.DefaultCell.HorizontalAlignment = Element.ALIGN_RIGHT;
> table.AddCell(new Phrase(idx.ToString(), font));
> table.DefaultCell.BackgroundColor = BaseColor.WHITE;
> table.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT;
> table.AddCell(new Phrase(ksh,
> FontFactory.GetFont("Courier", 4)));
> table.DefaultCell.BackgroundColor = BaseColor.LIGHT_GRAY;
> table.AddCell(new Phrase(ean, font));
> table.DefaultCell.BackgroundColor = BaseColor.WHITE;
> table.AddCell(new Phrase(megn,
> FontFactory.GetFont("Courier", 4)));
> table.DefaultCell.HorizontalAlignment = Element.ALIGN_RIGHT;
> table.DefaultCell.BackgroundColor = BaseColor.LIGHT_GRAY;
> table.AddCell(new Phrase(menny.ToString(), font));
> table.DefaultCell.BackgroundColor = BaseColor.WHITE;
> table.AddCell(new Phrase(brEar.ToString(), font));
> table.DefaultCell.BackgroundColor = BaseColor.LIGHT_GRAY;
> table.AddCell(new Phrase(br.ToString(), font));
> table.DefaultCell.BackgroundColor = BaseColor.WHITE;
> table.AddCell(new Phrase((eng == 0 ? "" :
> eng.ToString()), font));
> table.DefaultCell.BackgroundColor = BaseColor.LIGHT_GRAY;
> table.AddCell(new Phrase(neEar.ToString(), font));
> table.DefaultCell.BackgroundColor = BaseColor.WHITE;
> table.AddCell(new Phrase(ne.ToString(), font));
> table.DefaultCell.BackgroundColor = BaseColor.LIGHT_GRAY;
> // !!!!!!!!!!!!
> table.DefaultCell.HorizontalAlignment =
> Element.ALIGN_RIGHT; //ALIGN_UNDEFINED;
> table.AddCell(afaTable);
> // !!!!!!!!!!!!
> table.DefaultCell.HorizontalAlignment = Element.ALIGN_RIGHT;
> table.DefaultCell.BackgroundColor = BaseColor.WHITE;
> table.AddCell(new Phrase(brEng.ToString(), font));
> table.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT;
> }
>
> private void ItemSummaLine(PdfPTable table, Double quantity)
> {
> Font font = FontFactory.GetFont("Courier", 5);
> table.DefaultCell.Border = Rectangle.NO_BORDER;
> table.DefaultCell.Colspan = 4;
> table.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER;
> table.AddCell(new Phrase("Számlán szereplö mennyiség
> összesen:", font));
> table.DefaultCell.Colspan = 0;
> table.DefaultCell.HorizontalAlignment = Element.ALIGN_RIGHT;
> table.AddCell(new Phrase(quantity.ToString(), font));
> table.DefaultCell.Colspan = 7;
> table.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT;
> table.AddCell(new Phrase("db", font));
> table.DefaultCell.Colspan = 0;
> table.DefaultCell.Border = Rectangle.LEFT_BORDER |
> Rectangle.TOP_BORDER | Rectangle.RIGHT_BORDER | Rectangle.BOTTOM_BORDER;
> }
>
> private PdfPTable TaxHeader()
> {
> Font font = FontFactory.GetFont("Courier", 6);
> PdfPTable table = new PdfPTable(new float[] { 2, 3, 3, 3,
> 3, 3, 5 });
> table.WidthPercentage = 100f;
>
> PdfPCell c1 = new PdfPCell(new Phrase("Adó kulcsok
> szerint", font));
> PdfPCell c2 = new PdfPCell(new Phrase("Fogyasztói érték
> ÁFA-val", font));
> PdfPCell c3 = new PdfPCell(new Phrase("ÁFA nélküli
> elszámoló érték", font));
> PdfPCell c4 = new PdfPCell(new Phrase("Engedmény érték", font));
> PdfPCell c5 = new PdfPCell(new Phrase("ÁFA nélküli
> engedményes érték", font));
> PdfPCell c6 = new PdfPCell(new Phrase("ÁFA érték", font));
> PdfPCell c7 = new PdfPCell(new Phrase("Összesen", font));
> c1.NoWrap = false;
> c1.HorizontalAlignment = Element.ALIGN_CENTER;
> c2.NoWrap = false;
> c2.HorizontalAlignment = Element.ALIGN_CENTER;
> c3.NoWrap = false;
> c3.HorizontalAlignment = Element.ALIGN_CENTER;
> c4.NoWrap = false;
> c4.HorizontalAlignment = Element.ALIGN_CENTER;
> c5.NoWrap = false;
> c5.HorizontalAlignment = Element.ALIGN_CENTER;
> c6.NoWrap = true;
> c6.HorizontalAlignment = Element.ALIGN_CENTER;
> c7.NoWrap = true;
> c7.HorizontalAlignment = Element.ALIGN_CENTER;
> table.AddCell(c1);
> table.AddCell(c2);
> table.AddCell(c3);
> table.AddCell(c4);
> table.AddCell(c5);
> table.AddCell(c6);
> table.AddCell(c7);
>
> return table;
> }
>
> private void TaxLine(PdfPTable table, string k, string v,
> double v1, double v2, double v3, double v4, double v5, double o)
> {
> Font font = FontFactory.GetFont("Courier", 9);
> if (String.IsNullOrEmpty(k))
> {
> font.SetStyle(Font.BOLD);
> table.DefaultCell.HorizontalAlignment =
> Element.ALIGN_CENTER;
> table.AddCell(new Phrase("Összesen", font));
> }
> else
> {
> table.DefaultCell.HorizontalAlignment = Element.ALIGN_RIGHT;
> PdfPTable t;
> PdfPCell ck;
> PdfPCell cv;
> if (String.IsNullOrEmpty(v))
> {
> t = new PdfPTable(new float[] { 1, 3 });
> ck = new PdfPCell(new Phrase(k + ":", font));
> ck.Padding = 0;
> ck.NoWrap = true;
> ck.HorizontalAlignment = Element.ALIGN_LEFT;
> ck.Border = Rectangle.NO_BORDER;
> t.AddCell(ck);
> cv = new PdfPCell(new Phrase("ÁFA körön kívüli",
> FontFactory.GetFont("Courier", 5)));
> cv.Padding = 0;
> cv.NoWrap = false;
> cv.HorizontalAlignment = Element.ALIGN_RIGHT;
> cv.Border = Rectangle.NO_BORDER;
> t.AddCell(cv);
> table.AddCell(t);
> }
> else
> {
> t = new PdfPTable(new float[] { 1, 2 });
> ck = new PdfPCell(new Phrase(k + ":", font));
> ck.Padding = 0;
> ck.HorizontalAlignment = Element.ALIGN_LEFT;
> ck.Border = Rectangle.NO_BORDER;
> t.AddCell(ck);
> cv = new PdfPCell(new Phrase(v + "%", font));
> cv.Padding = 0;
> cv.HorizontalAlignment = Element.ALIGN_RIGHT;
> cv.Border = Rectangle.NO_BORDER;
> t.AddCell(cv);
> table.AddCell(t);
> }
> }
> table.DefaultCell.HorizontalAlignment = Element.ALIGN_RIGHT;
> table.AddCell(new Phrase(v1.ToString(), font));
> table.AddCell(new Phrase(v2.ToString(), font));
> table.AddCell(new Phrase(v3.ToString(), font));
> table.AddCell(new Phrase(v4.ToString(), font));
> table.AddCell(new Phrase(v5.ToString(), font));
> table.AddCell(new Phrase(o.ToString(), font));
> }
>
> /**
> * Inner class of PdfPageEvent.
> */
> internal class PdfPageEvent : PdfPageEventHelper
> {
> /** The template with the total number of pages. */
> PdfTemplate totalPageNumber;
>
> /** The header text. */
> Font headerFont;
> public string Header { get; set; }
>
> /** The footer text. */
> Font footerFont;
> public string Footer { get; set; }
>
> /**
> * Creates the PdfTemplate that will hold the total
> number of pages.
> * @see com.itextpdf.text.pdf.PdfPageEventHelper#onOpenDocument(
> * com.itextpdf.text.pdf.PdfWriter,
> com.itextpdf.text.Document)
> */
> public override void OnOpenDocument(PdfWriter writer,
> Document document)
> {
> headerFont = FontFactory.GetFont("Courier", 12, Font.BOLD);
> footerFont = FontFactory.GetFont("Courier", 6);
> totalPageNumber =
> writer.DirectContent.CreateTemplate(30, 16);
> }
>
> /**
> * Adds a header to every page
> * @see com.itextpdf.text.pdf.PdfPageEventHelper#onEndPage(
> * com.itextpdf.text.pdf.PdfWriter,
> com.itextpdf.text.Document)
> */
> public override void OnStartPage(PdfWriter writer,
> Document document)
> {
> PdfPTable header = new PdfPTable(1);
> header.TotalWidth = 527;
> header.LockedWidth = true;
> header.DefaultCell.Padding = 0;
> header.DefaultCell.FixedHeight = 16;
> header.DefaultCell.BorderColor = BaseColor.BLACK;
>
> PdfPTable main = new PdfPTable(3);
> main.SetWidths(new int[] { 28, 24, 2 });
> main.DefaultCell.Padding = 0;
> main.DefaultCell.Border = Rectangle.NO_BORDER;
> main.DefaultCell.HorizontalAlignment = Element.ALIGN_RIGHT;
> //
> main.AddCell(new Phrase(Header, headerFont));
> //
> Phrase pageNumber = new Phrase();
> pageNumber.Add(new Chunk("Oldal: ", footerFont));
> pageNumber.Add(new Chunk(string.Format("{0} /",
> writer.PageNumber), headerFont));
> main.AddCell(pageNumber);
> //
> PdfPCell cell = new
> PdfPCell(Image.GetInstance(totalPageNumber));
> cell.BorderColor = iTextSharp.text.BaseColor.WHITE;
> cell.Border = Rectangle.NO_BORDER;
> main.AddCell(cell);
> //
> header.AddCell(main);
> header.WriteSelectedRows(0, -1, 34,
> PageSize.A4.Height - 20, writer.DirectContent);
> if (writer.PageNumber == 1)
> {
> PdfPTable invoiceInfos = new PdfPTable(1);
> invoiceInfos.TotalWidth = 527;
> invoiceInfos.LockedWidth = true;
> invoiceInfos.DefaultCell.Padding = 0;
> invoiceInfos.DefaultCell.BorderColor = BaseColor.BLACK;
> PdfPTable parties = new PdfPTable(2);
> parties.SetWidths(new int[] { 300, 227 });
> parties.DefaultCell.Padding = 0;
> parties.AddCell(InvoiceSeller(writer));
> parties.AddCell(InvoiceBuyer(writer));
> invoiceInfos.AddCell(parties);
> invoiceInfos.AddCell(InvoiceDetails(writer));
> document.Add(invoiceInfos);
> }
> }
>
> /**
> * Adds a footer to every page
> * @see com.itextpdf.text.pdf.PdfPageEventHelper#onEndPage(
> * com.itextpdf.text.pdf.PdfWriter,
> com.itextpdf.text.Document)
> */
> public override void OnEndPage(PdfWriter writer, Document
> document)
> {
> PdfPTable footer = new PdfPTable(2);
> footer.SetWidths(new int[] { 24, 84 });
> footer.TotalWidth = 527;
> footer.LockedWidth = true;
> footer.DefaultCell.Padding = 0;
> footer.DefaultCell.FixedHeight = 12;
> footer.DefaultCell.Border = Rectangle.TOP_BORDER;
> //
> footer.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT;
> footer.AddCell(new Phrase(Footer, footerFont));
> //
> footer.DefaultCell.HorizontalAlignment =
> Element.ALIGN_RIGHT;
> footer.AddCell(new Phrase("Készült a storeIT
> v0.7.1.1644 programmal. (c) 2005-2009 Pécsi Direkt Kft", footerFont));
> //
> footer.WriteSelectedRows(0, -1, 34, 16,
> writer.DirectContent);
> }
>
> /**
> * Fills out the total number of pages before the
> document is closed.
> * @see
> com.itextpdf.text.pdf.PdfPageEventHelper#onCloseDocument(
> * com.itextpdf.text.pdf.PdfWriter,
> com.itextpdf.text.Document)
> */
> public override void OnCloseDocument(PdfWriter writer,
> Document document)
> {
> /*
> * NewPage() already called when closing the
> document; subtract 1
> */
> ColumnText.ShowTextAligned(
> totalPageNumber, Element.ALIGN_LEFT,
> new Phrase((writer.PageNumber - 1).ToString(),
> headerFont),
> 2, 4, 0
> );
> }
>
> private PdfPTable InvoiceSeller(PdfWriter writer)
> {
> PdfPTable seller = new PdfPTable(2);
> seller.SetWidths(new int[] { 45, 255 });
> seller.DefaultCell.Border = Rectangle.NO_BORDER;
> //
> PdfPTable image = new PdfPTable(1);
> image.DefaultCell.Border = Rectangle.NO_BORDER;
> image.AddCell(new Phrase("Számlkibocsátó",
> FontFactory.GetFont("Courier", 4)));
> //
> Image img =
> Image.GetInstance(Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
> "..\\..\\Images", "logo.gif"));
> img.ScaleAbsolute(90, 90);
> image.DefaultCell.Padding = 0;
> image.DefaultCell.FixedHeight = 20;
> image.AddCell(img);
> seller.AddCell(image);
> //
> PdfPTable issuer = new PdfPTable(1);
> issuer.DefaultCell.Padding = 0;
> issuer.DefaultCell.PaddingBottom = 1;
> issuer.DefaultCell.Border = Rectangle.NO_BORDER;
> issuer.AddCell(new Phrase("Központi Hangbeszerzés",
> FontFactory.GetFont("Courier", 6)));
> issuer.DefaultCell.Border = Rectangle.BOTTOM_BORDER;
> issuer.AddCell(new Phrase("Pécsi Direkt Kft.",
> FontFactory.GetFont("Courier", 6)));
> issuer.DefaultCell.Border = Rectangle.NO_BORDER;
> PdfPTable infos = new PdfPTable(2);
> infos.SetWidths(new int[] { 30, 220 });
> infos.DefaultCell.Border = Rectangle.NO_BORDER;
> infos.DefaultCell.Padding = 0;
> infos.DefaultCell.PaddingBottom = 1;
> infos.AddCell(new Phrase("Telephely:",
> FontFactory.GetFont("Courier", 4)));
> infos.AddCell(new Phrase("7630 Pécs, Üszögi-Kiserdő u
> 1.", FontFactory.GetFont("Courier", 4)));
> infos.AddCell(new Phrase("Telefon:",
> FontFactory.GetFont("Courier", 4)));
> infos.AddCell(new Phrase("+3672777273",
> FontFactory.GetFont("Courier", 4)));
> infos.AddCell(new Phrase("Fax:",
> FontFactory.GetFont("Courier", 4)));
> infos.AddCell(new Phrase("+3672777111",
> FontFactory.GetFont("Courier", 4)));
> //
> infos.AddCell(new Phrase("Raktár:",
> FontFactory.GetFont("Courier", 4)));
> PdfPTable tax = new PdfPTable(3);
> tax.SetWidths(new int[] { 100, 20, 100 });
> tax.DefaultCell.Border = Rectangle.NO_BORDER;
> tax.DefaultCell.Padding = 0;
> tax.AddCell(new Phrase("",
> FontFactory.GetFont("Courier", 4)));
> tax.DefaultCell.HorizontalAlignment = Element.ALIGN_RIGHT;
> tax.AddCell(new Phrase("Adósz: ",
> FontFactory.GetFont("Courier", 4)));
> tax.AddCell(new Phrase("11009498-2-41",
> FontFactory.GetFont("Courier", 4)));
> infos.AddCell(tax);
> //
> infos.AddCell(new Phrase("Banksz.:",
> FontFactory.GetFont("Courier", 4)));
> infos.AddCell(new Phrase("Raiffeisen B. -
> 12072507-00151260-00100008", FontFactory.GetFont("Courier", 4)));
> issuer.AddCell(infos);
> seller.AddCell(issuer);
> return seller;
> }
>
> private PdfPTable InvoiceBuyer(PdfWriter writer)
> {
> PdfPTable buyer = new PdfPTable(2);
> buyer.SetWidths(new int[] { 20, 207 });
> buyer.DefaultCell.Border = Rectangle.NO_BORDER;
> //
> PdfPTable image = new PdfPTable(1);
> image.DefaultCell.Border = Rectangle.NO_BORDER;
> image.AddCell(new Phrase("Vevö",
> FontFactory.GetFont("Courier", 4)));
> buyer.AddCell(image);
> PdfPTable customer = new PdfPTable(1);
> customer.DefaultCell.Padding = 0;
> customer.DefaultCell.PaddingBottom = 1;
> customer.DefaultCell.Border = Rectangle.NO_BORDER;
> customer.AddCell(new Phrase("PICUR AJÁNDÉK KFT",
> FontFactory.GetFont("Courier", 6)));
> customer.DefaultCell.Border = Rectangle.BOTTOM_BORDER;
> customer.AddCell(new Phrase("Nagy Lászlóné",
> FontFactory.GetFont("Courier", 6)));
> customer.DefaultCell.Border = Rectangle.NO_BORDER;
> customer.AddCell(new Phrase("1128 Budapest",
> FontFactory.GetFont("Courier", 4)));
> customer.AddCell(new Phrase("Márvámy utca 25. fsz.
> 6.", FontFactory.GetFont("Courier", 4)));
> customer.AddCell(new Phrase("",
> FontFactory.GetFont("Courier", 4)));
> customer.AddCell(new Phrase("",
> FontFactory.GetFont("Courier", 4)));
> customer.AddCell(new Phrase("",
> FontFactory.GetFont("Courier", 4)));
> customer.AddCell(new Phrase("",
> FontFactory.GetFont("Courier", 4)));
> buyer.AddCell(customer);
> buyer.DefaultCell.Colspan = 2;
> Phrase comment = new Phrase();
> comment.Add(new Chunk("Megjegyzés:",
> FontFactory.GetFont("Courier", 5)));
> comment.Add(new Chunk("182727",
> FontFactory.GetFont("Courier", 5, Font.BOLD)));
> buyer.AddCell(comment);
> return buyer;
> }
>
> private PdfPTable InvoiceDetails(PdfWriter writer)
> {
> PdfPTable details = new PdfPTable(5);
> details.SetWidths(new int[] { 105, 105, 105, 105, 105 });
> //
> PdfPTable invoiceNumber = new PdfPTable(1);
> invoiceNumber.DefaultCell.Border = Rectangle.NO_BORDER;
> invoiceNumber.DefaultCell.HorizontalAlignment =
> Element.ALIGN_CENTER;
> invoiceNumber.AddCell(new Phrase("Számlaszám",
> FontFactory.GetFont("Courier", 4)));
> invoiceNumber.AddCell(new Phrase("I01110055203",
> FontFactory.GetFont("Courier", 4)));
> Barcode39 code39 = new Barcode39();
> code39.Code = "I01110055203";
> code39.BarHeight = 6;
> code39.Font = null;
>
> invoiceNumber.AddCell(code39.CreateImageWithBarcode(writer.DirectContent,
> null, null));
> details.AddCell(invoiceNumber);
> //
> PdfPTable issueDateTime = new PdfPTable(1);
> issueDateTime.DefaultCell.Border = Rectangle.NO_BORDER;
> issueDateTime.DefaultCell.HorizontalAlignment =
> Element.ALIGN_CENTER;
> issueDateTime.AddCell(new Phrase("Bizonylat kelte",
> footerFont));
> issueDateTime.AddCell(new Phrase("2011.05.05. 12:42",
> footerFont));
> details.AddCell(issueDateTime);
> //
> PdfPTable taxPointDate = new PdfPTable(1);
> taxPointDate.DefaultCell.Border = Rectangle.NO_BORDER;
> taxPointDate.DefaultCell.HorizontalAlignment =
> Element.ALIGN_CENTER;
> taxPointDate.AddCell(new Phrase("Teljesítés dátuma",
> footerFont));
> taxPointDate.AddCell(new Phrase("2011.05.05.", footerFont));
> details.AddCell(taxPointDate);
> //
> PdfPTable dueDateDateTime = new PdfPTable(1);
> dueDateDateTime.DefaultCell.Border = Rectangle.NO_BORDER;
> dueDateDateTime.DefaultCell.HorizontalAlignment =
> Element.ALIGN_CENTER;
> dueDateDateTime.AddCell(new Phrase("Fizetési
> határidö", footerFont));
> dueDateDateTime.AddCell(new Phrase("2011.05.13.",
> footerFont));
> details.AddCell(dueDateDateTime);
> //
> PdfPTable paymentMeansID = new PdfPTable(1);
> paymentMeansID.DefaultCell.Border = Rectangle.NO_BORDER;
> paymentMeansID.DefaultCell.HorizontalAlignment =
> Element.ALIGN_CENTER;
> paymentMeansID.AddCell(new Phrase("Fizetési mód",
> footerFont));
> paymentMeansID.AddCell(new Phrase("Átutalás", footerFont));
> details.AddCell(paymentMeansID);
> //
> return details;
> }
> }
> }
> }
>
> using System;
> using System.Collections.Generic;
> using System.Diagnostics;
> using System.IO;
> using System.Linq;
> using System.Text;
>
> namespace ConsoleApplication1
> {
> class Program
> {
> static void Main(string[] args)
> {
> using (FileStream fs = new FileStream("test.pdf",
> FileMode.OpenOrCreate))
> {
> new PdfInvoice().Write(fs);
> }
> System.Diagnostics.Process.Start("test.pdf");
> }
> }
> }
>
>
> ------------------------------------------------------------------------------
> All the data continuously generated in your IT infrastructure
> contains a definitive record of customers, application performance,
> security threats, fraudulent activity, and more. Splunk takes this
> data and makes sense of it. IT sense. And common sense.
> http://p.sf.net/sfu/splunk-novd2d
> _______________________________________________
> iText-questions mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
>
> iText(R) is a registered trademark of 1T3XT BVBA.
> Many questions posted to this list can (and will) be answered with a
> reference to the iText book: http://www.itextpdf.com/book/
> Please check the keywords list before you ask for examples:
> http://itextpdf.com/themes/keywords.php
>
------------------------------------------------------------------------------
Cloud Services Checklist: Pricing and Packaging Optimization
This white paper is intended to serve as a reference, checklist and point of
discussion for anyone considering optimizing the pricing and packaging model
of a cloud services business. Read Now!
http://www.accelacomm.com/jaw/sfnl/114/51491232/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples:
http://itextpdf.com/themes/keywords.php