/** Constructs a <CODE>PdfPCell</CODE> with a <CODE>PdfPtable</CODE>. * This constructor allows nested tables. * * @param table The <CODE>PdfPTable</CODE> * @param style The style to apply to the cell (you could use getDefaultCell()) * @since 2.1.0 */ public PdfPCell(PdfPTable table, PdfPCell style) : base(0, 0, 0, 0) { borderWidth = 0.5f; border = BOX; column.SetLeading(0, 1); this.table = table; table.WidthPercentage = 100; table.ExtendLastRow = true; column.AddElement(table); if (style != null) { CloneNonPositionParameters(style); verticalAlignment = style.verticalAlignment; paddingLeft = style.paddingLeft; paddingRight = style.paddingRight; paddingTop = style.paddingTop; paddingBottom = style.paddingBottom; colspan = style.colspan; rowspan = style.rowspan; cellEvent = style.cellEvent; useDescender = style.useDescender; useBorderPadding = style.useBorderPadding; rotation = style.rotation; } else { Padding = 0; } }
public override void RenderObject() { ColumnText itextText = new ColumnText(PdfContent); itextText.SetSimpleColumn(ObjectLayoutContainer.Layout.Left.Points, ObjectLayoutContainer.Layout.Top.Points, ObjectLayoutContainer.Layout.Right.Points, ObjectLayoutContainer.Layout.Bottom.Points); Paragraph pdfContentParagraph = new Paragraph(); itextText.AddElement(pdfContentParagraph); if (_textlines.Count > 0) { Models.Text.Paragraph currentParagraph = _textlines.First().ParagraphModel; pdfContentParagraph.Leading = currentParagraph.Leading.Points; pdfContentParagraph.Alignment = (int)currentParagraph.Alignment; foreach (Textline textline in _textlines) { if (currentParagraph != textline.ParagraphModel) { pdfContentParagraph = new Paragraph(textline.ParagraphModel.Leading.Points) { Alignment = (int)textline.ParagraphModel.Alignment }; itextText.AddElement(pdfContentParagraph); } textline.Render(pdfContentParagraph); currentParagraph = textline.ParagraphModel; } itextText.Go(); } }
// --------------------------------------------------------------------------- public void Write(Stream stream) { // step 1 using (Document document = new Document()) { // step 2 PdfWriter writer = PdfWriter.GetInstance(document, stream); // step 3 document.Open(); // step 4 BaseFont bf = BaseFont.CreateFont( "c:/windows/fonts/arialuni.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED ); Font font = new Font(bf, 20); document.Add(new Paragraph("Movie title: Lawrence of Arabia (UK)")); document.Add(new Paragraph("directed by David Lean")); document.Add(new Paragraph("Wrong: " + MOVIE, font)); ColumnText column = new ColumnText(writer.DirectContent); column.SetSimpleColumn(36, 730, 569, 36); column.RunDirection = PdfWriter.RUN_DIRECTION_RTL; column.AddElement(new Paragraph("Wrong: " + MOVIE_WITH_SPACES, font)); column.AddElement(new Paragraph(MOVIE, font)); column.Go(); } }
// --------------------------------------------------------------------------- // replace ContentParser.endElement() from Java example public void EndElement(string name) { if ("chapter".Equals(name)) { return; } String s = buf.ToString().Trim(); buf = new StringBuilder(); if (s.Length > 0) { Paragraph p = new Paragraph(s, font); p.Alignment = Element.ALIGN_JUSTIFIED; column.AddElement(p); int status = column.Go(); while (ColumnText.HasMoreText(status)) { canvas.EndMarkedContentSequence(); document.NewPage(); canvas.BeginMarkedContentSequence(current); column.SetSimpleColumn(36, 36, 384, 569); status = column.Go(); } } canvas.EndMarkedContentSequence(); }
public void NestedTablesTest01() { String output = "nestedTablesTest.pdf"; String cmp = "cmp_nestedTablesTest.pdf"; Stopwatch timer = new Stopwatch(); timer.Start(); Document doc = new Document(PageSize.A4); PdfWriter writer = PdfWriter.GetInstance(doc, File.Create(outFolder + output)); doc.Open(); ColumnText column = new ColumnText(writer.DirectContent); column.SetSimpleColumn(72, 72, 523, 770); column.AddElement(CreateNestedTables(15)); column.Go(); doc.Close(); timer.Stop(); Console.WriteLine(timer.ElapsedMilliseconds); CompareDocuments(output, cmp, false); }
public void Verify_Unicode_PDF_File_CanBeCreated_Using_Chunks() { var pdfDoc = new Document(PageSize.A4); var pdfFilePath = TestUtils.GetOutputFileName(); var fileStream = new FileStream(pdfFilePath, FileMode.Create); var pdfWriter = PdfWriter.GetInstance(pdfDoc, fileStream); pdfDoc.AddAuthor(TestUtils.Author); pdfDoc.Open(); var tahomaFont = TestUtils.GetUnicodeFont("Tahoma", TestUtils.GetTahomaFontPath(), 10, Font.NORMAL, BaseColor.Black); var ct = new ColumnText(pdfWriter.DirectContent) { RunDirection = PdfWriter.RUN_DIRECTION_RTL }; ct.SetSimpleColumn(100, 100, 500, 800, 24, Element.ALIGN_RIGHT); var chunk = new Chunk("آزمایش", tahomaFont); ct.AddElement(chunk); ct.Go(); pdfDoc.Close(); fileStream.Dispose(); TestUtils.VerifyPdfFileIsReadable(pdfFilePath); }
public void TabStopOutOfPageBoundColumnTextTest() { Font f = FontFactory.GetFont(FontFactory.COURIER, 11); Document doc = new Document(); Paragraph p; FileStream fs = new FileStream(TARGET + "/tabStopOutColumnText.pdf", FileMode.Create); PdfWriter writer = PdfWriter.GetInstance(doc, fs); writer.CompressionLevel = 0; doc.Open(); ColumnText ct = new ColumnText(writer.DirectContent); ct.SetSimpleColumn(36, 0, 436, 836); f.Size = 16; p = new Paragraph(Chunk.TABBING); p.Add(new Chunk("Hello world", f)); List <TabStop> tabStopsList = new List <TabStop>(); tabStopsList.Add(new TabStop(1000, new DottedLineSeparator())); tabStopsList.Add(new TabStop(1050, new LineSeparator(), TabStop.Alignment.ANCHOR, ',')); tabStopsList.Add(new TabStop(1100, new DottedLineSeparator(), TabStop.Alignment.ANCHOR)); p.TabSettings = new TabSettings(tabStopsList, 50); AddTabs(p, f, 15, "l.aal"); AddTabs(p, f, 13, "laa,l"); AddTabs(p, f, 13, "laa.l"); AddTabs(p, f, 13, "l,aal"); ct.AddElement(p); ct.Go(); doc.Close(); writer.Close(); Assert.IsTrue(CompareInnerText(SOURCE17, TARGET + "/tabStopOutColumnText.pdf")); }
public static void Add(this ColumnText ct, List <IElement> elements) { foreach (IElement e in elements) { ct.AddElement(e); } }
private static void AddInvoiceHeadingPart(PdfContentByte directContent, Invoice invoice) { var table = new PdfPTable(2) { HorizontalAlignment = Element.ALIGN_LEFT, WidthPercentage = 100 }; table.SetWidths(new float[] { 55, 55 }); table.AddCell(PdfHelper.GetCell("Factuurdatum", PdfHelper.BoldFont).AlignRight()); table.AddCell(PdfHelper.GetCell(invoice.Date.ToShortDateString())); table.AddCell(PdfHelper.GetCell("Vervaldatum", PdfHelper.BoldFont).AlignRight()); table.AddCell(PdfHelper.GetCell(invoice.ExpiryDate.ToShortDateString())); table.AddCell(PdfHelper.GetCell("Factuurnummer", PdfHelper.BoldFont).AlignRight()); table.AddCell(PdfHelper.GetCell(invoice.FullNumber).BorderRight()); if (!string.IsNullOrEmpty(invoice.TheirReference)) { table.AddCell(PdfHelper.GetCell("Uw referentie", PdfHelper.BoldFont).AlignRight()); table.AddCell(PdfHelper.GetCell(invoice.TheirReference).BorderRight()); } PdfHelper.SurroundBorders(table); var columnText = new ColumnText(directContent); var size = directContent.PdfDocument.PageSize; columnText.SetSimpleColumn(size.Right - 300, size.Top - 135, size.Right - 50, size.Top - 500); columnText.AddElement(table); columnText.Go(); }
internal void TextColumn(string text, string nameFont, int sizeFont, float xInfEsq, float yInfEsq, float xSupDir, float ySupDir) { var ct = new ColumnText(this.PdfContentByte); ct.SetSimpleColumn(xInfEsq, yInfEsq, xSupDir, ySupDir); ct.AddElement(TextJustified(text, nameFont, sizeFont)); ct.Go(); }
public void CreateColumnText(string Text, float x, float y, float length, float height) { ColumnText ct = new ColumnText(_pDFWriter.DirectContent); ct.SetSimpleColumn(new Rectangle(x, y, length, height)); ct.AddElement(new Paragraph(Text)); ct.Go(); }
private void WriteTable(PdfContentByte directContent, PdfPTable table, Rectangle coordinates) { ColumnText columnText = new ColumnText(directContent); columnText.SetSimpleColumn(coordinates); columnText.AddElement(table); columnText.Go(); }
private void ProcessStampSolidOutline(ATShape dr, PdfStamper stamper, PdfReader pdfReader, bool isFilled) { var pageHeight = pdfReader.GetPageSizeWithRotation(dr.Mark.PageIndex).Height; var cb = stamper.GetOverContent(dr.Mark.PageIndex); var outer = new Rectangle(dr.PositionX, pageHeight - (dr.PositionY + dr.Height), dr.PositionX + dr.Width, pageHeight - dr.PositionY); var color = GetColor(dr.StampColor ?? "#990000"); cb.SetColorStroke(color); var strokeWidth = 4f; cb.SetLineWidth(strokeWidth); cb.RoundRectangle( outer.Left, outer.Bottom + strokeWidth, outer.Width - strokeWidth, outer.Height - strokeWidth, 5); if (isFilled) { cb.SetColorFill(color); cb.FillStroke(); } else { cb.Stroke(); } var text = dr.LabelText; // Create a font to work with color = GetColor(dr.LabelTextColor ?? "#000000"); cb.SetRGBColorFill(color.R, color.G, color.B); // Note: The x,y of the Pdf Matrix is from bottom left corner. // This command tells iTextSharp to write the text at a certain location with a certain angle. // Again, this will angle the text from bottom left corner to top right corner and it will // place the text in the middle of the page. var size = 13f; var baseFont = BaseFont.CreateFont(BaseFont.TIMES_BOLD, Encoding.ASCII.EncodingName, true); var ct = new ColumnText(cb); var p = new Paragraph(text, new Font(baseFont, size)); var t = new PdfPTable(1); var c = new PdfPCell(p); c.VerticalAlignment = Element.ALIGN_MIDDLE; c.HorizontalAlignment = Element.ALIGN_CENTER; c.FixedHeight = outer.Height + 10; c.BorderWidth = 0; c.SetLeading(0f, 1.2f); c.PaddingBottom = c.PaddingLeft = c.PaddingRight = c.PaddingTop = 0; t.AddCell(c); // TODO: remove this hardcoded adjust, was added to conform client ct.SetSimpleColumn(outer.Left - 2, outer.Bottom, outer.Right + 2, outer.Top + 12); ct.AddElement(t); ct.Go(); }
public void CreateTaggedPdf8() { InitializeDocument("8"); ColumnText columnText = new ColumnText(writer.DirectContent); List list = new List(true); try { list = new List(true); ListItem listItem = new ListItem( new Chunk( "Quick brown fox jumped over a lazy dog. A very long line appears here because we need new line.")); list.Add(listItem); Image i = Image.GetInstance(RESOURCES + "img\\fox.bmp"); Chunk c = new Chunk(i, 0, 0); c.SetAccessibleAttribute(PdfName.ALT, new PdfString("Fox image")); listItem = new ListItem(c); list.Add(listItem); listItem = new ListItem(new Chunk("jumped over a lazy")); list.Add(listItem); i = Image.GetInstance(RESOURCES + "img\\dog.bmp"); c = new Chunk(i, 0, 0); c.SetAccessibleAttribute(PdfName.ALT, new PdfString("Dog image")); listItem = new ListItem(c); list.Add(listItem); listItem = new ListItem(new Paragraph(text)); list.Add(listItem); } catch (Exception) { } columnText.SetSimpleColumn(36, 36, 400, 800); columnText.AddElement(h1); columnText.AddElement(list); columnText.Go(); document.NewPage(); columnText.SetSimpleColumn(36, 36, 400, 800); columnText.Go(); document.Close(); int[] nums = new int[] { 64, 35 }; CheckNums(nums); CompareResults("8"); }
// --------------------------------------------------------------------------- /** * Manipulates a PDF file src * @param src the original PDF * @param stationery the resulting PDF */ public byte[] ManipulatePdf(byte[] src, byte[] stationery) { ColumnText ct = new ColumnText(null); string SQL = @"SELECT country, id FROM film_country ORDER BY country "; using (var c = AdoDB.Provider.CreateConnection()) { c.ConnectionString = AdoDB.CS; using (DbCommand cmd = c.CreateCommand()) { cmd.CommandText = SQL; c.Open(); using (var r = cmd.ExecuteReader()) { while (r.Read()) { ct.AddElement(new Paragraph( 24, new Chunk(r["country"].ToString()) )); } } } } // Create a reader for the original document and for the stationery PdfReader reader = new PdfReader(src); PdfReader rStationery = new PdfReader(stationery); using (MemoryStream ms = new MemoryStream()) { // Create a stamper using (PdfStamper stamper = new PdfStamper(reader, ms)) { // Create an imported page for the stationery PdfImportedPage page = stamper.GetImportedPage(rStationery, 1); int i = 0; // Add the content of the ColumnText object while (true) { // Add a new page stamper.InsertPage(++i, reader.GetPageSize(1)); // Add the stationary to the new page stamper.GetUnderContent(i).AddTemplate(page, 0, 0); // Add as much content of the column as possible ct.Canvas = stamper.GetOverContent(i); ct.SetSimpleColumn(36, 36, 559, 770); if (!ColumnText.HasMoreText(ct.Go())) { break; } } } return(ms.ToArray()); } }
public void CreateTaggedPdf2() { InitializeDocument("2"); Paragraph paragraph = new Paragraph(text); ColumnText columnText = new ColumnText(writer.DirectContent); columnText.SetSimpleColumn(36, 36, 400, 800); columnText.AddElement(h1); columnText.AddElement(paragraph); columnText.Go(); document.NewPage(); columnText.SetSimpleColumn(36, 36, 400, 800); columnText.Go(); document.Close(); // int[] nums = new int[]{237, 47} ; // CheckNums("2", nums); CompareResults("2"); }
/// <summary> /// Get the ColumnText /// </summary> /// <param name="paragraph">ColumnText content</param> /// <param name="x">X position of the lower left corner of the ColumnText</param> /// <param name="currentY">Y position of the lower left corner of the ColumnText</param> /// <param name="simulate">Value indicating wheter add the ColumnText into the PDF document or only compute the needed space</param> /// <returns>ColumnText instance</returns> internal ColumnText GetColumnText(Paragraph paragraph, float x, float currentY, bool simulate) { ColumnText ct = new ColumnText(ContentByte); ct.SetSimpleColumn(x, currentY, RX, currentY - 3000); ct.AddElement(paragraph); ct.Go(simulate); return(ct); }
public override void OnEndPage(PdfWriter writer, Document document) { ColumnText ct = new ColumnText(writer.DirectContent); ct.SetSimpleColumn(new Rectangle(36, 832, 559, 810)); foreach (IElement e in header) { ct.AddElement(e); } ct.Go(); ct.SetSimpleColumn(new Rectangle(36, 10, 559, 32)); foreach (IElement e in footer) { ct.AddElement(e); } ct.Go(); base.OnEndPage(writer, document); }
public void CreateTaggedPdf1() { InitializeDocument("1"); Paragraph paragraph = new Paragraph(text); paragraph.Font = new Font(Font.FontFamily.HELVETICA, 8, Font.NORMAL, BaseColor.RED); ColumnText columnText = new ColumnText(writer.DirectContent); columnText.SetSimpleColumn(36, 36, 250, 800); columnText.AddElement(h1); columnText.AddElement(paragraph); columnText.Go(); columnText.SetSimpleColumn(300, 36, 500, 800); columnText.Go(); document.Close(); int[] nums = new int[] { 77 }; CheckNums(nums); CompareResults("1"); }
public void Add(IWritable w) { if (w is WritableElement) { foreach (IElement e in ((WritableElement)w).Elements()) { ct.AddElement(e); } } }
// =========================================================================== public void Write(Stream stream) { // step 1 using (Document document = new Document(PageSize.A4.Rotate())) { // step 2 PdfWriter writer = PdfWriter.GetInstance(document, stream); // step 3 document.Open(); // step 4 ColumnText column = new ColumnText(writer.DirectContent); List <string> days = PojoFactory.GetDays(); // COlumn definition float[][] x = { new float[] { document.Left, document.Left + 380 }, new float[] { document.Right - 380, document.Right } }; // Loop over the festival days foreach (string day in days) { // add content to the column column.AddElement(GetTable(day)); int count = 0; float height = 0; // iText-ONLY, 'Initial value of the status' => 0 // iTextSharp **DOES NOT** include this member variable // int status = ColumnText.START_COLUMN; int status = 0; // render the column as long as it has content while (ColumnText.HasMoreText(status)) { // add the top-level header to each new page if (count == 0) { height = AddHeaderTable(document, day, writer.PageNumber); } // set the dimensions of the current column column.SetSimpleColumn( x[count][0], document.Bottom, x[count][1], document.Top - height - 10 ); // render as much content as possible status = column.Go(); // go to a new page if you've reached the last column if (++count > 1) { count = 0; document.NewPage(); } } document.NewPage(); } } }
virtual public void TabStopsColumnText() { Document document = new Document(PageSize.A4); PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(OUTABSTOPSC, FileMode.Create)); document.Open(); Font oFont1 = FontFactory.GetFont(BaseFont.ZAPFDINGBATS, 15, Font.UNDEFINED); Font oFont2 = FontFactory.GetFont(BaseFont.COURIER, 15, Font.UNDEFINED); Font oFont3 = FontFactory.GetFont(BaseFont.TIMES_ROMAN, 15, Font.UNDEFINED); Font oFont4 = FontFactory.GetFont(BaseFont.HELVETICA, 15, Font.UNDEFINED); Image oImg = Image.GetInstance(RESOURCES + "logo.gif"); PdfContentByte canvas = writer.DirectContentUnder; List <TabStop> tabStops = new List <TabStop>(); //tabStops.Add(new TabStop(100, new DottedLineSeparator())); //tabStops.Add(new TabStop(200, new DottedLineSeparator())); tabStops.Add(new TabStop(200, new DottedLineSeparator())); //tabStops.Add(new TabStop(300, new DottedLineSeparator())); tabStops.Add(new TabStop(400, new DottedLineSeparator())); //tabStops.Add(new TabStop(500, new DottedLineSeparator())); //tabStops.Add(new TabStop(550, new DottedLineSeparator())); Paragraph oPara = new Paragraph("Hello World! ", oFont1); oPara.TabSettings = new TabSettings(tabStops); oPara.Add(new Chunk("iText ® is a library that allows you to create and manipulate PDF documents.", oFont2)); oPara.Add( new Chunk("It enables developers looking to enhance web- and other applications with dynamic PDF docu", oFont3)); oPara.Add(Chunk.TABBING); oPara.Add(new Chunk("ment generation and/or manipulation.", oFont3)); oPara.Add(new Chunk(oImg, 0, 0, true)); //oPara.Add(new Chunk(new TestVerticalPositionMark())); oPara.Add(Chunk.TABBING); oPara.Add(new Chunk("Developers can use iText to:", oFont4)); ColumnText.ShowTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("|100"), 100, 500, 0); ColumnText.ShowTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("|200"), 200, 500, 0); ColumnText.ShowTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("|250"), 250, 500, 0); ColumnText.ShowTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("|300"), 300, 500, 0); ColumnText.ShowTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("|400"), 400, 500, 0); ColumnText.ShowTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("|500"), 500, 500, 0); ColumnText.ShowTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("|550"), 550, 500, 0); ColumnText oColTxt1 = new ColumnText(canvas); oColTxt1.SetSimpleColumn(0, 400, 595, 500); oColTxt1.AddElement(oPara); oColTxt1.Go(); document.Close(); Assert.IsTrue(CompareInnerText(SOURCE15, OUTABSTOPSC)); }
public void CreateTaggedPdf0() { InitializeDocument("0"); Paragraph paragraph = new Paragraph(); Chunk c = new Chunk(" Hello "); paragraph.Add(c); c = new Chunk(" world\n\n"); paragraph.Add(c); ColumnText columnText = new ColumnText(writer.DirectContent); columnText.SetSimpleColumn(36, 36, 250, 800); columnText.AddElement(paragraph); columnText.Go(); document.Close(); InitializeDocument("0"); paragraph = new Paragraph(); c = new Chunk(" "); paragraph.Add(c); columnText = new ColumnText(writer.DirectContent); columnText.SetSimpleColumn(36, 36, 250, 800); columnText.AddElement(paragraph); columnText.Go(); document.Close(); InitializeDocument("0"); paragraph = new Paragraph(); c = new Chunk("Hello World"); paragraph.Add(c); columnText = new ColumnText(writer.DirectContent); columnText.SetSimpleColumn(36, 36, 250, 800); columnText.AddElement(paragraph); columnText.Go(); document.Close(); InitializeDocument("0"); paragraph = new Paragraph(); c = new Chunk("Hello World"); paragraph.Add(c); document.Add(paragraph); document.Close(); InitializeDocument("0"); paragraph = new Paragraph(); c = new Chunk(" Hello "); paragraph.Add(c); c = new Chunk(" world\n"); paragraph.Add(c); paragraph.Font = new Font(Font.FontFamily.HELVETICA, 8, Font.NORMAL, BaseColor.RED); document.Add(paragraph); document.Close(); }
public bool AddParagraph(Paragraph p, PdfContentByte canvas, AcroFields.FieldPosition f, bool simulate) { ColumnText ct = new ColumnText(canvas); ct.SetSimpleColumn( f.position.Left, f.position.GetBottom(2), f.position.GetRight(2), f.position.Top ); ct.AddElement(p); return(ColumnText.HasMoreText(ct.Go(simulate))); }
private static void BuildPatronageBodyText(int cropYear, string qualified, ColumnText ct) { const string METHOD_NAME = "BuildPatronageBodyText"; Paragraph p = null; try { p = new Paragraph(new Phrase(_primaryLeading, "The amount set forth below has been allocated to your account for Crop Year " + cropYear.ToString() + " by THE WESTERN SUGAR COOPERATIVE pursuant to Article VIII of the By-Laws.\n\n", _normalFont)); p.IndentationLeft = _primaryLeftIndent; p.IndentationRight = _primaryRightIndent; ct.AddElement(p); p = new Paragraph(new Phrase(_primaryLeading, "This notice constitutes a " + qualified.ToLower() + " written notice of allocation as defined in Section 1388(d) of the " + "Internal Revenue Code of 1954, as amended. The total amount of this patronage refund must be included in your gross income for federal income tax purposes " + "whether distributed in cash or as equity. As provided in Article X of the By-Laws, patronage equities may be paid, " + "redeemed, or revolved in whole or in part at a time and in a manner determined by the Board of Directors. The Board of Directors shall have " + "complete discretion over all matters related to paying, redeeming, or revolving patronage equities.\n\n", _normalFont)); p.IndentationLeft = _primaryLeftIndent; p.IndentationRight = _primaryRightIndent; ct.AddElement(p); p = new Paragraph(new Phrase(_primaryLeading, "As stated in Article XI of the By-laws, no proposed assignment or transfer of common stock, membership agreements, patron preferred stock, " + "patronge equities, or unit retains shall be binding upon the Cooperative without the consent of the Board of Directors, nor until it shall have been " + "entered on the books of the Cooperative\n\n", _normalFont)); p.IndentationLeft = _primaryLeftIndent; p.IndentationRight = _primaryRightIndent; ct.AddElement(p); p = new Paragraph(new Phrase("This notice has been executed as of the date set forth below by the undersigned duly authorized officer of THE WESTERN SUGAR COOPERATIVE.\n\n", _normalFont)); p.IndentationLeft = _primaryLeftIndent; p.IndentationRight = _primaryRightIndent; ct.AddElement(p); } catch (Exception ex) { WSCIEMP.Common.CException wex = new WSCIEMP.Common.CException(MOD_NAME + METHOD_NAME, ex); throw (wex); } }
virtual public void TabspaceColumnTextTest() { Font f = FontFactory.GetFont(FontFactory.COURIER, 11); Document doc = new Document(); Paragraph p; FileStream fs = new FileStream(OUTABSPACEC, FileMode.Create); PdfWriter writer = PdfWriter.GetInstance(doc, fs); writer.CompressionLevel = 0; doc.Open(); ColumnText ct = new ColumnText(writer.DirectContent); ct.SetSimpleColumn(36, 36, 436, 800); p = new Paragraph(new Chunk("Hello world", f)); AddTabspaces(p, f, 0); ct.AddElement(p); p = new Paragraph(new Chunk("Hello World!!!")); AddTabspaces(p, f, 0); ct.AddElement(p); f.Size = 16; p = new Paragraph(new Chunk("Hello world", f)); AddTabspaces(p, f, 0); ct.AddElement(p); f = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 12); p = new Paragraph(new Chunk("Hello world", f)); AddTabspaces(p, f, 0); ct.AddElement(p); f.Size = 20; p = new Paragraph(new Chunk("Hello world", f)); AddTabspaces(p, f, 0); ct.AddElement(p); ct.Go(); doc.Close(); fs.Close(); Assert.IsTrue(CompareInnerText(SOURCE12, OUTABSPACEC)); }
// --------------------------------------------------------------------------- /** * Add content to a ColumnText object. * @param ct the ColumnText object * @param movie a Movie object * @param img the poster of the image */ public void AddContent(ColumnText ct, Movie movie, Image img) { ct.AddElement(img); ct.AddElement(new Paragraph(movie.Title, FilmFonts.BOLD)); if (!string.IsNullOrEmpty(movie.OriginalTitle)) { ct.AddElement(new Paragraph(movie.OriginalTitle, FilmFonts.ITALIC)); } ct.AddElement(PojoToElementFactory.GetDirectorList(movie)); ct.AddElement(PojoToElementFactory.GetYearPhrase(movie)); ct.AddElement(PojoToElementFactory.GetDurationPhrase(movie)); ct.AddElement(PojoToElementFactory.GetCountryList(movie)); ct.AddElement(Chunk.NEWLINE); }
/// <summary> /// Get height of provided PDF table /// </summary> /// <param name="table">PDF table for which to compute height</param> /// <returns>Height of the PDF table</returns> internal float GetTableHeight(PdfPTable table) { ColumnText ct = new ColumnText(ContentByte); ct.SetSimpleColumn( PdfDocument.Left, PdfDocument.Bottom, PdfDocument.Right, PdfDocument.Top ); ct.AddElement(table); ct.Go(true); return(table.TotalHeight); }
public void DrawString(string text, System.Drawing.Rectangle rect) { var bf = iTextSharp.text.pdf.BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1250, false); var f = new Font(bf, 12); var p = new iTextSharp.text.Paragraph(text); p.Font = f; var ct = new ColumnText(Canvas); ct.SetSimpleColumn(Transform2(rect)); ct.AddElement(p); ct.Go(); }
public static void DrawText(PdfContentByte cb, string text, iTextSharp.text.Font font, float x, float y, float width, float height, int alignment) { cb.SetRGBColorFill(127, 127, 127); //cb.Rectangle(x, y, width, height); //cb.Stroke(); ColumnText ct = new ColumnText(cb); ct.SetSimpleColumn(x, y, x + width, y + height); var p = new Paragraph(text); //, font); p.Alignment = alignment; ct.AddElement(p); ct.Go(); }