diff --git a/PROMS/Volian.Print.Library/ItemToParagraph.cs b/PROMS/Volian.Print.Library/ItemToParagraph.cs index f6f985d1..e73e22ed 100644 --- a/PROMS/Volian.Print.Library/ItemToParagraph.cs +++ b/PROMS/Volian.Print.Library/ItemToParagraph.cs @@ -105,6 +105,10 @@ namespace Volian.Print.Library private int COL_WID_ADJ = 6; // adjusts for incorrect use of WidSTable when breaking a line (it breaks 6 chars too short) public vlnParagraph(vlnParagraph parent, PdfContentByte cb, ItemInfo itemInfo, float xoff,float yoff, int rnoLevel, int maxRNO, FormatInfo formatInfo) { + //int[] problemIDs = { 871, 877 }; + //List lProblemIDs = new List( problemIDs ); + //if (lProblemIDs.Contains(itemInfo.ItemID)) + // Console.WriteLine("Found Item {0}", itemInfo.ItemID); MyParent = parent; MyContentByte = cb; MyItemInfo = itemInfo; @@ -140,20 +144,38 @@ namespace Volian.Print.Library //yoff += 2 * _SixLinesPerInch; } YTop = yoff; - if (itemInfo.MyHeader != null && itemInfo.MyHeader.Text != null && itemInfo.MyHeader.Text != "") - yoff += SetHeader(this, cb, itemInfo, formatInfo); + if (itemInfo.MyHeader != null && itemInfo.MyHeader.Text != null) + // if (itemInfo.MyHeader != null && itemInfo.MyHeader.Text != null && itemInfo.MyHeader.Text != "") // EquipmentWBlank uses an empty string + yoff += SetHeader(this, cb, itemInfo, formatInfo); YOffset = yoff; AddMacros(itemInfo, mytab); if (mytab != null) mytab.YOffset = yoff; if (myCB != null) myCB.YOffset = yoff; Rtf = GetRtf(itemInfo); + if (itemInfo.IsTablePart) + { + Width = GetTableWidth(cb, IParagraph); + vlnParagraph hls = MyParent; + bool aerTable = itemInfo.FormatStepData.Type.Contains("AER"); + while (hls.MyParent != null) + { + if (aerTable && hls.MyItemInfo.IsHigh) break; + hls = hls.MyParent; + } + XOffset = hls.XOffset + hls.Width / 2 - Width / 2; + if (XOffset < (float)itemInfo.MyDocStyle.Layout.LeftMargin) + XOffsetBox = (float)itemInfo.MyDocStyle.Layout.LeftMargin; + } //if (MyItemInfo.ItemID == 117) //{ // Rtf = Rtf.Replace("3 psig", @"3\'A0psig"); // //Console.WriteLine("'{0}'", Rtf); //} - yoff += Height; - yoff += AdjustForBlankLines(); + if (!itemInfo.IsStepSection) // Don't add any lines for the Section Title + { + yoff += Height; + yoff += AdjustForBlankLines(); + } float yOffRight = yoff; float RnoOffset = ToPrint(formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.ColRTable, maxRNO); if (rnoLevel < maxRNO && itemInfo.RNOs != null) yOffRight= ChildrenRight.Add(cb, itemInfo.RNOs, XOffset + RnoOffset, YTop, YTop, rnoLevel + 1, maxRNO, formatInfo); @@ -207,6 +229,9 @@ namespace Volian.Print.Library } // HLP Change bar flags in format file: // + // Locations: With Text, Outside Box, AER on Left RNO on Right, To The Left of Text + // Text: Date & Change ID, Revision Number, Change ID, None, Custom (use input data) + // Flag AERChgBarMsgRNOChgBarNoMsg and AERMsgRNONoMsg are NOT Used in 16-bit. private vlnChangeBar DoChangeBar(ItemInfo itemInfo, float xoff, float yoff, int maxRNO, FormatInfo formatInfo, vlnChangeBar myCB) { // find column for the change bar based on format flags - this is code from 16-bit @@ -235,6 +260,29 @@ namespace Volian.Print.Library ProcedureConfig.PrintChangeBarText pcbt = itemInfo.PrintChangeBarText; string pcbum1 = itemInfo.PrintChangeBarUsrMsg1; string pcbum2 = itemInfo.PrintChangeBarUsrMsg2; + // Now get the text. + // This is only the User Change Bar Message from the docversion config. Any other data is determined + // during printing, i.e. item or page specific. + + //if (cbd.MyChangeBarText == DocVersionConfig.PrintChangeBarText.ChgID || cbd.MyChangeBarText == DocVersionConfig.PrintChangeBarText.DateChgID) + //{ + // cbd.MyChangeBarMessage = myItemInfo.UserID; + // string mydts = null; + // if (changeBarData.ChgBarMessageFromEdit) + // { + // StepInfo si = (StepInfo)myItemInfo; + // if (si != null) + // { + // StepConfig sc = si.MyConfig as StepConfig; + // if (sc != null && sc.Step_MultipleChangeID != null) cbd.MyChangeBarMessage = sc.Step_MultipleChangeID; + // } + // } + // if (cbd.MyChangeBarText == DocVersionConfig.PrintChangeBarText.DateChgID) cbd.MyChangeBarMessage = cbd.MyChangeBarMessage + @"\" + myItemInfo.DTS.Date.ToString(); + //} + //else if (cbd.MyChangeBarText == DocVersionConfig.PrintChangeBarText.RevNum) + //{ + // //TODO + //} //myCB = new vlnChangeBar(this, XOffset + Width + 5, yoff); // xoff varies depending on type of change bar myCB = new vlnChangeBar(this, (float) itemInfo.MyDocStyle.Layout.LeftMargin+(col*_CharsToTwips), yoff); return myCB; @@ -242,16 +290,16 @@ namespace Volian.Print.Library private int ChangeBarLocation(float c, vlnParagraph paragraph, FormatInfo formatInfo, int maxRNO) { - int fixChgColumn = formatInfo.PlantFormat.FormatData.ProcData.ChangeBarData.FixedChangeColumn ?? 0; + int fixedChgCol = formatInfo.PlantFormat.FormatData.ProcData.ChangeBarData.FixedChangeColumn ?? 0; int cols = formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.ColS ?? 0; int colr = ToPrint(formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.ColRTable, maxRNO); - if (fixChgColumn < -10 || fixChgColumn >= 0) - return ((fixChgColumn > 0)? fixChgColumn : - (fixChgColumn == 0) ? (int)c + 1 : - (c > cols + colr + COL_WID_ADJ) ? - fixChgColumn : + if (fixedChgCol < -10 || fixedChgCol >= 0) + return ((fixedChgCol > 0) ? fixedChgCol : + (fixedChgCol == 0) ? (int)c + 1 : + (c > cols + colr + COL_WID_ADJ) ? -fixedChgCol : AERLeftChangeBarLocation(formatInfo)); else - return (fixChgColumn + (((c < cols + Width + colr) || TableTest() + return (fixedChgCol + (((c < cols + Width + colr) || TableTest() || MyItemInfo.IsCaution || MyItemInfo.IsNote) ? 0 : cols+colr)); // || (GetColumnMode() == 0)) ? 0 : cols + colr)); /* Change bars to left of text -- ColS+WidS+ColR is the end of RNO col*/ } diff --git a/PROMS/Volian.Print.Library/Rtf2Pdf.cs b/PROMS/Volian.Print.Library/Rtf2Pdf.cs index d598420a..1f802f16 100644 --- a/PROMS/Volian.Print.Library/Rtf2Pdf.cs +++ b/PROMS/Volian.Print.Library/Rtf2Pdf.cs @@ -57,27 +57,17 @@ namespace Volian.Print.Library { while (yTop > 0) { - float newYTop = TextAt(cb, para, x, yTop - 12F, width, 100); + float newYTop = TextAt(cb, para, x, yTop - 12F, width, 100,""); //Console.WriteLine("{0},{1},{2}", yTop, width, newYTop); width -= 16; yTop = newYTop; } } - public static float GetParagraphHeight(PdfContentByte cb, Paragraph iParagraph, float width) + private static bool _PdfDebug = true; + public static bool PdfDebug { - ColumnText myColumnText = new ColumnText(cb); - myColumnText.SetSimpleColumn(0, 792F, width, 0); // Bottom margin - myColumnText.AddElement(iParagraph); - //myColumnText.UseAscender = true;// Adjusts to the top of the text box. - int status = myColumnText.Go(true); // Check to see if it will fit on the page. - if (ColumnText.HasMoreText(status)) throw(new Exception("Paragraph longer than a page")); - return 792F - myColumnText.YLine; // This gives the height of the Paragraph - } - private static bool _DrawBox = true; - public static bool DrawBox - { - get { return Rtf2Pdf._DrawBox; } - set { Rtf2Pdf._DrawBox = value; } + get { return Rtf2Pdf._PdfDebug; } + set { Rtf2Pdf._PdfDebug = value; } } private static System.Drawing.PointF _Offset = new System.Drawing.PointF(0, 0); public static System.Drawing.PointF Offset @@ -85,8 +75,11 @@ namespace Volian.Print.Library get { return Rtf2Pdf._Offset; } set { Rtf2Pdf._Offset = value; } } - public static float TextAt(PdfContentByte cb, Paragraph iParagraph, float x, float y, float width, float height) + public static float TextAt(PdfContentByte cb, Paragraph iParagraph, float x, float y, float width, float height, string debugText) { + VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper; + PdfLayer textLayer = _MyPageHelper == null ? null : _MyPageHelper.TextLayer; + if (textLayer != null) cb.BeginLayer(textLayer); float left = x + Offset.X; float top = y + Offset.Y; float right = left + width; @@ -111,14 +104,21 @@ namespace Volian.Print.Library //Console.WriteLine("Calculated Bottom {0}, YLine {1}", top - textHeight, myColumnText.YLine); //BoxText(cb, System.Drawing.Color.BurlyWood, left, top, left + width, top - height); //BoxText(canvas, System.Drawing.Color.CadetBlue, left, top, left + width, top - textHeight); - if(DrawBox)BoxText(cb, System.Drawing.Color.CadetBlue, left, top, left + width, myColumnText.YLine); + if (textLayer != null) cb.EndLayer(); + + if (PdfDebug) + DrawPdfDebug(cb, System.Drawing.Color.CadetBlue, left, top, left + width, myColumnText.YLine, debugText); //Console.WriteLine("Lines = {0}", myColumnText.LinesWritten); return myColumnText.YLine; + } - private static void BoxText(PdfContentByte cb, System.Drawing.Color sysColor, float left, float top, float right, float bottom) + private static void DrawPdfDebug(PdfContentByte cb, System.Drawing.Color sysColor, float left, float top, float right, float bottom, string debugText) { float yAdj = 3; cb.SaveState(); + VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper; + PdfLayer debugLayer = _MyPageHelper == null ? null : _MyPageHelper.DebugLayer; + if (debugLayer != null) cb.BeginLayer(debugLayer); cb.SetColorStroke(new Color(sysColor)); cb.SetLineWidth(.1F); cb.MoveTo(left, top - yAdj); @@ -127,6 +127,15 @@ namespace Volian.Print.Library cb.LineTo(left, bottom - yAdj); cb.LineTo(left, top - yAdj); cb.Stroke(); + ColumnText ct = new ColumnText(cb); + ct.SetSimpleColumn(left, 4 + top - yAdj, right, top - yAdj - 50); + iTextSharp.text.Font font = FontFactory.GetFont("Arial", 2); + Chunk chk = new Chunk(debugText, font); + Phrase ph = new Phrase(chk); + ct.AddElement(ph); + cb.SetColorFill(new Color(sysColor)); + ct.Go(); + if (debugLayer != null) cb.EndLayer(); cb.RestoreState(); } diff --git a/PROMS/Volian.Print.Library/ToPdf.cs b/PROMS/Volian.Print.Library/ToPdf.cs index 844497da..d8cae256 100644 --- a/PROMS/Volian.Print.Library/ToPdf.cs +++ b/PROMS/Volian.Print.Library/ToPdf.cs @@ -48,20 +48,17 @@ namespace Volian.Print.Library if (_PartsAbove != null && _PartsAbove.Count > 0) yPageStart = PartsAbove.ToPdf(cb, yPageStart, yTopMargin, yBottomMargin); float yLocation = yPageStart - YOffset; float retval = yLocation; - if (MyItemInfo.IsStepSection) + if (!MyItemInfo.IsStepSection) // Don't ouput the Step Section title { - Console.WriteLine("Step Section - {0}", MyItemInfo.Path); - } - else - { - retval = Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, Width, 100); + retval = Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, Width, 100, PdfDebugText); if (retval == 0) { cb.PdfDocument.NewPage(); yPageStart = yTopMargin + YTop; yLocation = yPageStart - YOffset; - Console.WriteLine("Other Paginate"); - retval = Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, Width, 100); + //MyItemInfo.ItemID, YSize, yPageSize, yLocation + Console.WriteLine("-1,'Yes','Forced Pagination',{0},{1},,{3},'{4}'", MyItemInfo.ItemID,YSize,0,yLocation,MyItemInfo.ShortPath); + retval = Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, Width, 100, PdfDebugText); } } //Height = yLocation - retval; @@ -71,12 +68,17 @@ namespace Volian.Print.Library if (_PartsContainer != null && _PartsContainer.Count > 0) yPageStart = PartsContainer.ToPdf(cb, yPageStart, yTopMargin, yBottomMargin); return yPageStart; } - - + private string PdfDebugText + { + get + { + return string.Format("ID={0} Type={1} TypeName='{2}' EveryNLines= {3}", MyItemInfo.ItemID, MyItemInfo.FormatStepType, MyItemInfo.FormatStepData.Type, MyItemInfo.FormatStepData.StepLayoutData.EveryNLines); + } + } public override float ToPdf(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin) { float yLocation = yPageStart - YTopMost; - int paginate = Paginate(yLocation, yTopMargin - yBottomMargin); + int paginate = Paginate(yLocation, yTopMargin, yBottomMargin); switch (paginate) { case 1: // Break on High Level Step @@ -96,12 +98,47 @@ namespace Volian.Print.Library return yPageStart; } - private int Paginate(float yLocation, float yPageSize) + private int Paginate(float yLocation, float yTopMargin, float yBottomMargin) { - if (YSize <= yLocation) return 0; // Don't Paginate if there is enough room + float yPageSize = yTopMargin - yBottomMargin; + float yWithinMargins = yLocation - yBottomMargin; + if (MyItemInfo.ItemID == 879) + Console.Write(",'Here'"); + if (MyItemInfo.IsStepSection) return 0; // Don't Paginate on a Step Section + if (YSize <= yWithinMargins) + { + if(MyItemInfo.IsHigh) + Console.WriteLine("1,'No','HLS will fit on page',{0},{1},{2}, {3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath); + return 0; // Don't Paginate if there is enough room + } if (MyItemInfo.IsRNOPart && MyParent.XOffset < XOffset) return 0; // Don't paginate on an RNO to the right - if (MyItemInfo.IsHigh && YSize < yPageSize) return 1; // Paginate on High Level Steps - if (yLocation > yPageSize / 2) return 0; + if (MyItemInfo.IsHigh) + { + if (YSize < yPageSize) // if the entire step can fit on one page, do a page break + { + Console.WriteLine("2,'Yes','HLS will fit on 1 Page',{0},{1},{2}, {3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath); + return 1; // Paginate on High Level Steps + } + else // The entire step cannot fit go ahead and kick to the next page + { + if (yWithinMargins > yPageSize / 2) + { + // If High level Step will not fit, kick to the next page + Console.WriteLine("3,'No','HLS will have to split anyway',{0},{1},{2}, {3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath); + return 0;// Otherwise stay on this page + } + Console.WriteLine("3,'Yes','HLS will have to split',{0},{1},{2}, {3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath); + return 1; // Paginate on High Level Steps + } + } + if (yWithinMargins > yPageSize / 4) + { + Console.WriteLine("4,'No','Not Half way down the page',{0},{1},{2}, {3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath); + return 0; // More than half way down the page + } + //if (ChildrenBelow.Count > 0 && ChildrenBelow[0].YSize < yWithinMargins) + // return 0; + Console.WriteLine("5,'Yes','At least half the page is filled',{0},{1},{2},{3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath); return 2; } } @@ -110,7 +147,7 @@ namespace Volian.Print.Library public override float ToPdf(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin) { float yLocation = yPageStart - YOffset; - Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, HeaderWidth, 100); + Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, HeaderWidth, 100,""); return yPageStart; } } @@ -120,7 +157,7 @@ namespace Volian.Print.Library public override float ToPdf(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin) { float yLocation = yPageStart - YOffset; - Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, TabWidth, 100); + Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, TabWidth, 100, ""); return yPageStart; } } @@ -152,7 +189,7 @@ namespace Volian.Print.Library public override float ToPdf(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin) { float yLocation = yPageStart - YOffset; - Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, Width, 100); + Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, Width, 100, ""); return yPageStart; } } @@ -161,12 +198,16 @@ namespace Volian.Print.Library public override float ToPdf(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin) { float yLocation = yPageStart - YOffset; + VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper; + PdfLayer textLayer = _MyPageHelper == null ? null : _MyPageHelper.TextLayer; + if (textLayer != null) cb.BeginLayer(textLayer); MyContentByte = cb; System.Drawing.Color push = PrintOverride.SvgColor; PrintOverride.SvgColor = PrintOverride.TextColor == System.Drawing.Color.Empty ? System.Drawing.Color.Black : PrintOverride.TextColor ; if (MyPageHelper != null && MyPageHelper.MySvg != null) MyPageHelper.MySvg.DrawMacro(MacroDef, XOffset, yLocation, cb); PrintOverride.SvgColor = push; + if (textLayer != null) cb.EndLayer(); return yPageStart; } } diff --git a/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs b/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs index 47ec92a7..28266eb6 100644 --- a/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs +++ b/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs @@ -7,11 +7,30 @@ using iTextSharp.text.factories; using Volian.Svg.Library; using System.Text.RegularExpressions; using System.Xml; +using VEPROMS.CSLA.Library; namespace Volian.Print.Library { public class VlnSvgPageHelper:SvgPageHelper { + private ChangeBarDefinition _ChangeBarDefinition; + public ChangeBarDefinition ChangeBarDefinition + { + get { return _ChangeBarDefinition; } + set { _ChangeBarDefinition = value; } + } + private PdfLayer _TextLayer; + public PdfLayer TextLayer + { + get { return _TextLayer; } + set { _TextLayer = value; } + } + private PdfLayer _DebugLayer; + public PdfLayer DebugLayer + { + get { return _DebugLayer; } + set { _DebugLayer = value; } + } private VEPROMS.CSLA.Library.SectionInfo _MySection; public VEPROMS.CSLA.Library.SectionInfo MySection { @@ -267,4 +286,47 @@ namespace Volian.Print.Library return ""; } } + public class ChangeBarDefinition + { + private DocVersionConfig.PrintChangeBar _MyChangeBarType; + public DocVersionConfig.PrintChangeBar MyChangeBarType + { + get { return _MyChangeBarType; } + set { _MyChangeBarType = value; } + } + private DocVersionConfig.PrintChangeBarLoc _MyChangeBarLoc; + public DocVersionConfig.PrintChangeBarLoc MyChangeBarLoc + { + get { return _MyChangeBarLoc; } + set { _MyChangeBarLoc = value; } + } + private DocVersionConfig.PrintChangeBarText _MyChangeBarText; + public DocVersionConfig.PrintChangeBarText MyChangeBarText + { + get { return _MyChangeBarText; } + set { _MyChangeBarText = value; } + } + private string _MyChangeBarMessage; + public string MyChangeBarMessage + { + get { return _MyChangeBarMessage; } + set { _MyChangeBarMessage = value; } + } + private int _MyChangeBarColumn; //TODO Should this be two dimensional array + public int MyChangeBarColumn + { + get { return _MyChangeBarColumn; } + set { _MyChangeBarColumn = value; } + } + public ChangeBarDefinition() + { + } + public ChangeBarDefinition(DocVersionConfig.PrintChangeBar myCBT, DocVersionConfig.PrintChangeBarLoc myCBL, DocVersionConfig.PrintChangeBarText myCBTxt, string myCBMsg) + { + _MyChangeBarType = myCBT; + _MyChangeBarLoc = myCBL; + _MyChangeBarText = myCBTxt; + _MyChangeBarMessage = myCBMsg; + } + } } diff --git a/PROMS/Volian.Print.Library/vlnPrintObject.cs b/PROMS/Volian.Print.Library/vlnPrintObject.cs index eaebc280..1416bd68 100644 --- a/PROMS/Volian.Print.Library/vlnPrintObject.cs +++ b/PROMS/Volian.Print.Library/vlnPrintObject.cs @@ -3,6 +3,7 @@ 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 @@ -71,10 +72,41 @@ namespace Volian.Print.Library get { if (_Height == 0) - _Height = Rtf2Pdf.GetParagraphHeight(MyContentByte, IParagraph, Width); + _Height = GetParagraphHeight(MyContentByte, IParagraph, Width); return _Height; } } + public static float GetParagraphHeight(PdfContentByte cb, Paragraph iParagraph, float width) + { + return GetParagraphHeight(cb, iParagraph, width, true); + } + public static float GetParagraphHeight(PdfContentByte cb, Paragraph iParagraph, float width, bool throwException) + { + ColumnText myColumnText = new ColumnText(cb); + myColumnText.SetSimpleColumn(0, 792F, width, 0); // Bottom margin + myColumnText.AddElement(iParagraph); + //myColumnText.UseAscender = true;// Adjusts to the top of the text box. + int status = myColumnText.Go(true); // Check to see if it will fit on the page. + if (ColumnText.HasMoreText(status) && throwException) + throw (new Exception("Paragraph longer than a page")); + return 792F - myColumnText.YLine; // This gives the height of the Paragraph + } + public static float GetTableWidth(PdfContentByte cb, Paragraph iParagraph) + { + int iWidth = 128 * (int) _CharsToTwips; // maximum width in Characters + float h = GetParagraphHeight(cb, iParagraph, iWidth); + int iWidthMax = iWidth; + int iDelta = iWidth / 2; + iWidth = iWidth / 2; + while (iDelta > 0) + { + float h2 = GetParagraphHeight(cb, iParagraph, iWidth,false); + iDelta = iDelta / 2; + if (h2 == h) iWidthMax = iWidth; + iWidth += (h2>h ? 1: -1) * iDelta; + } + return (float) iWidthMax; + } private PdfContentByte _MyContentByte; public PdfContentByte MyContentByte { @@ -330,7 +362,8 @@ namespace Volian.Print.Library if (bxIndx != null) { Box bx = formatInfo.PlantFormat.FormatData.BoxList[(int)bxIndx]; - XOffset += (float)bx.TxtStart + tabWidth + XOffsetBox; + //XOffset += (float)bx.TxtStart + tabWidth + XOffsetBox; + XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin + (float)bx.TxtStart + tabWidth + XOffsetBox; if (myTab!=null)myTab.XOffset = XOffset - tabWidth; } else if (itemInfo.IsHigh) @@ -371,6 +404,10 @@ namespace Volian.Print.Library { Width = MyParent.Width; } + else if (itemInfo.IsTablePart) + { + Width = 72*7; // TODO: Need to determine the Width of the Table based upon the contents + } else { Width = MyParent.Width - tabWidth + (myTab == null ? 0 : myTab.TabAlign); @@ -473,8 +510,8 @@ namespace Volian.Print.Library public partial class vlnBox : vlnPrintObject { private int _LineType; /* how to represent?? */ - private Color _Color; - public Color Color + private System.Drawing.Color _Color; + public System.Drawing.Color Color { get { return _Color; } set { _Color = value; } diff --git a/PROMS/Volian.Svg.Library/SvgScale.cs b/PROMS/Volian.Svg.Library/SvgScale.cs index db3d23c5..c4ab0260 100644 --- a/PROMS/Volian.Svg.Library/SvgScale.cs +++ b/PROMS/Volian.Svg.Library/SvgScale.cs @@ -102,7 +102,7 @@ namespace Volian.Svg.Library float myY = yOffset + cb.PdfDocument.PageSize.Height - _Scale * (y.GetSizeInPixels(DPI) - YLowerLimit); if (myY < .1F * cb.PdfDocument.PageSize.Height) { - cb.PdfDocument.NewPage(); + //cb.PdfDocument.NewPage(); myY += .8F * cb.PdfDocument.PageSize.Height; } return myY; diff --git a/PROMS/Volian.Svg.Library/iTextSharp.cs b/PROMS/Volian.Svg.Library/iTextSharp.cs index b2fa94aa..5cf5d184 100644 --- a/PROMS/Volian.Svg.Library/iTextSharp.cs +++ b/PROMS/Volian.Svg.Library/iTextSharp.cs @@ -411,9 +411,7 @@ namespace Volian.Svg.Library //cb.SetLineWidth(scale.M(LineWidth)); cb.SetLineWidth(LineWidth.Value); cb.SetColorStroke(new Color(LineColor)); - //cb.SetColorStroke(Color.BLACK); } - //cb.SetColorStroke(Color.GREEN); cb.SetLineCap(PdfContentByte.LINE_CAP_ROUND); cb.MoveTo(scale.X(X1), scale.Y(cb, Y1)); cb.LineTo(scale.X(X2), scale.Y(cb, Y2)); @@ -965,7 +963,7 @@ namespace Volian.Svg.Library private void DrawZoomOMatic(PdfContentByte cb) { cb.SaveState(); - ZoomOMatic(cb, 18); + ZoomOMatic(cb, 36); cb.RestoreState(); } private void DrawWatermark(PdfContentByte cb)