using System; using System.Collections.Generic; using System.Text; using System.Drawing; using iTextSharp.text.pdf; using iTextSharp.text; using VEPROMS.CSLA.Library; namespace Volian.Print.Library { public partial class vlnRNOSeparator : vlnPrintObject { private VE_Font _MyFont; public VE_Font MyFont { get { return _MyFont; } set { _MyFont = value; } } private bool _ExtendChangeBar; public bool ExtendChangeBar { get { return _ExtendChangeBar; } set { _ExtendChangeBar = value; } } private float _XLength = 0; public float XLength { get { return _XLength; } set { _XLength = value; } } /* if flag set and separator defined then output separator */ /*if separator is a control-A use RNOSepLine*/ public vlnRNOSeparator(vlnParagraph parent, PdfContentByte cb, string sepStr, float xoffset, float yoffset, FormatInfo formatInfo, bool extendChangeBar) { MyContentByte = cb; // B2019-091: crash when printing (note moved from the 'ToPdf' method) ExtendChangeBar = formatInfo.PlantFormat.FormatData.ProcData.ChangeBarData.ChangeBarToRNOSep ? extendChangeBar : false; YOffset = yoffset; XOffset = xoffset; XLength = formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionPrintData.RNOSepLineLength??0; _MyParent = parent; MyFont = formatInfo.PlantFormat.FormatData.Font; if (XLength == 0) { if (sepStr != null) Rtf = GetRtf(sepStr, formatInfo.PlantFormat.FormatData.Font); else Rtf = "--------------------------"; //TODO - What should this be: is this Ctrl-A? Width = sepStr.Length * MyFont.CharsToTwips + _WidthAdjust; } else { Width = XLength; Height = SixLinesPerInch; } } public override float ToPdf(PdfContentByte cb, float yPageStart, ref float yTopMargin, ref float yBottomMargin) { float yLocation = CalculateYOffset(yPageStart, yTopMargin); if (XLength != 0) { cb.SaveState(); VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper; PdfLayer textLayer = _MyPageHelper == null ? null : _MyPageHelper.TextLayer; if (textLayer != null) cb.BeginLayer(textLayer); iTextSharp.text.Color lineColor = new iTextSharp.text.Color(PrintOverride.OverrideChangeBarColor(System.Drawing.Color.Black)); cb.SetColorStroke(lineColor); cb.SetLineWidth(.5F); // C2018-004 create meta file for baseline compares Volian.Base.Library.BaselineMetaFile.WriteLine("RNOSepLn X1={0} Y1={1} X2={2} Y2={3}", XOffset, yLocation - 7, XOffset + XLength, yLocation - 7); cb.MoveTo(XOffset/* + xAdj */, yLocation - 7); cb.LineTo(XOffset + XLength, yLocation-7); cb.Stroke(); if (textLayer != null) cb.EndLayer(); cb.RestoreState(); } else Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, Width, 100, "", yBottomMargin); MyPageHelper.BottomContent = yLocation-SixLinesPerInch; return yPageStart; } } }