public void Wrap() { var tag = new Div(); tag.Add(new Span()); Assert.AreEqual("<div><span></span></div>", tag.ToString()); tag.Wrap("razor-blade"); Assert.AreEqual("<div>razor-blade</div>", tag.ToString()); }
public void SetContent() { var tag = new Div(); tag.Add(new Span()); Assert.AreEqual("<div><span></span></div>", tag.ToString()); tag.TagContents = "razor-blade"; Assert.AreEqual("<div>razor-blade</div>", tag.ToString()); }
private void ProcessBlockElement(IElement propertyContainer) { if (elementsContainer == null) { elementsContainer = new Div(); elementsContainer.Add(lastParagraph); } inlineHelper.FlushHangingLeaves(lastParagraph); if (propertyContainer is Image) { elementsContainer.Add((Image)propertyContainer); } else { elementsContainer.Add((IBlockElement)propertyContainer); } lastParagraph = new Paragraph(); elementsContainer.Add(lastParagraph); }
public override void GenerateBody() { base.GenerateBody(); var coverPage = new Div(Compatibility); coverPage.GlobalAttributes.Class.Value = ElementStylesV2.CoverPage; coverPage.Add(_coverImage); BodyElement.Add(coverPage); }
public virtual void ImageTest08() { String outFileName = destinationFolder + "imageTest08.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest08.pdf"; PdfWriter writer = new PdfWriter(outFileName); PdfDocument pdfDoc = new PdfDocument(writer); Document doc = new Document(pdfDoc); iText.Layout.Element.Image image = new iText.Layout.Element.Image(ImageDataFactory.Create(sourceFolder + "Desert.jpg" )); Div div = new Div(); div.Add(image); div.Add(image); doc.Add(div); doc.Close(); NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder , "diff")); }
public virtual void CreatePdf(String dest) { // Initialize PDF document PdfDocument pdf = new PdfDocument(new PdfWriter(dest)); // Initialize document Document document = new Document(pdf, PageSize.A4); //Set column parameters float offSet = 27; float gutter = 18; float columnWidth = (PageSize.A4.GetWidth() - offSet * 2) / 3 - gutter; float columnHeight = PageSize.A4.GetHeight() - offSet * 2; //Define column areas Rectangle[] columns = new Rectangle[] { new Rectangle(offSet + gutter * 0.5f, offSet, columnWidth, columnHeight ), new Rectangle(offSet + columnWidth + gutter * 1.5f, offSet, columnWidth, columnHeight), new Rectangle (offSet + columnWidth * 2 + gutter * 2.5f, offSet, columnWidth, columnHeight) }; document.SetRenderer(new ColumnDocumentRenderer(document, columns)); PdfFont font = PdfFontFactory.CreateFont(StandardFonts.TIMES_ROMAN); PdfFont bold = PdfFontFactory.CreateFont(StandardFonts.HELVETICA_BOLD); document.SetTextAlignment(TextAlignment.JUSTIFIED).SetHyphenation(new HyphenationConfig("en", "uk", 3, 3)); StreamReader sr = File.OpenText(SRC); bool chapter = false; Div div = new Div(); AreaBreak areaBreak = new AreaBreak(AreaBreakType.NEXT_PAGE); String line; while ((line = sr.ReadLine()) != null) { div = new Div().SetFont(font).SetFontSize(11).SetMarginBottom(18); div.Add(new Paragraph(line).SetFont(bold).SetFontSize(12).SetMarginBottom(0)); while ((line = sr.ReadLine()) != null) { div.Add(new Paragraph(line).SetMarginBottom(0).SetFirstLineIndent(36)); if (String.IsNullOrEmpty(line)) { document.Add(div); if (chapter) { document.Add(areaBreak); } div = new Div(); chapter = true; break; } } } document.Add(div); //Close document document.Close(); }
public virtual void CreatePdf(String dest) { //Initialize PDF document PdfDocument pdf = new PdfDocument(new PdfWriter(dest)); // Initialize document Document document = new Document(pdf); PdfFont font = PdfFontFactory.CreateFont(StandardFonts.TIMES_ROMAN); PdfFont bold = PdfFontFactory.CreateFont(StandardFonts.HELVETICA_BOLD); document.SetTextAlignment(TextAlignment.JUSTIFIED).SetHyphenation(new HyphenationConfig("en", "uk", 3, 3)); StreamReader sr = File.OpenText(SRC); LineSeparator separator = new LineSeparator(new DottedLine(2f, 5f)); separator.SetMarginLeft(10); separator.SetMarginRight(10); bool chapter = false; Div div = new Div(); String line; while ((line = sr.ReadLine()) != null) { div = new Div().SetFont(font).SetFontSize(11).SetMarginBottom(18); div.Add(new Paragraph(line).SetFont(bold).SetFontSize(12).SetMarginBottom(0)); while ((line = sr.ReadLine()) != null) { div.Add(new Paragraph(line).SetMarginBottom(0).SetFirstLineIndent(36)); if (String.IsNullOrEmpty(line)) { if (chapter) { div.Add(separator); } document.Add(div); div = new Div(); chapter = true; break; } } } document.Add(div); //Close document document.Close(); }
/// <summary>Convenience method to write a text aligned about the specified point</summary> /// <param name="p"> /// paragraph of text to be placed to the page. By default it has no leading and is written in single line. /// Set width to write multiline text. /// </param> /// <param name="x">the point about which the text will be aligned and rotated</param> /// <param name="y">the point about which the text will be aligned and rotated</param> /// <param name="pageNumber">the page number to write the text</param> /// <param name="textAlign">horizontal alignment about the specified point</param> /// <param name="vertAlign">vertical alignment about the specified point</param> /// <param name="angle">the angle of rotation applied to the text, in radians</param> /// <returns>this object</returns> public virtual T ShowTextAligned(Paragraph p, float x, float y, int pageNumber, TextAlignment?textAlign, VerticalAlignment?vertAlign, float angle) { Div div = new Div(); div.SetTextAlignment(textAlign).SetVerticalAlignment(vertAlign); if (angle != 0) { div.SetRotationAngle(angle); } div.SetProperty(Property.ROTATION_POINT_X, x); div.SetProperty(Property.ROTATION_POINT_Y, y); float divWidth = AbstractRenderer.INF; float divHeight = AbstractRenderer.INF; float divX = x; float divY = y; if (textAlign == TextAlignment.CENTER) { divX = x - divWidth / 2; p.SetHorizontalAlignment(HorizontalAlignment.CENTER); } else { if (textAlign == TextAlignment.RIGHT) { divX = x - divWidth; p.SetHorizontalAlignment(HorizontalAlignment.RIGHT); } } if (vertAlign == VerticalAlignment.MIDDLE) { divY = y - divHeight / 2; } else { if (vertAlign == VerticalAlignment.TOP) { divY = y - divHeight; } } if (pageNumber == 0) { pageNumber = 1; } div.SetFixedPosition(pageNumber, divX, divY, divWidth).SetHeight(divHeight); if (p.GetProperty <Leading>(Property.LEADING) == null) { p.SetMultipliedLeading(1); } div.Add(p.SetMargins(0, 0, 0, 0)); div.SetRole(PdfName.Artifact); this.Add(div); return((T)(Object)this); }
public override void GenerateBody() { base.GenerateBody(); Div page = new Div(Compatibility); page.GlobalAttributes.Class.Value = "about"; H1 heading = new H1(Compatibility); heading.Add(new SimpleHTML5Text(Compatibility) { Text = "About" }); page.Add(heading); foreach (var text in AboutTexts) { var p1 = new Paragraph(Compatibility); var text1 = new SimpleHTML5Text(Compatibility) { Text = text }; p1.Add(text1); page.Add(p1); } foreach (var text in AboutLinks) { var p1 = new Paragraph(Compatibility); var anch = new Anchor(Compatibility); anch.HRef.Value = text; anch.GlobalAttributes.Title.Value = text; var text3 = new SimpleHTML5Text(Compatibility) { Text = text }; anch.Add(text3); p1.Add(anch); page.Add(p1); } BodyElement.Add(page); }
//<expr-mul>// public Node ExprMul() { var unaryOne = ExprUnary(); var xprMul = unaryOne; while (firstOfExprMul.Contains(CurrentToken)) { switch (CurrentToken) { case TokenCategory.MUL: xprMul = new Multiply() { AnchorToken = Expect(TokenCategory.MUL) }; break; case TokenCategory.REM: xprMul = new Remainder() { AnchorToken = Expect(TokenCategory.REM) }; break; case TokenCategory.DIV: xprMul = new Div() { AnchorToken = Expect(TokenCategory.DIV) }; break; default: throw new SyntaxError(firstOfExprMul, tokenStream.Current); } xprMul.Add(unaryOne); xprMul.Add(ExprUnary()); unaryOne = xprMul; } return(xprMul); }
public virtual void BlocksInsideDiv() { /* this test shows different combinations of 3 float values blocks within divParent containers */ String testName = "blocksInsideDiv"; String outFileName = destinationFolder + testName + ".pdf"; String cmpFileName = sourceFolder + "cmp_" + testName + ".pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); pdfDocument.SetTagged(); Document document = new Document(pdfDocument); Div div1 = CreateDiv(ColorConstants.RED, HorizontalAlignment.CENTER, ClearPropertyValue.BOTH, FloatPropertyValue .NONE, UnitValue.CreatePercentValue(80)); Div div2 = CreateDiv(ColorConstants.BLUE, HorizontalAlignment.LEFT, ClearPropertyValue.BOTH, FloatPropertyValue .NONE, UnitValue.CreatePercentValue(80)); Div div3 = CreateDiv(ColorConstants.GREEN, HorizontalAlignment.RIGHT, ClearPropertyValue.BOTH, FloatPropertyValue .NONE, UnitValue.CreatePercentValue(80)); Div divParent1 = CreateParentDiv(HorizontalAlignment.CENTER, ClearPropertyValue.BOTH, UnitValue.CreatePercentValue (80)); divParent1.Add(div3); divParent1.Add(div2); divParent1.Add(div1); document.Add(divParent1); Div divParent2 = CreateParentDiv(HorizontalAlignment.LEFT, ClearPropertyValue.BOTH, UnitValue.CreatePercentValue (80)); divParent2.Add(div2); divParent2.Add(div1); divParent2.Add(div3); document.Add(divParent2); Div divParent3 = CreateParentDiv(HorizontalAlignment.RIGHT, ClearPropertyValue.BOTH, UnitValue.CreatePercentValue (80)); divParent3.Add(div1); divParent3.Add(div2); divParent3.Add(div3); document.Add(divParent3); document.Close(); NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder , "diff01_")); }
public virtual void DivTest01() { PdfDocument pdfDocument = new PdfDocument(new PdfWriter(destinationFolder + "divTest01.pdf")); pdfDocument.SetTagged(); Document document = new Document(pdfDocument); Div div = new Div(); div.Add(CreateParagraph1()); iText.Layout.Element.Image image = new iText.Layout.Element.Image(ImageDataFactory.Create(sourceFolder + imageName )); image.SetAutoScale(true); div.Add(image); div.Add(CreateParagraph2()); div.Add(image); div.Add(CreateParagraph2()); document.Add(div); document.Close(); CompareResult("divTest01.pdf", "cmp_divTest01.pdf"); }
private Div CreateParentDiv(HorizontalAlignment?horizontalAlignment, ClearPropertyValue?clearPropertyValue , UnitValue width) { Div divParent1 = new Div().SetBorder(new SolidBorder(5)).SetWidth(width); divParent1.SetHorizontalAlignment(horizontalAlignment); divParent1.SetProperty(Property.CLEAR, clearPropertyValue); divParent1.Add(new Paragraph("Div with HorizontalAlignment." + horizontalAlignment + ", ClearPropertyValue." + clearPropertyValue)); return(divParent1); }
/// <summary>Convenience method to write a text aligned about the specified point</summary> /// <param name="p"> /// paragraph of text to be placed to the page. By default it has no leading and is written in single line. /// Set width to write multiline text. /// </param> /// <param name="x">the point about which the text will be aligned and rotated</param> /// <param name="y">the point about which the text will be aligned and rotated</param> /// <param name="pageNumber">the page number to write the text</param> /// <param name="textAlign">horizontal alignment about the specified point</param> /// <param name="vertAlign">vertical alignment about the specified point</param> /// <param name="radAngle">the angle of rotation applied to the text, in radians</param> /// <returns>this object</returns> public virtual T ShowTextAligned(Paragraph p, float x, float y, int pageNumber, TextAlignment?textAlign, VerticalAlignment?vertAlign, float radAngle) { Div div = new Div(); div.SetTextAlignment(textAlign).SetVerticalAlignment(vertAlign); if (radAngle != 0) { div.SetRotationAngle(radAngle); } div.SetProperty(Property.ROTATION_POINT_X, x); div.SetProperty(Property.ROTATION_POINT_Y, y); float divSize = 5e3f; float divX = x; float divY = y; if (textAlign == TextAlignment.CENTER) { divX = x - divSize / 2; p.SetHorizontalAlignment(HorizontalAlignment.CENTER); } else { if (textAlign == TextAlignment.RIGHT) { divX = x - divSize; p.SetHorizontalAlignment(HorizontalAlignment.RIGHT); } } if (vertAlign == VerticalAlignment.MIDDLE) { divY = y - divSize / 2; } else { if (vertAlign == VerticalAlignment.TOP) { divY = y - divSize; } } if (pageNumber == 0) { pageNumber = 1; } div.SetFixedPosition(pageNumber, divX, divY, divSize).SetMinHeight(divSize); if (p.GetProperty <Leading>(Property.LEADING) == null) { p.SetMultipliedLeading(1); } div.Add(p.SetMargins(0, 0, 0, 0)); div.GetAccessibilityProperties().SetRole(StandardRoles.ARTIFACT); this.Add(div); return((T)(Object)this); }
public virtual void CollapsingMarginsTest02() { String outFileName = destinationFolder + "collapsingMarginsTest02.pdf"; String cmpFileName = sourceFolder + "cmp_collapsingMarginsTest02.pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); DrawPageBorders(pdfDocument, 3); String textByron = "When a man hath no freedom to fight for at home,\n" + " Let him combat for that of his neighbours;\n" + "Let him think of the glories of Greece and of Rome,\n" + " And get knocked on the head for his labours.\n" + "\n" + "To do good to Mankind is the chivalrous plan,\n" + " And is always as nobly requited;\n" + "Then battle for Freedom wherever you can,\n" + " And, if not shot or hanged, you'll get knighted."; Document doc = new Document(pdfDocument); doc.SetProperty(Property.COLLAPSING_MARGINS, true); doc.Add(new Paragraph("marker text").SetMargin(0)); Paragraph p = new Paragraph(textByron); for (int i = 0; i < 3; i++) { p.Add(textByron); } p.Add("When a man hath no freedom to fight for at home,\n" + " Let him combat for that of his neighbours;\n" + "Let him think of the glories of Greece and of Rome,\n" + " And get knocked on the head for his labours.\n" + "\n" + "To do good to Mankind is the chivalrous plan,\n"); Div div1 = new Div(); Div div2 = new Div(); div1.Add(p).SetBackgroundColor(new DeviceRgb(65, 151, 29)); div2.Add(p).SetBackgroundColor(new DeviceRgb(209, 247, 29)); div1.SetMarginBottom(40); div2.SetMarginTop(20); div2.SetMarginBottom(150); Div div = new Div().SetMarginTop(20).SetMarginBottom(10).SetBackgroundColor(new DeviceRgb(78, 151, 205)); div.Add(div1); div.Add(div2); doc.Add(div); doc.Close(); NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder , "diff")); }
public void SubChildrenPreserveOptions() { var tag = new Div().Id("27"); tag.TagOptions = new TagOptions(new AttributeOptions { Quote = "\"" }); var span = new Span().Id("spn").Add(new Div()); tag.Add(span); Assert.AreEqual("<div id=\"27\"><span id=\"spn\"><div></div></span></div>", tag.ToString()); }
public virtual void UnderlineOpacityTest01() { String outFileName = destinationFolder + "underlineOpacityTest01.pdf"; String cmpFileName = sourceFolder + "cmp_underlineOpacityTest01.pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); DeviceRgb darkBlue = new DeviceRgb(32, 80, 129); Div div = new Div().SetBackgroundColor(darkBlue).SetHeight(300); div.Add(new Paragraph("Simple text inside of the div with transparent (0.0) underline.").SetUnderline(ColorConstants .RED, 0.0f, .75f, 0, 0, -1 / 8f, PdfCanvasConstants.LineCapStyle.BUTT)); div.Add(new Paragraph("Simple text inside of the div with transparent (0.3) underline.").SetUnderline(ColorConstants .RED, 0.3f, .75f, 0, 0, -1 / 8f, PdfCanvasConstants.LineCapStyle.BUTT)); div.Add(new Paragraph("Simple text inside of the div with transparent (0.5) underline.").SetUnderline(ColorConstants .RED, 0.5f, .75f, 0, 0, -1 / 8f, PdfCanvasConstants.LineCapStyle.BUTT)); div.Add(new Paragraph("Simple text inside of the div with transparent (0.7) underline.").SetUnderline(ColorConstants .RED, 0.7f, .75f, 0, 0, -1 / 8f, PdfCanvasConstants.LineCapStyle.BUTT)); div.Add(new Paragraph("Simple text inside of the div with transparent (1.0) underline.").SetUnderline(ColorConstants .RED, 1.0f, .75f, 0, 0, -1 / 8f, PdfCanvasConstants.LineCapStyle.BUTT)); div.Add(new Paragraph("Simple text inside of the div with underline.").SetUnderline(ColorConstants.RED, .75f , 0, 0, -1 / 8f, PdfCanvasConstants.LineCapStyle.BUTT)); document.Add(div); document.Close(); NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder , "diff")); }
/// <summary> /// Converts FB2 Stanza element into XHTML representation /// </summary> /// <param name="stanzaItem">item to convert</param> /// <param name="stanzaConverterParams"></param> /// <returns>XHTML representation</returns> public IHTMLItem Convert(StanzaItem stanzaItem, StanzaConverterParamsV3 stanzaConverterParams) { if (stanzaItem == null) { throw new ArgumentNullException("stanzaItem"); } var stanzaSection = new Div(HTMLElementType.HTML5); if (stanzaItem.Title != null) { var titleConverter = new TitleConverterV3(); stanzaSection.Add(titleConverter.Convert(stanzaItem.Title, new TitleConverterParamsV3 { TitleLevel = stanzaConverterParams.Level, Settings = stanzaConverterParams.Settings })); } if (stanzaItem.SubTitle != null) { var subtitleConverter = new SubtitleConverterV3(); stanzaSection.Add(subtitleConverter.Convert(stanzaItem.SubTitle, new SubtitleConverterParamsV3 { Settings = stanzaConverterParams.Settings })); } foreach (var line in stanzaItem.Lines) { var vElementConverter = new VElementConverterV3(); stanzaSection.Add(vElementConverter.Convert(line, new VElementConverterParamsV3 { Settings = stanzaConverterParams.Settings })); } if (stanzaItem.Lang != null) { stanzaSection.GlobalAttributes.Language.Value = stanzaItem.Lang; } SetClassType(stanzaSection, ElementStylesV3.Stanza); return(stanzaSection); }
public virtual void BackgroundOpacityTest01() { String outFileName = destinationFolder + "backgroundOpacityTest01.pdf"; String cmpFileName = sourceFolder + "cmp_backgroundOpacityTest01.pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); DeviceRgb darkBlue = new DeviceRgb(32, 80, 129); Div div = new Div().SetBackgroundColor(darkBlue).SetHeight(200); div.Add(new Paragraph("Simple text inside of the div with transparent (0.0) background.").SetBackgroundColor (ColorConstants.RED, 0f)); div.Add(new Paragraph("Simple text inside of the div with transparent (0.3) background.").SetBackgroundColor (ColorConstants.RED, 0.3f)); div.Add(new Paragraph("Simple text inside of the div with transparent (0.5) background.").SetBackgroundColor (ColorConstants.RED, 0.5f)); div.Add(new Paragraph("Simple text inside of the div with transparent (0.7) background.").SetBackgroundColor (ColorConstants.RED, 0.7f)); div.Add(new Paragraph("Simple text inside of the div with transparent (1.0) background.").SetBackgroundColor (ColorConstants.RED, 1f)); div.Add(new Paragraph("Simple text inside of the div with background.").SetBackgroundColor(ColorConstants. RED)); document.Add(div); document.Close(); NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder , "diff")); }
private static Div CreateDiv(Color color, ClearPropertyValue?clearPropertyValue, FloatPropertyValue?floatPropertyValue , UnitValue width) { Div div = new Div().SetBorder(new SolidBorder(color, 1)).SetBackgroundColor(color, 0.3f).SetMargins(10, 10 , 10, 10).SetWidth(width); div.SetProperty(Property.CLEAR, clearPropertyValue); div.SetProperty(Property.FLOAT, floatPropertyValue); String cont = "Div with ClearPropertyValue." + clearPropertyValue + ", FloatPropertyValue." + floatPropertyValue; div.Add(new Paragraph(cont)); return(div); }
public virtual void DivWithBigRotatedParagraph() { String outFileName = destinationFolder + "divBigRotatedParagraphTest01.pdf"; String cmpFileName = sourceFolder + "cmp_divBigRotatedParagraphTest01.pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document doc = new Document(pdfDocument); String str = "Hello. I am a fairly long paragraph. I really want you to process me correctly. You heard that? Correctly!!! Even if you will have to wrap me."; Paragraph p = new Paragraph(new Text(str)).SetPadding(1f).SetBorder(new SolidBorder(ColorConstants.BLACK, 2)).SetMargin(3).SetBackgroundColor(ColorConstants.LIGHT_GRAY).SetRotationAngle(Math.PI / 8); Div d = new Div().SetPadding(4f).SetBorder(new SolidBorder(ColorConstants.GREEN, 5)).SetMargin(6); d.Add(p); d.Add(new Paragraph(("iText"))); MinMaxWidth result = ((AbstractRenderer)d.CreateRendererSubTree().SetParent(doc.GetRenderer())).GetMinMaxWidth (); d.SetWidth(ToEffectiveWidth(d, result.GetMinWidth())); doc.Add(d); doc.Close(); NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder , "diff")); }
private static Div CreateDiv(Color color, HorizontalAlignment?horizontalAlignment, ClearPropertyValue?clearPropertyValue , FloatPropertyValue?floatPropertyValue, UnitValue width) { Div div = new Div().SetBorder(new SolidBorder(color, 1)).SetBackgroundColor(color, 0.3f).SetMargins(10, 10 , 10, 10).SetWidth(width); div.SetHorizontalAlignment(horizontalAlignment); div.SetProperty(Property.CLEAR, clearPropertyValue); div.SetProperty(Property.FLOAT, floatPropertyValue); div.Add(new Paragraph("Div with HorizontalAlignment." + horizontalAlignment + ", ClearPropertyValue." + clearPropertyValue + ", FloatPropertyValue." + floatPropertyValue)); return(div); }
public virtual void UpdateHeightTest01() { String testName = "updateHeightTest01.pdf"; String outFileName = destinationFolder + testName; String cmpFileName = sourceFolder + "cmp_" + testName; PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outFileName)); pdfDoc.SetDefaultPageSize(new PageSize(102.0F, 102.0F)); Document doc = new Document(pdfDoc); Div div = new Div(); div.SetBackgroundColor(ColorConstants.RED); div.Add(new Paragraph("row")); div.Add(new Paragraph("row 10")); div.SetKeepTogether(true); div.SetHeight(100); doc.Add(new Paragraph("a")); doc.Add(div); doc.Close(); NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder , testName + "_diff")); }
public Node ExprMul() { var node = ExprUnary(); while (firstOfExprMul.Contains(CurrentToken)) { switch (CurrentToken) { case TokenCategory.MULTIPLICATION: var node_mul = new Mul(); node_mul.AnchorToken = Expect(TokenCategory.MULTIPLICATION); node_mul.Add(node); node_mul.Add(ExprUnary()); node = node_mul; break; case TokenCategory.MODULO: var node_rem = new Rem(); node_rem.AnchorToken = Expect(TokenCategory.MODULO); node_rem.Add(node); node_rem.Add(ExprUnary()); node = node_rem; break; case TokenCategory.DIVIDE: var node_div = new Div(); node_div.AnchorToken = Expect(TokenCategory.DIVIDE); node_div.Add(node); node_div.Add(ExprUnary()); node = node_div; break; default: throw new SyntaxError(firstOfExprMul, tokenStream.Current); } } return(node); }
protected void ManipulatePdf(string dest) { PdfDocument pdfDocument = new PdfDocument(new PdfWriter(dest)); Document doc = new Document(pdfDocument); String bigText = "Hello. I am a fairly long paragraph. I really want you to process me correctly." + " You heard that? Correctly!!! Even if you will have to wrap me."; Style rotatedStyle = new Style().SetPadding(0).SetMargin(0).SetBorder(new SolidBorder(ColorConstants.BLUE, 2)).SetBackgroundColor(ColorConstants.LIGHT_GRAY); Style contentStyle = new Style().SetPadding(0).SetMargin(0).SetBorder(new SolidBorder(ColorConstants.GREEN , 2)).SetWidth(400); LineSeparator line = new LineSeparator(new SolidLine(1)); //width of rotated element isn't set, so it's width will be set automatically Div contentDiv = new Div().AddStyle(contentStyle); contentDiv.Add(new Paragraph("Short paragraph").AddStyle(rotatedStyle).SetRotationAngle(Math.PI * 3 / 8)); contentDiv.Add(line); contentDiv.Add(new Paragraph(bigText).AddStyle(rotatedStyle).SetRotationAngle(Math.PI * 3 / 8)); contentDiv.Add(line); contentDiv.Add(new Paragraph(bigText).AddStyle(rotatedStyle).SetRotationAngle(Math.PI / 30)); doc.Add(contentDiv); doc.Add(new AreaBreak()); //fixed width of rotated elements, so the content inside will be located according set width contentDiv = new Div().AddStyle(contentStyle).SetWidth(200); contentDiv.Add(new Paragraph(bigText).AddStyle(rotatedStyle).SetWidth(400).SetRotationAngle(Math.PI / 2)); doc.Add(contentDiv); doc.Add(new Paragraph(bigText).AddStyle(rotatedStyle).SetWidth(800).SetRotationAngle(Math.PI / 30)); doc.Close(); }
private Div GenerateOutputForQueues(Dictionary <string, CallStats> totalStats) { Div queueDiv = new Div() .SetKeepTogether(true) .SetMarginTop(DIV_MARGIN) .SetFont(REGULAR_FONT); var queueTitle = new Paragraph("Call Stats For Different Queues") .SetFont(BOLD_FONT) .SetFontSize(LARGE_FONT_SIZE) .SetFontColor(HEADING_COLOR); queueDiv.Add(queueTitle); Table queueTable = new Table(new float[totalStats.Count]).UseAllAvailableWidth(); foreach (var queue in totalStats) { Cell queueHeader = new Cell() .SetBackgroundColor(GREEN_BACKGROUND) .Add(new Paragraph(queue.Key)); Cell queueCalls = new Cell() .Add(new Paragraph($"{queue.Value.TotalCalls} Call(s)")); Cell queueTime = new Cell() .SetBackgroundColor(TABLE_STRIPE) .Add(new Paragraph($"Duration: {queue.Value.Duration}")); queueTable.AddHeaderCell(queueHeader) .AddCell(queueCalls) .AddFooterCell(queueTime); } queueDiv.Add(queueTable); return(queueDiv); }
private static Div CreateKeptTogetherDivWithSmallFloat(int divHeight) { // test keep-together processing on height-only overflow for blocks Div div = new Div().SetHeight(divHeight).SetBorder(new SolidBorder(3)); div.SetKeepTogether(true); Div floatDiv = new Div(); floatDiv.SetProperty(Property.FLOAT, FloatPropertyValue.RIGHT); floatDiv.SetHeight(50); floatDiv.SetWidth(50); floatDiv.SetBackgroundColor(ColorConstants.RED); div.Add(floatDiv); return(div); }
public virtual void KeepTogetherDivTest01() { String cmpFileName = sourceFolder + "cmp_keepTogetherDivTest01.pdf"; String outFile = destinationFolder + "keepTogetherDivTest01.pdf"; PdfWriter writer = new PdfWriter(outFile); PdfDocument pdfDoc = new PdfDocument(writer); Document doc = new Document(pdfDoc); Paragraph p = new Paragraph("Test String"); for (int i = 0; i < 28; i++) { doc.Add(p); } Div div = new Div(); div.Add(new Paragraph("first paragraph")); div.Add(new Paragraph("second paragraph")); div.Add(new Paragraph("third paragraph")); div.SetKeepTogether(true); doc.Add(div); doc.Close(); NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFile, cmpFileName, destinationFolder, "diff")); }
/// <summary> /// Convert epigraph author FB2 element /// </summary> /// <param name="textAuthorItem">item to convert</param> /// <param name="epigraphAuthorConverterParams"></param> /// <returns>XHTML representation</returns> public IHTMLItem Convert(TextAuthorItem textAuthorItem, EpigraphAuthorConverterParamsV3 epigraphAuthorConverterParams) { if (textAuthorItem == null) { throw new ArgumentNullException("textAuthorItem"); } var epigraphAuthor = new Div(HTMLElementType.HTML5); var paragraphConverter = new ParagraphConverterV3(); epigraphAuthor.Add(paragraphConverter.Convert(textAuthorItem, new ParagraphConverterParamsV3 { ResultType = ParagraphConvTargetEnumV3.Paragraph, Settings = epigraphAuthorConverterParams.Settings, StartSection = false })); SetClassType(epigraphAuthor, ElementStylesV3.EpigraphAuthor); return(epigraphAuthor); }
public virtual void FixedWidthRotationTest03() { String outFileName = destinationFolder + "fixedWidthRotationTest03.pdf"; String cmpFileName = sourceFolder + cmpPrefix + "fixedWidthRotationTest03.pdf"; Document doc = new Document(new PdfDocument(new PdfWriter(outFileName))); Text text = new Text("Hello. I am a fairly long paragraph. I really want you to process me correctly. You heard that? Correctly!!! Even if you will have to wrap me." ); Div d = new Div().SetWidth(300).SetBorder(new SolidBorder(ColorConstants.RED, 5)).SetPadding(5); Div d1 = new Div().Add(new Paragraph(text)).SetWidth(500).SetRotationAngle(Math.PI * 5 / 8).SetBorder(new SolidBorder(ColorConstants.BLUE, 5)); doc.Add(d.Add(d1)); doc.Close(); NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder , "diff")); }