internal static void RemoveParentArtifactsOnPageSplitIfOnlyFloatsOverflow(IRenderer overflowRenderer) { overflowRenderer.SetProperty(Property.BACKGROUND, null); overflowRenderer.SetProperty(Property.BACKGROUND_IMAGE, null); overflowRenderer.SetProperty(Property.OUTLINE, null); Border[] borders = AbstractRenderer.GetBorders(overflowRenderer); overflowRenderer.SetProperty(Property.BORDER_TOP, null); overflowRenderer.SetProperty(Property.BORDER_BOTTOM, null); if (borders[1] != null) { overflowRenderer.SetProperty(Property.BORDER_RIGHT, new SolidBorder(ColorConstants.BLACK, borders[1].GetWidth (), 0)); } if (borders[3] != null) { overflowRenderer.SetProperty(Property.BORDER_LEFT, new SolidBorder(ColorConstants.BLACK, borders[3].GetWidth (), 0)); } overflowRenderer.SetProperty(Property.MARGIN_TOP, UnitValue.CreatePointValue(0)); overflowRenderer.SetProperty(Property.MARGIN_BOTTOM, UnitValue.CreatePointValue(0)); overflowRenderer.SetProperty(Property.PADDING_TOP, UnitValue.CreatePointValue(0)); overflowRenderer.SetProperty(Property.PADDING_BOTTOM, UnitValue.CreatePointValue(0)); }
private static void ApplyBorderAttributes(AbstractRenderer renderer, PdfDictionary attributes) { bool specificBorderProperties = renderer.GetProperty <Border>(Property.BORDER_TOP) != null || renderer.GetProperty <Border>(Property.BORDER_RIGHT) != null || renderer.GetProperty <Border>(Property.BORDER_BOTTOM) != null || renderer.GetProperty <Border>(Property.BORDER_LEFT) != null; bool generalBorderProperties = !specificBorderProperties && renderer.GetProperty <Object>(Property.BORDER) != null; if (generalBorderProperties) { Border generalBorder = renderer.GetProperty <Border>(Property.BORDER); Color generalBorderColor = generalBorder.GetColor(); int borderType = generalBorder.GetBorderType(); float borderWidth = generalBorder.GetWidth(); if (generalBorderColor is DeviceRgb) { attributes.Put(PdfName.BorderColor, new PdfArray(generalBorderColor.GetColorValue())); attributes.Put(PdfName.BorderStyle, TransformBorderTypeToName(borderType)); attributes.Put(PdfName.BorderThickness, new PdfNumber(borderWidth)); } } if (specificBorderProperties) { PdfArray borderColors = new PdfArray(); PdfArray borderTypes = new PdfArray(); PdfArray borderWidths = new PdfArray(); bool atLeastOneRgb = false; Border[] borders = renderer.GetBorders(); bool allColorsEqual = true; bool allTypesEqual = true; bool allWidthsEqual = true; for (int i = 1; i < borders.Length; i++) { Border border = borders[i]; if (border != null) { if (null == borders[0] || !border.GetColor().Equals(borders[0].GetColor())) { allColorsEqual = false; } if (null == borders[0] || border.GetWidth() != borders[0].GetWidth()) { allWidthsEqual = false; } if (null == borders[0] || border.GetBorderType() != borders[0].GetBorderType()) { allTypesEqual = false; } } } int[] borderOrder = new int[] { 0, 1, 2, 3 }; //TODO set depending on writing direction foreach (int i in borderOrder) { if (borders[i] != null) { if (borders[i].GetColor() is DeviceRgb) { borderColors.Add(new PdfArray(borders[i].GetColor().GetColorValue())); atLeastOneRgb = true; } else { borderColors.Add(PdfNull.PDF_NULL); } borderTypes.Add(TransformBorderTypeToName(borders[i].GetBorderType())); borderWidths.Add(new PdfNumber(borders[i].GetWidth())); } else { borderColors.Add(PdfNull.PDF_NULL); borderTypes.Add(PdfName.None); borderWidths.Add(PdfNull.PDF_NULL); } } if (atLeastOneRgb) { if (allColorsEqual) { attributes.Put(PdfName.BorderColor, borderColors.Get(0)); } else { attributes.Put(PdfName.BorderColor, borderColors); } } if (allTypesEqual) { attributes.Put(PdfName.BorderStyle, borderTypes.Get(0)); } else { attributes.Put(PdfName.BorderStyle, borderTypes); } if (allWidthsEqual) { attributes.Put(PdfName.BorderThickness, borderWidths.Get(0)); } else { attributes.Put(PdfName.BorderThickness, borderWidths); } } }