Print Library, Svg Library, Utils Library, XYPlots

This commit is contained in:
2026-07-24 13:36:46 -04:00
parent 06c3136566
commit f67d37801a
68 changed files with 12173 additions and 16618 deletions
+6 -36
View File
@@ -1,22 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Xml;
using VEPROMS.CSLA.Library;
namespace Volian.Print.Library
{
public class CPSGen
{
private vlnParagraph _MyVlnParagraph;
public vlnParagraph MyVlnParagraph
public vlnParagraph MyVlnParagraph { get; set; }
public CPSGen(vlnParagraph myParagraph)
{
get { return _MyVlnParagraph; }
set { _MyVlnParagraph = value; }
}
public CPSGen(vlnParagraph myParagraph)
{
_MyVlnParagraph = myParagraph;
MyVlnParagraph = myParagraph;
}
public void Generate(string fileName)
{
@@ -33,7 +25,6 @@ namespace Volian.Print.Library
AddAttribute(xe, "FromType", fromType);
AddAttribute(xe, "Ordinal", itm.Ordinal);
AddAttribute(xe, "ParentID", (itm.ActiveParent as ItemInfo).ItemID);
//AddAttribute(xe, "Xoffset", para.XOffset);
AddAttribute(xe, "ItemID", itm.ItemID);
AddAttribute(xe, "PreviousID", itm.PreviousID);
AddAttribute(xe, "ContentID", itm.ContentID);
@@ -45,41 +36,20 @@ namespace Volian.Print.Library
AddAttribute(xe, "FormatID", itm.MyContent.FormatID);
AddAttribute(xe, "Config", itm.MyContent.Config);
AddAttribute(xe, "Rtf", para.Rtf);
//AddParts(xe, "PartsAbove", para.PartsAbove);
//AddParts(xe, "PartsLeft", para.PartsLeft);
//AddParts(xe, "PartsRight", para.PartsRight);
//AddParts(xe, "PartsBelow", para.PartsBelow);
AddChildren(level,0, parent, "ChildrenAbove", para.ChildrenAbove);
AddChildren(level,0, parent, "ChildrenLeft", para.ChildrenLeft);
AddChildren(level,0, parent, "ChildrenRight", para.ChildrenRight);
AddChildren(level,0, parent, "ChildrenBelow", para.ChildrenBelow);
}
private void AddChildren(int level, int fromType, XmlElement parent, string name, vlnParagraphs children)
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping fromType and name for Debugging")]
private void AddChildren(int level, int fromType, XmlElement parent, string name, vlnParagraphs children)
{
if (children == null || children.Count == 0) return;
//XmlElement xchildren = xe.OwnerDocument.AppendChild(xe.OwnerDocument.CreateElement(name)) as XmlElement;
foreach(vlnParagraph child in children)
{
//XmlElement xechild = xe.ParentNode.AppendChild(xe.OwnerDocument.CreateElement("Item")) as XmlElement;
Generate(level+1,0,parent,child);
}
}
//private void AddParts(XmlElement xe, string name, vlnPrintObjects parts)
//{
// if (parts == null || parts.Count == 0) return;
// XmlElement xpart = xe.AppendChild(xe.OwnerDocument.CreateElement(name)) as XmlElement;
// foreach (vlnPrintObject part in parts)
// {
// XmlElement xechild = xpart.AppendChild(xe.OwnerDocument.CreateElement(part.GetType().Name)) as XmlElement;
// Generate(xechild, part);
// }
//}
//private void Generate(XmlElement xe, vlnPrintObject part)
//{
// AddAttribute(xe, "Xoffset", part.XOffset);
// AddAttribute(xe, "Width", part.Width);
// AddAttribute(xe, "Rtf", part.Rtf);
//}
private void AddAttribute(XmlElement xe, string attr, object val)
{
if (val == null) return;
+206 -305
View File
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.IO;
using System.Windows.Forms;
@@ -16,93 +15,54 @@ namespace Volian.Print.Library
class CompleteROReport
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
//Dictionary<string, PdfDestination> _MyErrorBookMarks = new Dictionary<string, PdfDestination>();
Headers Hdrs; // Header stack object.
readonly Headers Hdrs; // Header stack object.
RODataFile RO_df = null;
int curheaderlen;
string RODataFileName;
iTextSharp.text.Document _pdfReportDoc = null;
readonly string RODataFileName;
readonly iTextSharp.text.Document _pdfReportDoc;
PdfPTable datatable = null;
private iTextSharp.text.Font _f14; // = pdf.GetFont("Arial Unicode MS", 14, 1, Color.BLACK);
public iTextSharp.text.Font F14 { get; set; }
public iTextSharp.text.Font F14
{
get { return _f14; }
set { _f14 = value; }
}
private iTextSharp.text.Font _f10;
public iTextSharp.text.Font F10 { get; set; }
public iTextSharp.text.Font F10
{
get { return _f10; }
set { _f10 = value; }
}
private iTextSharp.text.Font _f12;
public iTextSharp.text.Font F12 { get; set; }
public iTextSharp.text.Font F12
{
get { return _f12; }
set { _f12 = value; }
}
private iTextSharp.text.Font _f10Bold;
public iTextSharp.text.Font F10Bold { get; set; }
public iTextSharp.text.Font F10Bold
{
get { return _f10Bold; }
set { _f10Bold = value; }
}
private iTextSharp.text.Font _f12Bold;
public iTextSharp.text.Font F12Bold { get; set; }
public iTextSharp.text.Font F12Bold
{
get { return _f12Bold; }
set { _f12Bold = value; }
}
public bool ConvertCaretToDelta { get; set; } = true;
private bool _ConvertCaretToDelta = true;
public bool IncludeEmptyROFields { get; set; } = false;
public bool ConvertCaretToDelta
{
get { return _ConvertCaretToDelta; }
set { _ConvertCaretToDelta = value; }
}
private bool _IncludeEmptyROFields = false;
public bool IncludeEmptyROFields
{
get { return _IncludeEmptyROFields; }
set { _IncludeEmptyROFields = value; }
}
private int _ROFstID;
public int ROFstID
{
get { return _ROFstID; }
set { _ROFstID = value; }
}
private string ReportTitle = "Complete Referenced Objects Report";
private PdfWriter _MyPDFWriter;
public int ROFstID { get; set; }
private readonly string ReportTitle = "Complete Referenced Objects Report";
private readonly PdfWriter _MyPDFWriter;
public CompleteROReport(PdfWriter mypdfwriter, iTextSharp.text.Document document, string dataFileName, bool convertCaretToDelta, bool includeEmptyROFields)
{
Hdrs = new Headers();
_pdfReportDoc = document;
RODataFileName = dataFileName;
_ConvertCaretToDelta = convertCaretToDelta;
ConvertCaretToDelta = convertCaretToDelta;
_MyPDFWriter = mypdfwriter;
_IncludeEmptyROFields = includeEmptyROFields;
IncludeEmptyROFields = includeEmptyROFields;
}
public void StartNewDataTable()
{
datatable = new PdfPTable(1);
datatable.TotalWidth = _pdfReportDoc.PageSize.Width - _pdfReportDoc.LeftMargin - _pdfReportDoc.RightMargin;
datatable.LockedWidth = true;
PdfPCell cell = new PdfPCell(new Phrase(ReportTitle, F14));
cell.HorizontalAlignment = Element.ALIGN_CENTER;
cell.BackgroundColor = Color.WHITE;
cell.BorderColor = Color.WHITE;
datatable.AddCell(cell);
datatable = new PdfPTable(1)
{
TotalWidth = _pdfReportDoc.PageSize.Width - _pdfReportDoc.LeftMargin - _pdfReportDoc.RightMargin,
LockedWidth = true
};
PdfPCell cell = new PdfPCell(new Phrase(ReportTitle, F14))
{
HorizontalAlignment = Element.ALIGN_CENTER,
BackgroundColor = Color.WHITE,
BorderColor = Color.WHITE
};
datatable.AddCell(cell);
datatable.HeaderRows = 3;
datatable.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT;
}
@@ -113,33 +73,17 @@ namespace Volian.Print.Library
PrintReport();
RO_df.close();
}
private Dictionary<int, DocOutline> _MyDocOutline = new Dictionary<int, DocOutline>();
internal Dictionary<int, DocOutline> MyDocOutline
internal Dictionary<int, DocOutline> MyDocOutline { get; set; } = new Dictionary<int, DocOutline>();
public class DocOutline
{
get { return _MyDocOutline; }
set { _MyDocOutline = value; }
}
public class DocOutline
{
private PdfOutline _MyOutline;
public PdfOutline MyOutline { get; set; }
public PdfOutline MyOutline
public string MyHeader { get; set; }
public DocOutline(PdfOutline outline, string header)
{
get { return _MyOutline; }
set { _MyOutline = value; }
}
private string _MyHeader;
public string MyHeader
{
get { return _MyHeader; }
set { _MyHeader = value; }
}
public DocOutline(PdfOutline outline, string header)
{
_MyHeader = header;
_MyOutline = outline;
MyHeader = header;
MyOutline = outline;
}
}
private string ReplaceLineDrawCharsWithUnicode(string text)
@@ -167,7 +111,6 @@ namespace Volian.Print.Library
instr = instr.Replace("[RHO]", "\u03C1"); // C2016-018 rho symbol - is being read in as a line draw character, so users need to put "[RHO]" in their text for the rho symbol to print
if (ConvertCaretToDelta)
{
//char[] ca = instr.ToCharArray(); // for debug
instr = instr.Replace("^", "\u0394"); // delta
}
//instr = instr.Replace("\x94", "\u0394"); // delta - the delta symbol is being read in as character x94
@@ -188,7 +131,7 @@ namespace Volian.Print.Library
{
string tstr = (instr.Substring(idx+uidx, m1.Index - uidx));
if (tstr.EndsWith(" "))
tstr = tstr.Substring(0, tstr.Length - 1) + "\xA0";
tstr = $"{tstr.Substring(0, tstr.Length - 1)}\xA0";
chk = new Chunk(tstr, fnt);
if (underlineChunk)
chk.SetUnderline(Color.BLACK, 0, 0.05F, 0, -.131F, PdfContentByte.LINE_CAP_ROUND);
@@ -244,7 +187,7 @@ namespace Volian.Print.Library
{
string tstr = (strChk.Substring(uidx, m1.Index - uidx));
if (tstr.EndsWith(" "))
tstr = tstr.Substring(0, tstr.Length - 1) + "\xA0";
tstr = $"{tstr.Substring(0, tstr.Length - 1)}\xA0";
chk = new Chunk(tstr, fnt);
if (underlineChunk)
chk.SetUnderline(Color.BLACK, 0, 0.05F, 0, -.131F, PdfContentByte.LINE_CAP_ROUND);
@@ -264,7 +207,7 @@ namespace Volian.Print.Library
{
string tstr = strChk.Substring(uidx);
if (tstr.EndsWith(" "))
tstr = tstr.Substring(0, tstr.Length - 1) + "\xA0";
tstr = $"{tstr.Substring(0, tstr.Length - 1)}\xA0";
chk = new Chunk(tstr, fnt);
if (underlineChunk)
chk.SetUnderline(Color.BLACK, 0, 0.05F, 0, -.131F, PdfContentByte.LINE_CAP_ROUND);
@@ -276,12 +219,9 @@ namespace Volian.Print.Library
return p;
}
public void AddText(string txt, Font fnt)
{
AddText(txt, fnt, Color.BLACK);
}
public void AddText(string txt, Font fnt, Color txtcolor)
public void AddText(string txt, Font fnt) => AddText(txt, fnt, Color.BLACK);
public void AddText(string txt, Font fnt, Color txtcolor)
{
// break the text up on double returns (paragraphs) and put each in their own cell
// this will allow for page breaks between paragraphs0
@@ -289,11 +229,15 @@ namespace Volian.Print.Library
string[] strlst = txt.Split(delim,StringSplitOptions.None);
foreach (string str in strlst)
{
Font f = new Font(fnt);
f.Color = txtcolor;
PdfPCell cell = new PdfPCell(ConvertDOSSuperAndSubScripts(str, f));
cell.BorderColor = Color.WHITE;
if (strlst.Length > 1)
Font f = new Font(fnt)
{
Color = txtcolor
};
PdfPCell cell = new PdfPCell(ConvertDOSSuperAndSubScripts(str, f))
{
BorderColor = Color.WHITE
};
if (strlst.Length > 1)
cell.PaddingBottom = 6;
datatable.AddCell(cell);
}
@@ -301,11 +245,12 @@ namespace Volian.Print.Library
public void AddImage(string filename)
{
ROImageInfo roImage = ROImageInfo.GetByROFstID_FileName(_ROFstID, filename);
if (roImage == null) roImage = ROFstInfo.Get(_ROFstID).GetROImageByFilename(filename, null);
PdfPCell spaceCell = new PdfPCell();
spaceCell.BorderColor = Color.WHITE;
datatable.AddCell(spaceCell);
ROImageInfo roImage = ROImageInfo.GetByROFstID_FileName(ROFstID, filename) ?? ROFstInfo.Get(ROFstID).GetROImageByFilename(filename, null);
PdfPCell spaceCell = new PdfPCell
{
BorderColor = Color.WHITE
};
datatable.AddCell(spaceCell);
if (roImage != null)
{
ROImageConfig rc = new ROImageConfig(roImage);
@@ -318,8 +263,8 @@ namespace Volian.Print.Library
it_image = iTextSharp.text.Image.GetInstance(dcnt);
//iTextSharp.text.Image it_image = iTextSharp.text.Image.GetInstance(ROImageInfo.Decompress(roImage.Content, size));
}
catch (Exception ex)
{
catch (Exception)
{
try
{
MemoryStream ms = new MemoryStream(dcnt);
@@ -342,9 +287,11 @@ namespace Volian.Print.Library
}
}
it_image.ScaleToFit(_MyPDFWriter.DirectContent.PdfDocument.PageSize.Width - 144, _MyPDFWriter.DirectContent.PdfDocument.PageSize.Height - 216);
PdfPCell cell = new PdfPCell(it_image);
cell.BorderColor = Color.WHITE;
datatable.AddCell(cell);
PdfPCell cell = new PdfPCell(it_image)
{
BorderColor = Color.WHITE
};
datatable.AddCell(cell);
roImage.Dispose();
}
else
@@ -364,17 +311,21 @@ namespace Volian.Print.Library
if (ConvertCaretToDelta)
plotlang = plotlang.Replace("^", "\x394"); // delta
plotlang = plotlang.Replace("\x7F", "\x394"); //delta
PdfPCell spaceCell = new PdfPCell();
spaceCell.BorderColor = Color.WHITE;
datatable.AddCell(spaceCell);
PdfPCell spaceCell = new PdfPCell
{
BorderColor = Color.WHITE
};
datatable.AddCell(spaceCell);
try
{
System.Drawing.RectangleF plotRect = MSWordToPDF.CreatePlot(pngFile, plotlang, 600F, MSWordToPDF.FormForPlotGraphics);
iTextSharp.text.Image it_image = iTextSharp.text.Image.GetInstance(pngFile);
it_image.ScaleToFit(_MyPDFWriter.DirectContent.PdfDocument.PageSize.Width - 144, _MyPDFWriter.DirectContent.PdfDocument.PageSize.Height - 216);
PdfPCell cell = new PdfPCell(it_image);
cell.BorderColor = Color.WHITE;
datatable.AddCell(cell);
PdfPCell cell = new PdfPCell(it_image)
{
BorderColor = Color.WHITE
};
datatable.AddCell(cell);
}
catch (Exception e)
{
@@ -386,94 +337,88 @@ namespace Volian.Print.Library
}
private string processingRO = "";
private string _MyROID = null;
public string MyROID
{
get { return _MyROID; }
set { _MyROID = value; }
}
public void PrintReport()
public string MyROID { get; set; } = null;
public void PrintReport()
{
bool StopPrinting = false;
bool UserTerminate = false;
Int16 iRecType = 0;
VlnStatusBar showStatBar = new VlnStatusBar("Complete RO Report");
try
VlnStatusBar showStatBar = new VlnStatusBar("Complete RO Report");
try
{
if (RO_df.GetFileLength() > 0)
{
showStatBar.BarMax = (int)RO_df.GetFileLength();
showStatBar.StatMsg = "Creating Report";
// Loop until either printing is aborted or end of file.
while (!StopPrinting && (iRecType = RO_df.ReadInteger16()) != -1)
{
//Console.WriteLine("Record Type: {0}.{0:X}", iRecType);
switch (iRecType)
{
case 1: // Set Header
SetHeader();
break;
case 2: // Push Header
PushHeader();
break;
case 3: // Pop Header
PopHeader();
break;
case 4: // RRO Begin
RROBegin();
break;
case 5: // RRO End
RROEnd();
processingRO = "";
break;
case 6: // Msg
Msg();
break;
case 7:
processingRO = KeyField();
break;
case 8:
MyROID = ROIDField();
break;
case 100: // Text Field - sometimes also XY Plot
Text();
Application.DoEvents();
break;
case 101: // Plot Field
XYPlot();
Application.DoEvents();
break;
case 102: // Image Field
ImageFile();
Application.DoEvents();
break;
case 103: // Multi Begin - Display data for setpoints
Multiple();
break;
case 104: // Multi End
break;
case 0: // nothing was entered in that field
if (_IncludeEmptyROFields)
NoInformatEntered();
break;
case 255:
_pdfReportDoc.Add(datatable);
_pdfReportDoc.NewPage();
StartNewDataTable();
showStatBar.BarValue = (int)RO_df.GetFilePointerPosition();
//Console.WriteLine("Record Type: {0} No Operation", iRecType);
//Console.WriteLine("----------------------------------------------");
break;
default: // Problem
//Console.WriteLine("Record Type: {0} Unrecognized record type", iRecType);
StopPrinting = true;
UserTerminate = true;
MessageBox.Show(string.Format("Unrecognized record type [{0}]", iRecType), "Error Creating Complete RO Report", MessageBoxButtons.OK, MessageBoxIcon.Error);
break;
};
}
}
short iRecType;
// Loop until either printing is aborted or end of file.
while (!StopPrinting && (iRecType = RO_df.ReadInteger16()) != -1)
{
//Console.WriteLine("Record Type: {0}.{0:X}", iRecType);
switch (iRecType)
{
case 1: // Set Header
SetHeader();
break;
case 2: // Push Header
PushHeader();
break;
case 3: // Pop Header
PopHeader();
break;
case 4: // RRO Begin
RROBegin();
break;
case 5: // RRO End
RROEnd();
processingRO = "";
break;
case 6: // Msg
Msg();
break;
case 7:
processingRO = KeyField();
break;
case 8:
MyROID = ROIDField();
break;
case 100: // Text Field - sometimes also XY Plot
Text();
Application.DoEvents();
break;
case 101: // Plot Field
XYPlot();
Application.DoEvents();
break;
case 102: // Image Field
ImageFile();
Application.DoEvents();
break;
case 103: // Multi Begin - Display data for setpoints
Multiple();
break;
case 104: // Multi End
break;
case 0: // nothing was entered in that field
if (IncludeEmptyROFields)
NoInformatEntered();
break;
case 255:
_pdfReportDoc.Add(datatable);
_pdfReportDoc.NewPage();
StartNewDataTable();
showStatBar.BarValue = (int)RO_df.GetFilePointerPosition();
//Console.WriteLine("Record Type: {0} No Operation", iRecType);
//Console.WriteLine("----------------------------------------------");
break;
default: // Problem
StopPrinting = true;
MessageBox.Show(string.Format("Unrecognized record type [{0}]", iRecType), "Error Creating Complete RO Report", MessageBoxButtons.OK, MessageBoxIcon.Error);
break;
}
;
}
}
else
{
StartNewDataTable();
@@ -502,20 +447,22 @@ namespace Volian.Print.Library
// if there is lenght then we are in the mist of processing an RO
string headers = erMsg;
for (int iLoop = 0; iLoop < Hdrs.HdrCnt; iLoop++)
headers += Hdrs.strHdrs[iLoop] + "\n ";
headers += $"{Hdrs.strHdrs[iLoop]}\n ";
if (processingRO.Length > 0)
headers += processingRO;
if (erMsg2 != null && erMsg2.Length > 0)
headers += "\n" + erMsg2;
//MessageBox.Show(headers, erMsg, MessageBoxButtons.OK, MessageBoxIcon.Error);
if (e != null)
_MyLog.Error(headers, e);
else
_MyLog.Error(headers);
PdfOutline outl = new PdfOutline(MyErrorOutline, MyPdfDestPage, processingRO.Length > 0 ? processingRO : "Problem Reading Header");
//DestSample(outl);
}
#pragma warning disable IDE0059 // Unnecessary assignment of a value - for debugging
PdfOutline outl = new PdfOutline(MyErrorOutline, MyPdfDestPage, processingRO.Length > 0 ? processingRO : "Problem Reading Header");
#pragma warning restore IDE0059 // Unnecessary assignment of a value
//DestSample(outl);
}
//For Debugging/Testing
//private void DestSample(PdfOutline outl)
//{
// new PdfOutline(outl, new PdfDestination(PdfDestination.FIT), "FIT");
@@ -531,29 +478,22 @@ namespace Volian.Print.Library
public void AddErrorBookmarks()
{
if (_MyErrorOutline == null) return;
//if (_MyErrorBookMarks.Count == 0) return;
//PdfOutline outline = null;
//foreach (string key in _MyErrorBookMarks.Keys)
//{
// if (outline == null) outline = new PdfOutline(_MyPDFWriter.DirectContent.RootOutline, _MyErrorBookMarks[key], "Errors");
// new PdfOutline(outline, _MyErrorBookMarks[key], key);
//}
string emsg = "A Bookmark grouping named \"Errors\" was added to the PDF.\n\n Click on the RO in this grouping to jump to the report page which will contain an error message.\n\nThe error were also recorded in the PROMS error log.";
MessageBox.Show(emsg, "Errors Found Creating Report", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
public void Multiple()
{
Int16 typ, i, j, nw = 0;
short typ, i, j;
string str, sep;
string buff = "";
int[] width;
LastHeader();
sep = "";
// nw - number of fields
nw = RO_df.ReadInteger16();
// allocate space for widths
width = new int[nw];
// nw - number of fields
short nw = RO_df.ReadInteger16();
// allocate space for widths
width = new int[nw];
// loop through and load field widths and names
for (i = 0; i < nw; i++)
{
@@ -645,7 +585,7 @@ namespace Volian.Print.Library
//Console.WriteLine("Set Header");
// Get the number of header records
Int16 iNewCnt = RO_df.ReadInteger16();
short iNewCnt = RO_df.ReadInteger16();
//Console.WriteLine("Num Header Records: {0}", iNewCnt);
@@ -676,16 +616,11 @@ namespace Volian.Print.Library
bool _LastWasName = false;//B2016-251 Don't change underscore to underline to Name value
public void PushHeader()
{
//if (m_pPrinterOut->Row() > 55)
//// m_pPrinterOut->newpage();
//pdfReportDoc.NewPage();
string pTmp = RO_df.ReadText();
//Console.WriteLine("PH[{0}]", pTmp);
curheaderlen = pTmp.Length;
_LastWasName = (pTmp == "Name");//B2016-251 Don't change underscore to underline to Name value
//Hdrs.strHdrs[Hdrs.HdrCnt] = pTmp;
Hdrs.strHdrs.Add(pTmp);
//Hdrs.repeatCount[Hdrs.HdrCnt] = 2;
Hdrs.repeatCount.Add(2);
Hdrs.HdrCnt++;
Hdrs.printedLastHeader = false;
@@ -704,15 +639,12 @@ namespace Volian.Print.Library
// if the last header was pushed on header list
// print eject the page if the page ran out, and
// print the header with "none".
//if (m_pPrinterOut->Row() > 55)
// m_pPrinterOut->NewPage();
LastHeader();
//m_pPrinterOut->PutLine(0, "none");
//m_pPrinterOut->NewLine(1);
}
// Remove the header
Hdrs.HdrCnt--;
//Hdrs.strHdrs[Hdrs.HdrCnt] = null;
Hdrs.strHdrs.RemoveAt(Hdrs.HdrCnt);
Hdrs.repeatCount.RemoveAt(Hdrs.HdrCnt);
@@ -722,7 +654,6 @@ namespace Volian.Print.Library
public void RROBegin()
{
//m_pPrinterOut->NewPage();
//Console.WriteLine("RRO Begin");
//Console.WriteLine("----------------------------------------------");
// Start of a new RO, print out the headers
@@ -730,12 +661,11 @@ namespace Volian.Print.Library
{
if (!MyDocOutline.ContainsKey(iLoop) || MyDocOutline[iLoop].MyHeader != Hdrs.strHdrs[iLoop])
{
PdfOutline parentOutline = null;
if (iLoop == 0)
PdfOutline parentOutline;
if (iLoop == 0)
parentOutline = MyRootOutline;//_MyPDFWriter.DirectContent.RootOutline;
else
parentOutline = MyDocOutline[iLoop - 1].MyOutline;
//pdfDest = new PdfDestination(PdfDestination.FITH, _MyPDFWriter.DirectContent.PdfDocument.PageSize.Height);
AddOutlineLevel(parentOutline, iLoop, Hdrs.strHdrs[iLoop], MyPdfDestPage);
}
// Change double underscore to spaces in header text
@@ -748,20 +678,13 @@ namespace Volian.Print.Library
{
// FITH was acting strange and shifting towards bottom of the page as the number of pages increased
//Console.WriteLine("Top = {0}, {1}", _Top, _MyPDFWriter.DirectContent.PdfDocument.PageSize.Height);
//return new PdfDestination(PdfDestination.FITH, _Top);//_MyPDFWriter.DirectContent.PdfDocument.PageSize.Height);
return new PdfDestination(PdfDestination.XYZ, 0, _MyPDFWriter.DirectContent.PdfDocument.PageSize.Height, 1.5f);
}
}
public PdfDestination MyPdfDestPage
{
get
{
return new PdfDestination(PdfDestination.FITV,0);
}
}
public PdfDestination MyPdfDestPage => new PdfDestination(PdfDestination.FITV, 0);
private PdfOutline _MyErrorOutline = null;
private PdfOutline _MyErrorOutline = null;
public PdfOutline MyErrorOutline
{
@@ -787,7 +710,6 @@ namespace Volian.Print.Library
return _MyRootOutline;
}
}
private PdfDestination pdfDest = null;
private void AddOutlineLevel(PdfOutline parentOutline, int iLoop, string hdr, PdfDestination pdfDest)
{
if (MyDocOutline.ContainsKey(iLoop))
@@ -798,7 +720,6 @@ namespace Volian.Print.Library
public void RROEnd()
{
//m_pPrinterOut->PageEnd();
// Remove any headers that are left over
//Console.WriteLine("{0} headers cleaned up.", Hdrs.HdrCnt);
//Console.WriteLine("RRO End");
@@ -843,7 +764,7 @@ namespace Volian.Print.Library
public void Text()
{
// Get the lenght of the text string and read it in
Int16 iValue = RO_df.ReadInteger16();
short iValue = RO_df.ReadInteger16();
string szStr = "";
// B2016-247 If size is zero it is an empty string.
if (iValue > 0)
@@ -867,11 +788,9 @@ namespace Volian.Print.Library
if (isXYPlot || (iValue + curheaderlen) > 72 || (szStr.IndexOf('\r') != -1))
{
// If the lenght of the string plus the field title is greater
// If the length of the string plus the field title is greater
// than 72 characters or has a carriage return character in it
// then output the text on multiple lines
//if (m_pPrinterOut->Row() > 55)
// m_pPrinterOut->newpage();
// the header goes on its own line
cell.AddElement(p);
@@ -891,10 +810,6 @@ namespace Volian.Print.Library
datatable.AddCell(cell);
//m_pPrinterOut->SetNumberOfNewLines(0);
//m_pPrinterOut->putline(0, temp);
//if (m_pPrinterOut->Row() + 1 > 55)
// Hdrs.repeatCount[Hdrs.HdrCnt] = 1;
//else
// m_pPrinterOut->newline(1);
}
//Console.WriteLine("Text");
//Console.WriteLine("Value: {0}", iValue);
@@ -906,10 +821,11 @@ namespace Volian.Print.Library
{
// use the key field as the PDF bookbark
string szStr = RO_df.ReadText();
//PdfDestination pdfDest = new PdfDestination(PdfDestination.FITH, _MyPDFWriter.DirectContent.PdfDocument.PageSize.Height);
PdfOutline outl = new PdfOutline(MyDocOutline[Hdrs.HdrCnt - 1].MyOutline, MyPdfDestTop, szStr);
//DestSample(outl);
return szStr;
#pragma warning disable IDE0059 // Unnecessary assignment of a value - For Debugging
PdfOutline outl = new PdfOutline(MyDocOutline[Hdrs.HdrCnt - 1].MyOutline, MyPdfDestTop, szStr);
#pragma warning restore IDE0059 // Unnecessary assignment of a value
//DestSample(outl);
return szStr;
//Console.WriteLine("Key Field");
//Console.WriteLine("Key Text: {0}", szStr);
//Console.WriteLine("----------------------------------------------");
@@ -918,6 +834,7 @@ namespace Volian.Print.Library
{
// use the key field as the PDF bookbark
string szStr = RO_df.ReadText();
//For Dubugging
//PdfDestination pdfDest = new PdfDestination(PdfDestination.FITH, _MyPDFWriter.DirectContent.PdfDocument.PageSize.Height);
//PdfOutline outl = new PdfOutline(MyDocOutline[Hdrs.HdrCnt - 1].MyOutline, MyPdfDestTop, szStr);
//DestSample(outl);
@@ -931,25 +848,26 @@ namespace Volian.Print.Library
public void ImageFile()
{
string fn = RO_df.ReadText();
Int16 ht = RO_df.ReadInteger16();
Int16 wd = RO_df.ReadInteger16();
//m_pPrinterOut->PrintImage(fn, wd, ht);
#pragma warning disable IDE0059 // Unnecessary assignment of a value - for Debugging
short ht = RO_df.ReadInteger16();
short wd = RO_df.ReadInteger16();
#pragma warning restore IDE0059 // Unnecessary assignment of a value
//m_pPrinterOut->PrintImage(fn, wd, ht);
//Console.WriteLine("ImageFile");
//Console.WriteLine("Name: {0}", fn);
//Console.WriteLine("Height: {0}", ht);
//Console.WriteLine("Width: {0}", wd);
//Console.WriteLine("----------------------------------------------");
AddImage(fn);
//Console.WriteLine("ImageFile");
//Console.WriteLine("Name: {0}", fn);
//Console.WriteLine("Height: {0}", ht);
//Console.WriteLine("Width: {0}", wd);
//Console.WriteLine("----------------------------------------------");
AddImage(fn);
}
// Read in the X/Y plot info.
public void XYPlot()
{
// Get the lenght of the text string and read it in
Int16 iValue = RO_df.ReadInteger16();
short iValue = RO_df.ReadInteger16();
string szStr = RO_df.ReadText(iValue);
string temp = szStr;
Chunk chk = LastHeader(); // = new Chunk(m.Value, fnt);
Chunk chk = LastHeader();
Phrase p = new Phrase();
PdfPCell cell = new PdfPCell();
p.Add(chk); // add the header chunk
@@ -997,7 +915,6 @@ namespace Volian.Print.Library
chk = new Chunk(hdrtxt, F10Bold);
Hdrs.printedLastHeader = true;
return chk;
//m_pPrinterOut->LastHeader();
}
}// end CompSumROReport
@@ -1005,9 +922,7 @@ namespace Volian.Print.Library
public class Headers
{
//public string[] strHdrs;
public List<string> strHdrs;
// public int[] repeatCount;
public int HdrCnt;
public List<int> repeatCount;
public bool printedLastHeader;
@@ -1022,8 +937,8 @@ namespace Volian.Print.Library
public class RODataFile
{
FileStream fs = null;
BinaryReader br = null;
readonly FileStream fs = null;
readonly BinaryReader br = null;
public RODataFile(string fname)
{
fs = new FileStream(fname,FileMode.Open);
@@ -1034,16 +949,10 @@ namespace Volian.Print.Library
br.Close();
fs.Close();
}
public long GetFileLength()
{
return fs.Length;
}
public long GetFilePointerPosition()
{
return fs.Position;
}
// Read an integer value from the data file
public Int16 ReadInteger16()
public long GetFileLength() => fs.Length;
public long GetFilePointerPosition() => fs.Position;
// Read an integer value from the data file
public Int16 ReadInteger16()
{
try
{
@@ -1055,18 +964,15 @@ namespace Volian.Print.Library
return -1;
}
}
// Read a text string from the data file and returns it.
// The calling program is responsible for free it
// with the "delete" operator.
// Read a text string from the data file and returns it.
// The calling program is responsible for free it
// with the "delete" operator.
public string ReadText()
{
return ReadText(-1);
}
public string ReadText() => ReadText(-1);
public string ReadText(Int16 i16CharCount)
public string ReadText(Int16 i16CharCount)
{
Int16 i16DataSize;
short i16DataSize;
if (i16CharCount == -1)
i16DataSize = ReadInteger16();
else
@@ -1082,15 +988,14 @@ namespace Volian.Print.Library
for (int i = 0; i < i16DataSize; i++)
str += Convert.ToChar(charbuff[i]).ToString();
return (str);
//return (Encoding.ASCII.GetString(charbuff, 0, i16DataSize)); // this didn't handle line draw chars
}
}
// Search through the file to find the next record
public long NextRecord()
{
Int16 iType;
Int16 RECORD_START = 255;
short iType;
short RECORD_START = 255;
// While not the next record and not end of file get the next meta item
while ((iType = ReadInteger16()) != RECORD_START && iType != -1)
{
@@ -1101,28 +1006,25 @@ namespace Volian.Print.Library
// Get the next meta item and discard the data
public long NextItem()
{
string pTmp;
Int16 iRecType = ReadInteger16();
Int16 iNewCnt;
int iLoop;
switch (iRecType)
short iRecType = ReadInteger16();
short iNewCnt;
int iLoop;
switch (iRecType)
{
case 1: // Set Header
iNewCnt = ReadInteger16();
for (iLoop = 0; iLoop < iNewCnt; iLoop++)
{
ReadInteger16();
pTmp = ReadText();
//delete pTmp;
_ = ReadText();
}
break;
case 2: // Push Header
case 6: // Msg
case 7: // Key Field
case 100: // Text Field
case 101: // Plot Field
pTmp = ReadText();
//delete pTmp;
case 101: // Plot Field
_ = ReadText();
break;
case 3: // Pop Header
case 4: // RRO Begin
@@ -1133,8 +1035,7 @@ namespace Volian.Print.Library
// Do nothing
break;
case 102: // Image Field
pTmp = ReadText();
//delete pTmp;
_ = ReadText();
ReadInteger16();
ReadInteger16();
break;
+17 -39
View File
@@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using LBWordLibrary;
using VEPROMS.CSLA.Library;
using System.Text.RegularExpressions;
@@ -10,12 +8,12 @@ namespace Volian.Print.Library
{
public class ContinuousActionSummary : IDisposable
{
private LBApplicationClass _WordApp;
private LBDocumentClass _WordDoc;
private LBSelection _WordSel;
private readonly LBApplicationClass _WordApp;
private readonly LBDocumentClass _WordDoc;
private readonly LBSelection _WordSel;
private LBTable _WordTbl;
private const string TheQuickBrownFox = "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.";
private VE_Font _pkFont;
private readonly VE_Font _pkFont;
public ContinuousActionSummary()
{
_WordApp = new LBApplicationClass();
@@ -41,7 +39,6 @@ namespace Volian.Print.Library
_WordApp = new LBApplicationClass();
_WordDoc = _WordApp.Documents.Add();
_WordSel = _WordApp.Selection;
//_WordApp.Visible = true;
_pkFont = pkFont;
AddTable();
AddHeader(doingTimeCriticalSummary); // F2022-024 pass flag when creating a Time Critical Action Summary report
@@ -72,11 +69,11 @@ namespace Volian.Print.Library
if (txtPageNum == "") txtPageNum = (pghC.MyParagraph.MyItemInfo.PageNumber + 1).ToString();
AddContinuousAction(NoteCautionTab, GetContActStepText(pghC.MyParagraph.MyItemInfo), doneStr, txtPageNum, 0, 0);
}
string stpTab = pgh.MyParagraph.MyItemInfo.MyTab.CleanText.Trim() + " "; // this is either the High Level step tab or the sub-step tab
string stpTab = $"{pgh.MyParagraph.MyItemInfo.MyTab.CleanText.Trim()} "; // this is either the High Level step tab or the sub-step tab
float preTabLen = 0;
if (pgh.MyParagraph.MyItemInfo.IsNote || pgh.MyParagraph.MyItemInfo.IsCaution) // only the caution and/or note is on the CAS - high level step not selected
{
stpTab = string.Format("{0} ", hlsii.MyTab.Text.Trim()) + " " + stpTab;
stpTab = $"{hlsii.MyTab.Text.Trim()} {stpTab}";
}
else if (!pgh.MyParagraph.MyItemInfo.IsHigh) // if the high level step was not included, adjust the tab for a sub-step/RNO
{
@@ -98,13 +95,13 @@ namespace Volian.Print.Library
prevItemInfo = prevItemInfo.MyParent;
}
if (_FirstLine) // the first of a CAS on the report include the High Level Step tab
sbTabPre.Insert(0, (hlsii != null) ? hlsii.MyTab.Text.Trim() + " " : "");
sbTabPre.Insert(0, (hlsii != null) ? $"{hlsii.MyTab.Text.Trim()} " : "");
tabPre = sbTabPre.ToString();
if (!_FirstLine) // if not the first line we indent the size of high level step tab
preTabLen = GetTextWidth(hlsii.MyTab.Text.Trim() + " ") / 72f;
preTabLen = GetTextWidth($"{hlsii.MyTab.Text.Trim()} ") / 72f;
if (pgh.MyParagraph.MyItemInfo.IsInRNO)
{
stpTab = stpTab.TrimEnd() + "[R] ";
stpTab = $"{stpTab.TrimEnd()}[R] ";
}
stpTab = tabPre + stpTab;
}
@@ -135,7 +132,7 @@ namespace Volian.Print.Library
string stpTab = cpgh.MyParagraph.MyItemInfo.MyTab.CleanText.Trim() + (cpgh.MyParagraph.MyItemInfo.IsInRNO ? "[R] ": " ");
if (cpgh.MyParagraph.MyItemInfo.IsNote || cpgh.MyParagraph.MyItemInfo.IsCaution)
{
stpTab = string.Format("{0} ", cpgh.MyParagraph.MyParent.MyTab.Text.Trim()) + " " + stpTab;
stpTab = $"{string.Format("{0} ", cpgh.MyParagraph.MyParent.MyTab.Text.Trim())} {stpTab}";
}
ItemInfo prevItmInfo = cpgh.MyParagraph.MyItemInfo.MyParent;
// F2026-001 the while loop below will add the sub-step's parent tab if applicable
@@ -154,19 +151,9 @@ namespace Volian.Print.Library
}
}
private string GetContActStepText(ItemInfo myItemInfo)
{
//string conActSumText = "";
//StepConfig sc = myItemInfo.MyConfig as StepConfig;
//if (sc != null && sc.Step_AlternateContActSumText != null)
// conActSumText = sc.Step_AlternateContActSumText;
//if (conActSumText == "")
// conActSumText = myItemInfo.FormattedDisplayText;
//return conActSumText;
return myItemInfo.FormattedDisplayText;
}
private string GetContActStepText(ItemInfo myItemInfo) => myItemInfo.FormattedDisplayText;
private void AddNotesOrCautions(pkParagraph pgh, int level)
private void AddNotesOrCautions(pkParagraph pgh, int level)
{
foreach (pkParagraph cpgh in pgh.MyCautionsAndNotes)
{
@@ -305,7 +292,7 @@ namespace Volian.Print.Library
}
_FirstLine = false;
}
static Regex rgx = new Regex(@"\\(b|ul|up[1-9]|dn0|up0|dn[1-9]|b0|ulnone)( |$|(?=\\))");
static readonly Regex rgx = new Regex(@"\\(b|ul|up[1-9]|dn0|up0|dn[1-9]|b0|ulnone)( |$|(?=\\))");
private void WriteRTF(string text)
{
Match m = rgx.Match(text);
@@ -363,17 +350,8 @@ namespace Volian.Print.Library
_WordSel.ParagraphFormat.Alignment = hAlign;
_WordSel.Cells.VerticalAlignment = vAlign;
}
private void Advance(int count)
{
_WordSel.MoveRight(LBWdUnits.wdCell, count, false);
}
private void Advance()
{
Advance(1);
}
public void Dispose()
{
_WordApp.Quit(false);
}
}
private void Advance(int count) => _WordSel.MoveRight(LBWdUnits.wdCell, count, false);
private void Advance() => Advance(1);
public void Dispose() => _WordApp.Quit(false);
}
}
@@ -0,0 +1,8 @@
// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.
using System.Diagnostics.CodeAnalysis;
[assembly: SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Not modifying Naming Styles")]
+150 -583
View File
@@ -2,12 +2,8 @@ using System;
using System.Collections.Generic;
using System.Text;
using C1.Win.C1FlexGrid;
using System.IO;
using Itenso.Rtf;
using Itenso.Rtf.Parser;
using Itenso.Rtf.Interpreter;
using Itenso.Rtf.Support;
using Volian.Print.Library;
using Volian.Controls.Library;
using iTextSharp.text;
using iTextSharp.text.pdf;
@@ -19,139 +15,37 @@ namespace Volian.Print.Library
#region Settings // RHM20150429 - Table Scrunch
public partial class vlnTable
{
private string _DebugInfo = null; // RHM20150429 - Table Scrunch
public string DebugInfo
{
get { return _DebugInfo; }
set { _DebugInfo = value; }
}
private int _ItemID = 0;
public int ItemID
{
get { return _ItemID; }
set { _ItemID = value; }
}
private bool _ShowDetails = false;
public bool ShowDetails
{
get { return _ShowDetails; }
set { _ShowDetails = value; }
}
private bool _IsTooBig = false;
public bool IsTooBig
{
get { return _IsTooBig; }
set { _IsTooBig = value; }
}
}
public partial class vlnCells
{
private static float YAdjust_HContent = 4; // 4
private float YAdjust_SpacingAfter
{
get
{
return 8-8*MyTable.Adjustment;//0; // 8
}
}
}
public string DebugInfo { get; set; } = null;
public int ItemID { get; set; } = 0;
public bool ShowDetails { get; set; } = false;
public bool IsTooBig { get; set; } = false;
}
public partial class vlnCell
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
public bool ShowDetails
{ get { return MyTable.ShowDetails; } }
private static float YAdjust_h = 0; // 0
private float YAdjust_TextLocation
{
get
{
return 4 - 4 * MyTable.Adjustment; ;//0; // 4
}
}
}
//public partial class vlnTable
//{
// private static float YAdjust_RowTop = 0;//8; // 0
//}
//public partial class vlnCells
//{
// private static float YAdjust_HContent = 4; // 4
// private static float YAdjust_SpacingAfter = 8;//0; // 8
//}
//public partial class vlnCell
//{
// private static float YAdjust_h = 0; // 0
// private static float YAdjust_TextLocation = 4;//0; // 4
//}
#endregion
public bool ShowDetails => MyTable.ShowDetails;
private static readonly float YAdjust_h = 0;
}
#endregion
public partial class vlnTable
{
#region Properties
// HContents: For each row, contains the largest height for all columns in that row.
// Merged cells are accounted for. This is done in vlnCells:SetupCells
private float[] _HContents;// RHM20150525 - Table Scrunch
public float[] HContents
{
get { return _HContents; }
set { _HContents = value; }
}
private float[] _RowTop;
public float[] RowTop
{
get { return _RowTop; }
set { _RowTop = value; }
}
private float[] _ColLeft;
public float[] ColLeft
{
get { return _ColLeft; }
set { _ColLeft = value; }
}
private VlnFlexGrid _MyFlexGrid;
public VlnFlexGrid MyFlexGrid
{
get { return _MyFlexGrid; }
set { _MyFlexGrid = value; }
}
private VlnBorders _MyBorders;
public VlnBorders MyBorders
{
get { return _MyBorders; }
set { _MyBorders = value; }
}
// C2021-004 Table cell shading
private VlnGridCellShading _MyShading;
public VlnGridCellShading MyShading
{
get { return _MyShading; }
set { _MyShading = value; }
}
private iTextSharp.text.pdf.PdfContentByte _MyContentByte;
public iTextSharp.text.pdf.PdfContentByte MyContentByte
{
get { return _MyContentByte; }
set { _MyContentByte = value; }
}
private vlnCells _MyCells;
public vlnCells MyCells
{
get { return _MyCells; }
set { _MyCells = value; }
}
public float Height
{ get
{
return RowTop[RowTop.Length - 1];
} }
public float Width
{ get
{
return ColLeft[ColLeft.Length - 1];
} }
#region Properties
// HContents: For each row, contains the largest height for all columns in that row.
// Merged cells are accounted for. This is done in vlnCells:SetupCells
public float[] HContents { get; set; }
public float[] RowTop { get; set; }
public float[] ColLeft { get; set; }
public VlnFlexGrid MyFlexGrid { get; set; }
public VlnBorders MyBorders { get; set; }
public VlnGridCellShading MyShading { get; set; }
public iTextSharp.text.pdf.PdfContentByte MyContentByte { get; set; }
public vlnCells MyCells { get; set; }
public float Height => RowTop[RowTop.Length - 1];
public float Width => ColLeft[ColLeft.Length - 1];
private static float _XOffset = -1; // This moves the borders with respect to the text
private static float _XOffset = -1; // This moves the borders with respect to the text
public static float XOffset
{
get { return vlnTable._XOffset; }
@@ -186,7 +80,7 @@ namespace Volian.Print.Library
get { return (LineThicknessForThick - LineThicknessForDouble) / 2; }//LineThicknessForThick - 2 * LineThicknessForDouble; }
}
private float _TotalContentHeight = 0;// RHM20150525 - Table Scrunc
// TotalContentHeight - height of just the content of all rows in the table.
public float TotalContentHeight
{
get
@@ -199,29 +93,28 @@ namespace Volian.Print.Library
return _TotalContentHeight;
}
}
public float SpaceAvailable// RHM20150525 - Table Scrunc
{
// SpaceAvailable is the amount of white space there is to work with. It uses the bottom location
// of the table and subtracts how much height the actual contents take, TotalContentHeight. TotalContentHeight
// includes size/height (font size - assumes 12, 6LPI) of text & leading (space between lines)
get { return TotalContentHeight ==0 ? 0 : RowTop[RowTop.Length - 1] - TotalContentHeight; }
}
public float LeadingSpaceAvailable// B2018-085 - Table Scrunch Fix:
{
// LeadingSpaceAvailable is the amount of 'blank' space between lines, this is included in TotalContentHeight.
// 1.5 is difference between 12 and 13.5, 12 is the standard font size, i.e. 6LPI. 13.5 is line leading.
// 1.5/13.5 is amount of space used by leading.
get { return TotalContentHeight == 0 ? 0 : TotalContentHeight * 1.5F/13.5F; }
}
// TooBig is the amount that the grid is over the amount of space on the page. To start (value in TooBig), it is set to
// (height of grid w/ compressed setting if needed + line) - (how much room on page), i.e. negative number if it can fit
private float _TooBig;// RHM20150525 - Table Scrunc
// RHM20150525 - Table Scrunc
// SpaceAvailable is the amount of white space there is to work with. It uses the bottom location
// of the table and subtracts how much height the actual contents take, TotalContentHeight. TotalContentHeight
// includes size/height (font size - assumes 12, 6LPI) of text & leading (space between lines)
public float SpaceAvailable => TotalContentHeight == 0 ? 0 : RowTop[RowTop.Length - 1] - TotalContentHeight;
// B2018-085 - Table Scrunch Fix:
// LeadingSpaceAvailable is the amount of 'blank' space between lines, this is included in TotalContentHeight.
// 1.5 is difference between 12 and 13.5, 12 is the standard font size, i.e. 6LPI. 13.5 is line leading.
// 1.5/13.5 is amount of space used by leading.
public float LeadingSpaceAvailable => TotalContentHeight == 0 ? 0 : TotalContentHeight * 1.5F / 13.5F;
// TooBig is the amount that the grid is over the amount of space on the page. To start (value in TooBig), it is set to
// (height of grid w/ compressed setting if needed + line) - (how much room on page), i.e. negative number if it can fit
private float _TooBig;// RHM20150525 - Table Scrunc
public float TooBig
{
get { return _TooBig; }
set
{
_TooBig = value;
//Debugging
//_Adjustment = Math.Min(1F, (_TooBig / (RowTop.Length - 1)) / 12);
//if (ShowDetails) Console.WriteLine("TooBig\t{0}\t{1}", value, _Adjustment);
//if(ShowDetails) Console.WriteLine("Before RowTop={0}", RowTop[RowTop.Length-1] );
@@ -252,21 +145,10 @@ namespace Volian.Print.Library
//if(ShowDetails) Console.WriteLine("After RowTop={0}", RowTop[RowTop.Length-1] );
}
}
private float _Adjustment = 0;// RHM20150525 - Table Scrunc
public float Adjustment
{
get { return _Adjustment; }
set { _Adjustment = value; }
}
//private float _YAdjust_RowTop = 0;//8; // 0
public float YAdjust_RowTop
{
get
{
return _Adjustment * 12;
}
}
private void DrawRuler(PdfContentByte cb, float x, float yTop, float height)// RHM20150525 - Table Scrunc
public float Adjustment { get; set; } = 0;
public float YAdjust_RowTop => Adjustment * 12;
private void DrawRuler(PdfContentByte cb, float x, float yTop, float height)// RHM20150525 - Table Scrunc
{
VlnSvgPageHelper myPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper;
if (myPageHelper.DebugLayer != null)
@@ -290,8 +172,8 @@ namespace Volian.Print.Library
cb.LineTo(x, y);
cb.Stroke();
}
i = 0;
cb.Stroke();
cb.Stroke();
cb.RestoreState();
cb.EndLayer();
}
@@ -320,17 +202,12 @@ namespace Volian.Print.Library
0, myItemInfo.ItemID, myItemInfo.FormatStepType, myItemInfo.FormatStepData == null ? "NoStepData" : myItemInfo.FormatStepData.Type,
myItemInfo.StepLevel, myItemInfo.ShortPath, Width, XOffset, YOffset);
}
#endregion
private string _Path;
#endregion
public string Path
{
get { return _Path; }
set { _Path = value; }
}
public string Path { get; set; }
#region Constructors
public vlnTable(VlnFlexGrid myFlexGrid, iTextSharp.text.pdf.PdfContentByte myContentByte)
#region Constructors
public vlnTable(VlnFlexGrid myFlexGrid, iTextSharp.text.pdf.PdfContentByte myContentByte)
{
MyFlexGrid = myFlexGrid;
MyContentByte = myContentByte;
@@ -374,7 +251,7 @@ public string Path
string myLPI = myPageHelper.YMultiplier == 1.0F ? ",6LPI" : ",7LPI";
Rtf2Pdf.DrawPdfDebug(myColumnText.Canvas, left-2, top+1, left + Width, top-myPageHelper.YMultiplier *(Height+1),
DebugInfo+", Height= " + (myPageHelper.YMultiplier * Height).ToString() + myLPI, 0);
PdfLayer textLayer = myPageHelper == null ? null : myPageHelper.TextLayer; // RHM20150429 - Table Scrunch
PdfLayer textLayer = myPageHelper?.TextLayer; // RHM20150429 - Table Scrunch
if (textLayer != null) cb.BeginLayer(textLayer);
myPageHelper.AddGap(top, top - Height, left, left + Width);
MyCells.ToPdf(myColumnText, left, top);
@@ -383,6 +260,7 @@ public string Path
ShowRowTops("ToPDF2");
if (ShowDetails) Console.WriteLine("^^^^^^ToPdf============{0}===============", ItemID);
}
//For Debugging
private void ZoomGrid(iTextSharp.text.pdf.ColumnText myColumnText, float left, float top)
{
PdfDestination dest = new PdfDestination(PdfDestination.FITR, left - 4, top - Height - 4, left + Width, top + 4);
@@ -394,58 +272,29 @@ public string Path
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Properties
private VlnFlexGrid _MyFlexGrid;
public VlnFlexGrid MyFlexGrid
{
get { return _MyFlexGrid; }
set { _MyFlexGrid = value; }
}
private vlnTable _MyTable;
public vlnTable MyTable
{
get { return _MyTable; }
set { _MyTable = value; }
}
public bool ShowDetails// RHM20150525 - Table Scrunc
#endregion
#region Properties
public VlnFlexGrid MyFlexGrid { get; set; }
public vlnTable MyTable { get; set; }
public bool ShowDetails// RHM20150525 - Table Scrunc
{ get { return MyTable.ShowDetails; }}
private iTextSharp.text.pdf.PdfContentByte _MyContentByte;
public iTextSharp.text.pdf.PdfContentByte MyContentByte
{
get { return _MyContentByte; }
set { _MyContentByte = value; }
}
#endregion
#region Constructors
public vlnCells(vlnTable myTable, VlnFlexGrid myFlexGrid, iTextSharp.text.pdf.PdfContentByte myContentByte)
public iTextSharp.text.pdf.PdfContentByte MyContentByte { get; set; }
#endregion
#region Constructors
public vlnCells(vlnTable myTable, VlnFlexGrid myFlexGrid, iTextSharp.text.pdf.PdfContentByte myContentByte)
{
MyTable = myTable;
MyFlexGrid = myFlexGrid;
MyContentByte = myContentByte;
SetupCells();
foreach(vlnCell cell in this)
{
myTable.MyShading = VlnGridCellShading.Get(myFlexGrid.MyShading.ConvertToString()); // C2021-004 Table Cell Shading
myTable.MyBorders = VlnBorders.Get(myFlexGrid.MyBorders.ConvertToString());
GridLinePattern glp = cell.AboveLeftSide;
glp = cell.AboveRightSide;
glp = cell.BelowLeftSide;
glp = cell.BelowRightSide;
glp = cell.RightOfBottomSide;
glp = cell.RightOfTopSide;
object ta = cell.TextAlign;
}
myTable.MyShading = VlnGridCellShading.Get(myFlexGrid.MyShading.ConvertToString()); // C2021-004 Table Cell Shading
myTable.MyBorders = VlnBorders.Get(myFlexGrid.MyBorders.ConvertToString());
}
#endregion
private float _MyLeading = 13.5F; // B2018-085 AEP and APP worked with 13.5
public float MyLeading
{
get { return _MyLeading; }
set { _MyLeading = value; }
}
#region Private Methods
private void SetupCells()
#endregion
public float MyLeading { get; set; } = 13.5F;
#region Private Methods
private void SetupCells()
{
// Create a ColumnText to determine the cell heights
iTextSharp.text.pdf.ColumnText myColumnText1 = new iTextSharp.text.pdf.ColumnText(MyContentByte);
@@ -526,9 +375,9 @@ public string Path
TrimNewlines(myPara); // RHM20150429 - Table Scrunch
myColumnText1.AddElement(myPara);
float posBefore = myColumnText1.YLine; // position is y of top of paragraph since paragraph was just added
int status = myColumnText1.Go(true); // 'puts out' text for info only
float posAfter = myColumnText1.YLine; // posAfter is y of bottom of paragraph, really y top of line below this
float posBefore = myColumnText1.YLine; // position is y of top of paragraph since paragraph was just added
_ = myColumnText1.Go(true); // 'puts out' text for info only
float posAfter = myColumnText1.YLine; // posAfter is y of bottom of paragraph, really y top of line below this
float hContent = 4 + posBefore - posAfter;
// TableScrunch Phase 4: sets content height, uses the size derived from iTextsharp putting out text
@@ -566,6 +415,7 @@ public string Path
}
}
}
//For Debugging:
// This summarizes the Content heights per row
//int i=0;
//foreach (float h in MyTable.HContents)
@@ -580,41 +430,6 @@ public string Path
return total;
}
// B2017-105 if a symbol character was set to a bigger font size, then the positioning of the larger symbol character was printing too high on the line
// found with Wolf Creek use of the empty box symbol
//private float BiggestFontSize(Paragraph myPara)
//{
// float fontSize = 12;
// foreach (Chunk ck in myPara.Chunks)
// {
// fontSize = Math.Max(fontSize, ck.Font.Size);
// if (ck.Font.Size > 12)
// {
// ck.SetTextRise(-2f);
// //_MyLog.WarnFormat("set text rise");
// }
// }
// return fontSize;
//}
// B2017-233, B2017-234 needed to get the smallest font size to help decide if a vertical adjustment of the text is needed in a table cell
//private float SmallestFontSize(Paragraph myPara)
//{
// float fontSize = 30;
// foreach (Chunk ck in myPara.Chunks)
// {
// fontSize = Math.Min(fontSize, ck.Font.Size);
// }
// return fontSize;
//}
//private void ShowChunks(System.Collections.ArrayList chunks) // RHM20150429 - Table Scrunch
//{
// StringBuilder sb = new StringBuilder();
// foreach (Chunk chk in chunks)
// {
// sb.Append(BuildChunks(chk.Content));
// }
// //if (ShowDetails) Console.WriteLine("Chunks = '{0}'", sb.ToString());
//}
private string BuildChunks(string str)
{
StringBuilder sb = new StringBuilder();
@@ -625,44 +440,25 @@ public string Path
else
sb.Append(c);
}
return "{" + sb.ToString() + "}";
return $"{{{sb}}}";
}
private void TrimNewlines(Paragraph myPara)
{
while (myPara.Count > 0 && ParaEndsWithNewLine(myPara))
myPara.RemoveAt(myPara.Count - 1);
}
private bool ParaEndsWithNewLine(Paragraph myPara)
{
Chunk chk = myPara[myPara.Count - 1] as Chunk;
if (chk == null) return false;
if (chk.Content == "\n") return true;
return false;
}
public class VlnSplitCharacter : ISplitCharacter
{
public bool IsSplitCharacter(int start, int current, int end, char[] cc, PdfChunk[] ck)
{
return (cc[current] == ' ');
}
public bool IsSplitCharacter(char c)
{
return (c == ' ');
}
}
public static VlnSplitCharacter mySplitter = new VlnSplitCharacter();
internal static void FixHyphens(Paragraph myPara, vlnTable myTable)
private bool ParaEndsWithNewLine(Paragraph myPara) => myPara[myPara.Count - 1] is Chunk chk && chk.Content == "\n";
internal static void FixHyphens(Paragraph myPara, vlnTable myTable)
{
// Find chunk with hardhyphen
// If a hard hyphen is found, the remove it and add a dash (keyboard minus sign) to the beginning
// of the text that follows it.
int hype=-1;
Font fnt = null;
while ((hype = GetHyphen(myPara)) > -1)
while ((hype = GetHyphen(myPara)) > -1)
{
fnt = null;
if (hype > 0)
Font fnt = null;
if (hype > 0)
{
Chunk chk1 = (Chunk)myPara[hype - 1];
if (hype > 1 && chk1.Content.Equals("\n"))
@@ -755,11 +551,10 @@ public string Path
// If a backslash symbold is found, the remove it and add a backslash (keyboard char) to the beginning
// of the text that follows it.
int bckSlsh = -1;
Font fnt = null;
while ((bckSlsh = GetBackslash(myPara)) > -1)
while ((bckSlsh = GetBackslash(myPara)) > -1)
{
fnt = null;
if (bckSlsh > 0)
Font fnt = null;
if (bckSlsh > 0)
{
Chunk chk1 = (Chunk)myPara[bckSlsh - 1];
if (bckSlsh > 1 && chk1.Content.Equals("\n"))
@@ -842,23 +637,17 @@ public string Path
public static float CalculateHangingIndent(string rtf)
{
float chkW = 0;
// **** This is intened to be a temporary fix for V.C.Summer ****
// Two procedures would not print: A-2 SAG in Summer's SAMG set, and SAG-3 in Summer's PWOG DAMG set.
// These procedures have tables with hanging indents and use the Letter Gothic Tall font.
// It appears that the font information for the hanging indent character is not included in the RTF
// for those table cells.
// This piece of code checks for the existance of a font definition of \f1 which is need for the \u9999? indent character
// If the a font definition of \f1 is not found then the indent character is removed. This will allow the procedure to print
// but the text in that table cell will not be indented. - jsj 10/10/2014
//IRtfDocument rtfDoc2 = RtfInterpreterTool.BuildDoc(rtf.Replace(@"\'05", @"\f1 \u9999? \f0 "));
IRtfDocument rtfDoc2 = null;
//if (rtf.Contains(@"\f1\fnil\fcharset0 "))
// rtfDoc2 = RtfInterpreterTool.BuildDoc(rtf.Replace(@"\'05", @"\f1 \u9999? \f0 "));
//else
//{
// first add the symbol font and then surround the indent as above.
rtfDoc2 = RtfInterpreterTool.BuildDoc(rtf.Replace(@"\'05", @"\par\u9999?\par"));
//}
// **** This is intened to be a temporary fix for V.C.Summer ****
// Two procedures would not print: A-2 SAG in Summer's SAMG set, and SAG-3 in Summer's PWOG DAMG set.
// These procedures have tables with hanging indents and use the Letter Gothic Tall font.
// It appears that the font information for the hanging indent character is not included in the RTF
// for those table cells.
// This piece of code checks for the existance of a font definition of \f1 which is need for the \u9999? indent character
// If the a font definition of \f1 is not found then the indent character is removed. This will allow the procedure to print
// but the text in that table cell will not be indented. - jsj 10/10/2014
// add the symbol font and then surround the indent.
//IRtfDocument rtfDoc2 = RtfInterpreterTool.BuildDoc(rtf.Replace(@"\'05", @"\f1 \u9999? \f0 "));
IRtfDocument rtfDoc2 = RtfInterpreterTool.BuildDoc(rtf.Replace(@"\'05", @"\par\u9999?\par"));
Rtf2iTextSharp rtf2IText2 = new Rtf2iTextSharp(rtfDoc2);
iTextSharp.text.Paragraph para2 = rtf2IText2.Convert();
@@ -883,7 +672,7 @@ public string Path
return chkW;
}
private static StepRTB _StatRTB = new StepRTB();
private static readonly StepRTB _StatRTB = new StepRTB();
private string PreProcessRTF(float w, string str)
{
_StatRTB.Text = string.Empty;
@@ -912,25 +701,7 @@ public string Path
_StatRTB.Text = str;
_StatRTB.SelectAll();
_StatRTB.SelectionColor = PrintOverride.OverrideTextColor(System.Drawing.Color.Black);
str = _StatRTB.Rtf;
// RHM 20180607 The following lines calculated line spacing but it did not give consistent values
//System.Drawing.Point location0 = _StatRTB.GetPositionFromCharIndex(0);
//int ii = 1;
//System.Drawing.Point locnext = location0;
//while (ii < 1000 && (locnext = _StatRTB.GetPositionFromCharIndex(ii)).Y == location0.Y)
// ii++;
//if (ii < 1000)
//{
// myLeading = (locnext.Y - location0.Y) * 72.0F / 96.0F;
// Console.WriteLine("{0} - {1}", _StatRTB.Font, myLeading);
//}
//else
// myLeading = 12.0F;
// myLeading = 13.5F; // RHM 20180607 This worked for AEP
// RHM 20180607 The following did not work
//RTBAPI.ParaFormatTwo pft = RTBAPI.GetParaFormat(_StatRTB);
//myLeading = Math.Max(12.0F, pft.dyLineSpacing);
return str;
return _StatRTB.Rtf;
}
private iTextSharp.text.Paragraph RtfToParagraph(string rtf, iTextSharp.text.Font mySymFont,int r, int c)
{
@@ -940,10 +711,11 @@ public string Path
rtf = rtf.Replace(@"\_", "-").Replace(@"\u8209?", "-");
rtf = FixRTFToPrint(rtf, r, c);
IRtfDocument rtfDoc = RtfInterpreterTool.BuildDoc(rtf);
Rtf2iTextSharp rtf2IText = new Rtf2iTextSharp(rtfDoc);
rtf2IText.DefaultFont = mySymFont;
iTextSharp.text.Paragraph para = rtf2IText.Convert();
//para.SetLeading(MyLeading , 0);// RHM 20180607 Not Needed - performed in SetupCells
Rtf2iTextSharp rtf2IText = new Rtf2iTextSharp(rtfDoc)
{
DefaultFont = mySymFont
};
iTextSharp.text.Paragraph para = rtf2IText.Convert();
return para;
}
// The text font used in FixRTFToPrint for grid
@@ -1011,7 +783,6 @@ public string Path
// follow through in fixing an Out of Window Handles bug, use new function to see if
// we can retrieve the font from a dictionary instead a doing a New and using another
// window handle B2017-117
//rtb.SelectionFont = new System.Drawing.Font(DefaultFont, fnt.Style);
rtb.SelectionFont = VE_Font.GetWinSysFont(DefaultFont, fnt.Style);
changed = true;
}
@@ -1027,8 +798,7 @@ public string Path
{
//use bolding underline italics from local font
System.Drawing.Font fnt = rtb.SelectionFont;
//System.Drawing.Font fntw = new System.Drawing.Font((rc.Family != null) ? rc.Family : fnt.FontFamily.Name, (rc.Size != null) ? (float)rc.Size : fnt.Size, (rc.Style != null) ? (System.Drawing.FontStyle)rc.Style : fnt.Style);
System.Drawing.Font fntw = VE_Font.GetWinSysFont((rc.Family != null) ? rc.Family : fnt.FontFamily.Name, (rc.Size != null) ? (float)rc.Size : fnt.Size, (rc.Style != null) ? (System.Drawing.FontStyle)rc.Style : fnt.Style);
System.Drawing.Font fntw = VE_Font.GetWinSysFont(rc.Family ?? fnt.FontFamily.Name, (rc.Size != null) ? (float)rc.Size : fnt.Size, (rc.Style != null) ? (System.Drawing.FontStyle)rc.Style : fnt.Style);
rtb.SelectionFont = fntw;
if (rc.Replace != null)
{
@@ -1047,7 +817,6 @@ public string Path
}
return rtf;
}
private static float _SixLinesPerInch = 12; // twips
#endregion
#region Public Methods
// C2021-005 Get the largest font size being used.
@@ -1116,60 +885,20 @@ public string Path
}
public partial class vlnCell // RHM20150429 - Table Scrunch
{
#region Properties
private vlnTable _MyTable;
public vlnTable MyTable
{
get { return _MyTable; }
set { _MyTable = value; }
}
public VlnBorders MyBorders
{
get { return _MyTable.MyBorders; }
}
private int _r1;
public int r1
{
get { return _r1; }
set { _r1 = value; }
}
private int _c1;
public int c1
{
get { return _c1; }
set { _c1 = value; }
}
private int _r2;
public int r2
{
get { return _r2; }
set { _r2 = value; }
}
private int _c2;
public int c2
{
get { return _c2; }
set { _c2 = value; }
}
private iTextSharp.text.Paragraph _MyPara;
public iTextSharp.text.Paragraph MyPara
{
get { return _MyPara; }
set { _MyPara = value; }
}
private float _HContent;
public float HContent
{
get { return _HContent; }
set { _HContent = value; }
}
public VlnGridCellShading MyShading
{
get { return _MyTable.MyShading; }
}
#endregion
#region Line Pattern Diagram
/*
#region Properties
public vlnTable MyTable { get; set; }
public VlnBorders MyBorders => MyTable.MyBorders;
public int r1 { get; set; }
public int c1 { get; set; }
public int r2 { get; set; }
public int c2 { get; set; }
public iTextSharp.text.Paragraph MyPara { get; set; }
public float HContent { get; set; }
public VlnGridCellShading MyShading => MyTable.MyShading;
#endregion
#region Line Pattern Diagram
/*
The diagram below identifies the various border names for the cell in the center
|-AboveLeftSide |-AboveRightSide
@@ -1192,9 +921,9 @@ public string Path
|-BelowLeftSide |-BelowRightSide
*/
#endregion
#region Horizontal Line Patterns
private GridLinePattern _TopSide = GridLinePattern.Unknown;
#endregion
#region Horizontal Line Patterns
private GridLinePattern _TopSide = GridLinePattern.Unknown;
public GridLinePattern TopSide
{
get
@@ -1408,27 +1137,27 @@ public string Path
return _AboveLeftSide;
}
}
#endregion
#region Static Properties
private static float XOffset { get { return vlnTable.XOffset; } }
private static float YOffset { get { return vlnTable.YOffset; } }
private static float LineThicknessForThin { get { return vlnTable.LineThicknessForThin; } }
private static float LineThicknessForThick { get { return vlnTable.LineThicknessForThick; } }
private static float LineThicknessForDouble { get { return vlnTable.LineThicknessForDouble; } }
private static float DoubleLineOffset { get { return vlnTable.DoubleLineOffset; } }
#endregion
#region Static Properties
private static float XOffset => vlnTable.XOffset;
private static float YOffset => vlnTable.YOffset;
private static float LineThicknessForThin => vlnTable.LineThicknessForThin;
private static float LineThicknessForThick => vlnTable.LineThicknessForThick;
private static float LineThicknessForDouble => vlnTable.LineThicknessForDouble;
private static float DoubleLineOffset => vlnTable.DoubleLineOffset;
// adjustments for line intersections:
private static float ThickOverDouble { get { return ((2 * DoubleLineOffset) + LineThicknessForDouble - LineThicknessForThick) / 2; } }
private static float ThickUnderDouble { get { return DoubleLineOffset + (LineThicknessForThick - LineThicknessForDouble) / 2; } }
private static float ThickOverThin { get { return (LineThicknessForThin - LineThicknessForThick) / 2; } }
private static float ThinOverThick { get { return (LineThicknessForThick - LineThicknessForThin) / 2; } }
private static float ThinUnderDouble { get { return DoubleLineOffset + (LineThicknessForThin - LineThicknessForDouble) / 2; } }
private static float ThinOverDouble { get { return (DoubleLineOffset + LineThicknessForThin - LineThicknessForDouble) / 2; } }
private static float DoubleUnderThin { get { return (LineThicknessForThin - LineThicknessForDouble) / 2; } }
private static float DoubleUnderThick { get { return (LineThicknessForThick - LineThicknessForDouble) / 2; } }
#endregion
#region Constructors
public vlnCell(int r1, int c1, int r2, int c2, vlnTable myTable, iTextSharp.text.Paragraph myPara, float hContent)
// adjustments for line intersections:
private static float ThickOverDouble => ((2 * DoubleLineOffset) + LineThicknessForDouble - LineThicknessForThick) / 2;
private static float ThickUnderDouble => DoubleLineOffset + (LineThicknessForThick - LineThicknessForDouble) / 2;
private static float ThickOverThin => (LineThicknessForThin - LineThicknessForThick) / 2;
private static float ThinOverThick => (LineThicknessForThick - LineThicknessForThin) / 2;
private static float ThinUnderDouble => DoubleLineOffset + (LineThicknessForThin - LineThicknessForDouble) / 2;
private static float ThinOverDouble => (DoubleLineOffset + LineThicknessForThin - LineThicknessForDouble) / 2;
private static float DoubleUnderThin => (LineThicknessForThin - LineThicknessForDouble) / 2;
private static float DoubleUnderThick => (LineThicknessForThick - LineThicknessForDouble) / 2;
#endregion
#region Constructors
public vlnCell(int r1, int c1, int r2, int c2, vlnTable myTable, iTextSharp.text.Paragraph myPara, float hContent)
{
this.r1 = r1;
this.c1 = c1;
@@ -1438,19 +1167,14 @@ public string Path
MyPara = myPara;
HContent = hContent;
}
#endregion
#region Public Methods
public override string ToString()
{
return string.Format("{0}:{1}", r1, c1);
}
// B2018-003 - RHM 20180319 Add
public void PdfDebug(iTextSharp.text.pdf.ColumnText myColumnText, float x, float bottom, float right, float y, string debugText, float yDescent)
#endregion
#region Public Methods
public override string ToString() => string.Format("{0}:{1}", r1, c1);
public void PdfDebug(iTextSharp.text.pdf.ColumnText myColumnText, float x, float bottom, float right, float y, string debugText, float yDescent)
{
PdfContentByte cb = myColumnText.Canvas;
VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper;
PdfLayer debugLayer = _MyPageHelper == null ? null : _MyPageHelper.DebugLayer;
if (debugLayer == null) return;
PdfLayer debugLayer = !(cb.PdfWriter.PageEvent is VlnSvgPageHelper _MyPageHelper) ? null : _MyPageHelper.DebugLayer;
if (debugLayer == null) return;
System.Drawing.Color sysColor = PrintOverride.OverrideDebugColor(System.Drawing.Color.Gray);
cb.SaveState();
cb.BeginLayer(debugLayer);
@@ -1481,7 +1205,6 @@ public string Path
cb.EndLayer();
cb.RestoreState();
}
//RHM 20180319 End of Add
// B2021-137 Added doShading parameter
// We call this twice. The first time to print the shading the second time to print the borders and text
public void ToPdf(iTextSharp.text.pdf.ColumnText myColumnText, float left, float top, int topPlacementAdjust, bool doShading)
@@ -1518,7 +1241,6 @@ public string Path
// B2019-093 missing table cell text when printing South Texas FSG-20 step 1
// Added two more to the last parameter of SetSimplColun (it's the ury value - upper y value)
// this will have the cell text print a little more toward the top of the cell
//myColumnText1.SetSimpleColumn(1 + left + x, top - y - h, left + x + w - 2, 3 + top - y - hAdjust - adjustTextLocation); // 2 == Default Padding
// B2019-109 Adjusted width of cell to match edit cell
// B2020-034 - use the passed in topPlacementAdjust value which is set based on the font size.
myColumnText1.SetSimpleColumn(.5F + left + x, top - y - h, left + x + w - 1.5F, topPlacementAdjust + top - y - hAdjust - adjustTextLocation); // 2 == Default Padding
@@ -1566,7 +1288,6 @@ public string Path
int cellStatus = myColumnText1.Go(); // B2019-109 Add to Error Log if cell too small
if (cellStatus != 1)
{
//System.Windows.Forms.MessageBox.Show("Cell width too narrow \r\n" + MyTable.Path, "Narrow Cell", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
_MyLog.WarnFormat("\r\n=-=-=-= Cell Width too narrow, text is wrapping ItemID={0} Location={1}, Row={2}, Col={3}, Status={4}",MyTable.ItemID, MyTable.Path, r1, c1, cellStatus);
}
float posAfter = myColumnText1.YLine; // RHM20150429 - Table Scrunch
@@ -1606,7 +1327,6 @@ public string Path
}
return sb.ToString();
}
private static float _SixLinesPerInch = 12; // twips
public bool IsRangeStyleNull = false;
private TextAlignEnum? _TextAlign = null;
public TextAlignEnum? TextAlign
@@ -1635,7 +1355,6 @@ public string Path
private float VeritcalTextAlignment(float h, float mult)
{
float hAdjust = 0;
//CellRange cr = MyTable.MyFlexGrid.GetCellRange(r1, c1, r2, c2);
if (!IsRangeStyleNull)
{
switch (TextAlign)
@@ -1913,28 +1632,10 @@ public string Path
else if (linePattern == GridLinePattern.Dashed)
cb.SetLineDash(4, 4, 0);
}
private static void SetLineColor(PdfContentByte cb, int row, int col, string side)
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping row and col for Debugging")]
private static void SetLineColor(PdfContentByte cb, int row, int col, string side)
{
iTextSharp.text.Color lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Black));
//switch (side)
//{
// case "Top":
// if (col == 0) lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Blue));
// else lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Cyan));
// break;
// case "Left":
// if (row == 0) lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Red));
// else lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Magenta));
// break;
// case "Bottom":
// if (col == 0) lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Green));
// else lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Cyan));
// break;
// case "Right":
// if (row == 0) lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Orange));
// else lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Magenta));
// break;
//}
cb.SetColorStroke(lineColor);
}
private static void InitializeLineStyle(PdfContentByte cb)
@@ -1946,9 +1647,11 @@ public string Path
#region Debug Methods
private static void SetOpacity(PdfContentByte cb, float opacity)
{
PdfGState gs = new PdfGState();
gs.StrokeOpacity = opacity;
cb.SetGState(gs);
PdfGState gs = new PdfGState
{
StrokeOpacity = opacity
};
cb.SetGState(gs);
}
private static void ZoomToCell(iTextSharp.text.pdf.ColumnText myColumnText, float xLeft, float yTop, float xRight, float yBottom)
{
@@ -1956,141 +1659,5 @@ public string Path
myColumnText.Canvas.SetAction(PdfAction.GotoLocalPage(myColumnText.Canvas.PdfWriter.CurrentPageNumber, dest, myColumnText.Canvas.PdfWriter), xLeft, yBottom, xRight, yTop);
}
#endregion
#region Old Border Methods
//private void DrawLeftLine(PdfContentByte cb, float xLeft, float yTop, float yBottom)
//{
// if (c1 == 0 && LineLeft != GridLinePattern.None)
// {
// InitializeLineStyle(cb);
// SetLineColor(cb, r1, c1, "Left");
// if (LineLeft == GridLinePattern.Double)
// {
// //Left Line
// float dyTop = DoubleIntersectionLeft(LineTopLeft, LineTop, LineLeftAbove);
// float dyBottom = -DoubleIntersectionRight(LineBottom, LineBottomLeft, LineLeftBelow);
// DrawLine(cb, LineThicknessForDouble, xLeft - DoubleLineOffset, yTop + dyTop, xLeft - DoubleLineOffset, yBottom + dyBottom);
// //Right Line
// dyTop = DoubleIntersectionRight(LineTopLeft, LineTop, LineLeftAbove);
// dyBottom = -DoubleIntersectionLeft(LineBottom, LineBottomLeft, LineLeftBelow);
// DrawLine(cb, LineThicknessForDouble, xLeft + DoubleLineOffset, yTop + dyTop, xLeft + DoubleLineOffset, yBottom + dyBottom);
// }
// else if (LineLeft != GridLinePattern.Thick)
// {
// SetLinePattern(cb, LineLeft);
// float dyTop = ThinIntersection(LineTopLeft, LineTop, LineLeftAbove);
// float dyBottom = -ThinIntersection(LineBottom, LineBottomLeft, LineLeftBelow);
// DrawLine(cb, LineThicknessForThin, xLeft, yTop + dyTop, xLeft, yBottom + dyBottom);
// }
// else
// {
// float dyTop = ThickIntersection(LineTopLeft, LineTop, LineLeftAbove);
// float dyBottom = -ThickIntersection(LineBottom, LineBottomLeft, LineLeftBelow);
// DrawLine(cb, LineThicknessForThick, xLeft, yTop + dyTop, xLeft, yBottom + dyBottom);
// }
// cb.Stroke();
// }
//}
//private void DrawRightLine(PdfContentByte cb, float xRight, float yTop, float yBottom)
//{
// if (LineRight != GridLinePattern.None)
// {
// InitializeLineStyle(cb);
// SetLineColor(cb, r1, c1, "Right");
// if (LineRight == GridLinePattern.Double)
// {
// //Left Line
// float dyTop = DoubleIntersectionLeft(LineTop, LineTopRight, LineRightAbove);
// float dyBottom = -DoubleIntersectionRight(LineBottomRight, LineBottom, LineRightBelow);
// DrawLine(cb, LineThicknessForDouble, xRight - DoubleLineOffset, yTop + dyTop, xRight - DoubleLineOffset, yBottom + dyBottom);
// //Right Line
// dyTop = DoubleIntersectionRight(LineTop, LineTopRight, LineRightAbove);
// dyBottom = -DoubleIntersectionLeft(LineBottomRight, LineBottom, LineRightBelow);
// DrawLine(cb, LineThicknessForDouble, xRight + DoubleLineOffset, yTop + dyTop, xRight + DoubleLineOffset, yBottom + dyBottom);
// }
// else if (LineRight != GridLinePattern.Thick)
// {
// float dyTop = ThinIntersection(LineTop, LineTopRight, LineRightAbove);
// float dyBottom = -ThinIntersection(LineBottomRight, LineBottom, LineRightBelow);
// SetLinePattern(cb, LineRight);
// DrawLine(cb, LineThicknessForThin, xRight, yTop + dyTop, xRight, yBottom + dyBottom);
// }
// else
// {
// float dyTop = ThickIntersection(LineTop, LineTopRight, LineRightAbove);
// float dyBottom = -ThickIntersection(LineBottomRight, LineBottom, LineRightBelow);
// DrawLine(cb, LineThicknessForThick, xRight, yTop + dyTop, xRight, yBottom + dyBottom);
// }
// cb.Stroke();
// }
//}
//private void DrawTopLine(PdfContentByte cb, float xLeft, float xRight, float yTop)
//{
// if (r1 == 0 && TopSide != GridLinePattern.None)
// {
// InitializeLineStyle(cb);
// SetLineColor(cb, r1, c1, "Top");
// if (TopSide == GridLinePattern.Double)
// {
// // Top Line
// float dxLeft = -DoubleIntersectionRight(LeftSide, AboveLeftSide, LeftOfTopSide);
// float dxRight = DoubleIntersectionLeft(AboveRightSide, RightSide, RightOfTopSide);
// DrawLine(cb, LineThicknessForDouble, xLeft + dxLeft, yTop + DoubleLineOffset, xRight + dxRight, yTop + DoubleLineOffset);
// // Bottom Line
// dxLeft = -DoubleIntersectionLeft(LeftSide, AboveLeftSide, LeftOfTopSide);
// dxRight = DoubleIntersectionRight(AboveRightSide, RightSide, RightOfTopSide);
// DrawLine(cb, LineThicknessForDouble, xLeft + dxLeft, yTop - DoubleLineOffset, xRight + dxRight, yTop - DoubleLineOffset);
// }
// else if (TopSide != GridLinePattern.Thick)
// {
// SetLinePattern(cb, TopSide);
// float dxLeft = -ThinIntersection(LeftSide, AboveLeftSide, LeftOfTopSide);
// float dxRight = ThinIntersection(AboveRightSide, RightSide, RightOfTopSide);
// DrawLine(cb, LineThicknessForThin, xLeft + dxLeft, yTop, xRight + dxRight, yTop);
// }
// else
// {
// float dxLeft = -ThickIntersection(LeftSide, AboveLeftSide, LeftOfTopSide);
// float dxRight = ThickIntersection(AboveRightSide, RightSide, RightOfTopSide);
// if (c1 == 0)
// Console.WriteLine("'{0}','{1}','{2}',{3},{4}", LeftSide, AboveLeftSide, LeftOfTopSide, dxLeft, ThickOverThin);
// DrawLine(cb, LineThicknessForThick, xLeft + dxLeft, yTop, xRight + dxRight, yTop);
// }
// cb.Stroke();
// }
//}
//private void DrawBottomLine(PdfContentByte cb, float xLeft, float xRight, float yBottom)
//{
// if (BottomSide != GridLinePattern.None)
// {
// InitializeLineStyle(cb);
// SetLineColor(cb, r1, c1, "Bottom");
// if (BottomSide == GridLinePattern.Double)
// {
// // Top Line
// float dxLeft = -DoubleIntersectionRight(BelowLeftSide, LeftSide, LeftOfBottomSide);
// float dxRight = DoubleIntersectionLeft(RightSide, BelowRightSide, RightOfBottomSide);
// DrawLine(cb, LineThicknessForDouble, xLeft + dxLeft, yBottom + DoubleLineOffset, xRight + dxRight, yBottom + DoubleLineOffset);// Top Line
// // Bottom Line
// dxLeft = -DoubleIntersectionLeft(BelowLeftSide, LeftSide, LeftOfBottomSide);
// dxRight = DoubleIntersectionRight(RightSide, BelowRightSide, RightOfBottomSide);
// DrawLine(cb, LineThicknessForDouble, xLeft + dxLeft, yBottom - DoubleLineOffset, xRight + dxRight, yBottom - DoubleLineOffset);//Bottom Line
// }
// else if (BottomSide != GridLinePattern.Thick) // Bottom line is thin. Determine if intersecting with double:
// {
// SetLinePattern(cb, BottomSide);
// float dxLeft = -ThinIntersection(BelowLeftSide, LeftSide, LeftOfBottomSide);
// float dxRight = ThinIntersection(RightSide, BelowRightSide, RightOfBottomSide);
// DrawLine(cb, LineThicknessForThin, xLeft + dxLeft, yBottom, xRight + dxRight, yBottom);
// }
// else
// {
// float dxLeft = -ThickIntersection(BelowLeftSide, LeftSide, LeftOfBottomSide);
// float dxRight = ThickIntersection(RightSide, BelowRightSide, RightOfBottomSide);
// DrawLine(cb, LineThicknessForThick, xLeft + dxLeft, yBottom, xRight + dxRight, yBottom);
// }
// cb.Stroke();
// }
//}
#endregion
}
}
+24 -62
View File
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Windows.Forms;
@@ -14,34 +13,15 @@ namespace Volian.Print.Library
{
public class MergedPdfProc
{
private string _Title;
public string Title
public string Title { get; // used for pdf outline
set; }
public int PageCount { get; set; }
public string PdfFileName { get; set; }
public bool FirstPageNoPageNum { get; set; } = false;
public MergedPdfProc(string title, string pfname)
{
get { return _Title; } // used for pdf outline
set { _Title = value; }
}
private int _PageCount; // number of pages in the particular pdf, to aid in determining total page count for merged pdf
public int PageCount
{
get { return _PageCount; }
set { _PageCount = value; }
}
private string _PdfFileName; // used for finding the procedure's pdf file to merge
public string PdfFileName
{
get { return _PdfFileName; }
set { _PdfFileName = value; }
}
private bool _FirstPageNoPageNum = false;
public bool FirstPageNoPageNum
{
get { return _FirstPageNoPageNum; }
set { _FirstPageNoPageNum = value; }
}
public MergedPdfProc(string title, string pfname)
{
_Title = title;
_PdfFileName = pfname;
Title = title;
PdfFileName = pfname;
}
}
// this class will manage the data & do subsequent merging of pdf files. It is used if the user
@@ -49,25 +29,11 @@ namespace Volian.Print.Library
public class MergedPdf
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private List<MergedPdfProc> _mergedPdfs = null; // This list has all procedure pdfs that will be included in the merged file.
public List<MergedPdfProc> MergedPdfs
{
get { return _mergedPdfs; }
set { _mergedPdfs = value; }
}
string _mergedFileName = null; // this is the name to be given the merged file
public string MergedFileName
{
get { return _mergedFileName; }
set { _mergedFileName = value; }
}
private string _folder; // this is folder to create the merged file in
public string Folder
{
get { return _folder; }
set { _folder = value; }
}
private DocVersionInfo _docVersionInfo;
public List<MergedPdfProc> MergedPdfs { get; set; } = null;
public string MergedFileName { get; set; } = null;
public string Folder { get; set; }
private readonly DocVersionInfo _docVersionInfo;
private string _pageof = null;
private iTextSharp.text.Font _itextFont = null;
private MergedPdfsPageNumCorner _corner;
@@ -80,11 +46,11 @@ namespace Volian.Print.Library
// the following constructs the class that contains data for merging a group of pdfs.
public MergedPdf(string folder, DocVersionInfo dvi)
{
_folder = folder;
Folder = folder;
_docVersionInfo = dvi;
}
// the following merges the procedure pdfs into a single pdf
public bool DoTheMerge(Dictionary<string, List<int>> MergedLandscapPages, bool generatePointListFile)
public bool DoTheMerge(bool generatePointListFile)
{
if (MergedPdfs == null)
{
@@ -93,7 +59,7 @@ namespace Volian.Print.Library
}
iTextSharp.text.Document doc = new iTextSharp.text.Document();
string slashReplace = _docVersionInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SlashReplace ?? "_";
MergedFileName = _folder + @"\" + _docVersionInfo.MyFolder.Name.Replace("/", slashReplace).Replace("\\", slashReplace) + ".pdf";
MergedFileName = Folder + @"\" + _docVersionInfo.MyFolder.Name.Replace("/", slashReplace).Replace("\\", slashReplace) + ".pdf";
MergedFileName = ItemInfo.StripRtfFormatting(MergedFileName);
// C2021-063 file name of Alarm Point List file containing Serial Number, Title, and merged Page Number
StreamWriter sw = null;
@@ -109,12 +75,12 @@ namespace Volian.Print.Library
{
writer = PdfWriter.GetInstance(doc, new FileStream(MergedFileName, FileMode.Create));
}
catch (Exception ex)
{
catch (Exception)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("Could not create");
sb.AppendLine();
sb.AppendLine(MergedFileName + ".");
sb.AppendLine($"{MergedFileName}.");
sb.AppendLine();
sb.AppendLine("If it is open, close and retry.");
FlexibleMessageBox.Show(sb.ToString(), "Error on CreatePdf", MessageBoxButtons.OK, MessageBoxIcon.Warning);
@@ -136,7 +102,7 @@ namespace Volian.Print.Library
// write Serial Number, Title, and Page Number in the Point List file
sw.WriteLine("{0}\t{1}\t{2}", idxSerialNum++, mpp.Title, mergedPageNumber + 1);
}
string pdffilename = _folder + @"\" + mpp.PdfFileName;
string pdffilename = $@"{Folder}\{mpp.PdfFileName}";
if (!File.Exists(pdffilename))
{
FlexibleMessageBox.Show("Error in finding pdf files to merge. Cannot print with date/time as part of pdf name. Or check that individual pdfs were generated.", "Error on CreatePdf", MessageBoxButtons.OK, MessageBoxIcon.Warning);
@@ -154,7 +120,7 @@ namespace Volian.Print.Library
PdfReader reader = null;
try // B2019-041: added a try/catch for when a corrupt pdf was created for a procedure, just skip & add message to error log.
{
reader = new PdfReader(_folder + @"\" + mpp.PdfFileName);
reader = new PdfReader($@"{Folder}\{mpp.PdfFileName}");
int numPages = reader.NumberOfPages;
int currentPageNumber = 0;
PdfOutline outline = null;
@@ -178,7 +144,7 @@ namespace Volian.Print.Library
// if on the first page, add the pdfname & title as part of outline. If on remaining pages, just put out page number.
// Later this may need expanded to put sections/steps/etc.
if (currentPageNumber == 1)
outline = new PdfOutline(canvas.RootOutline, dest, mpp.PdfFileName.Replace(".pdf", "") + " - " + mpp.Title, false);
outline = new PdfOutline(canvas.RootOutline, dest, $"{mpp.PdfFileName.Replace(".pdf", "")} - {mpp.Title}", false);
else
new PdfOutline(outline, dest, "Page " + currentPageNumber.ToString(), false);
canvas.AddTemplate(page, 0, 0); // adds the page to the combined pdf
@@ -204,17 +170,13 @@ namespace Volian.Print.Library
private void AddPageNumberToPage(PdfImportedPage page, PdfContentByte cb, string outputpage, bool landscape)
{
float pgright = page.BoundingBox.Right;
float pgleft = page.BoundingBox.Left;
float pgtop = page.BoundingBox.Top;
float pgbot = page.BoundingBox.Bottom;
MergedPdfsPageNumCorner cnr = _corner; // C2021-047: Allow for setting of Merged Pdf Landscape Page Number Location
// B2019-152: Landscape page numbers when merging
if (landscape)
{
pgright = page.BoundingBox.Top;
pgleft = page.BoundingBox.Bottom;
pgtop = page.BoundingBox.Right;
pgbot = page.BoundingBox.Left;
cnr = _landcorner; // C2021-047: Allow for setting of Merged Pdf Landscape Page Number Location
}
Phrase ph = new Phrase();
@@ -281,7 +243,7 @@ namespace Volian.Print.Library
private bool GetPageOfInfo()
{
DocVersionConfig dvc = (DocVersionConfig) _docVersionInfo.MyConfig;
MergedPdfsPageOf po = dvc.Print_MergedPdfsPageOf;
_ = dvc.Print_MergedPdfsPageOf;
string tmp = EnumDescConverter.GetEnumDescription((Enum)dvc.Print_MergedPdfsPageOf);
if (tmp == "None") return false; // no page number, return false so no page number is put out.
@@ -297,7 +259,7 @@ namespace Volian.Print.Library
famtmp = _docVersionInfo.ActiveFormat.PlantFormat.FormatData.Font.Family;
}
tmp = dvc.Print_MergedPdfsPageNumFontSize;
float? tmpi=0;
float? tmpi;
if (tmp == null || tmp == "")
{
// use the default from the format from this working draft
File diff suppressed because it is too large Load Diff
@@ -6,35 +6,20 @@ using iTextSharp.text.pdf;
using iTextSharp.text;
using System.IO;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using System.Linq;
namespace Volian.Print.Library
{
public class PDFConsistencyCheckReport
{
private DocVersionInfo _MyDocVersion;
public DocVersionInfo MyDocVersion
public DocVersionInfo MyDocVersion { get; set; }
public string FileName { get; set; }
public ItemInfoList MyItemInfoList { get; set; }
public PDFConsistencyCheckReport(string fileName, ItemInfoList myItemInfoList, DocVersionInfo myDocVersion)
{
get { return _MyDocVersion; }
set { _MyDocVersion = value; }
}
private string _FileName;
public string FileName
{
get { return _FileName; }
set { _FileName = value; }
}
private ItemInfoList _MyItemInfoList;
public ItemInfoList MyItemInfoList
{
get { return _MyItemInfoList; }
set { _MyItemInfoList = value; }
}
public PDFConsistencyCheckReport(string fileName, ItemInfoList myItemInfoList, DocVersionInfo myDocVersion)
{
_FileName = fileName;
_MyItemInfoList = myItemInfoList;
_MyDocVersion = myDocVersion; //B2020-020 needed to pass in DocVersion to get paper size from format
FileName = fileName;
MyItemInfoList = myItemInfoList;
MyDocVersion = myDocVersion; //B2020-020 needed to pass in DocVersion to get paper size from format
}
public void BuildReport()
{
@@ -47,7 +32,6 @@ namespace Volian.Print.Library
}
catch (Exception ex)
{
StringBuilder msg = new StringBuilder();
document.Add(new Paragraph("Error:"));
while (ex != null)
{
@@ -61,7 +45,7 @@ namespace Volian.Print.Library
if (document.IsOpen())
{
document.Close();
System.Diagnostics.Process.Start(_FileName);
System.Diagnostics.Process.Start(FileName);
}
}
}
@@ -73,13 +57,13 @@ namespace Volian.Print.Library
// Try to open a file for creating the PDF.
while (result == false)
{
string fileName = _FileName.ToLower().Replace(".pdf", suffix + ".pdf");
string fileName = FileName.ToLower().Replace(".pdf", suffix + ".pdf");
try
{
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(fileName, FileMode.Create));
document.SetMargins(36, 36, 36, 36);
document.Open();
_FileName = fileName;
FileName = fileName;
result = true;
}
catch (System.IO.IOException exIO)
@@ -118,10 +102,12 @@ namespace Volian.Print.Library
}
private PdfPCell BlankCell(int colSpan)
{
PdfPCell c = new PdfPCell();
c.Colspan = colSpan;
c.Border = 0;
return c;
PdfPCell c = new PdfPCell
{
Colspan = colSpan,
Border = 0
};
return c;
}
private void BuildConsistencyReport(iTextSharp.text.Document doc)
{
@@ -132,7 +118,6 @@ namespace Volian.Print.Library
iTextSharp.text.Font f3 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 8, 0, Color.BLACK);
iTextSharp.text.Font f4 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 10, 2, Color.BLACK);
int cols = 5;
int borders = 0;
int paddingBottom = 6;
// float[] widths;
Csla.SortedBindingList<ItemInfo> sortedProcs = new Csla.SortedBindingList<ItemInfo>(MyItemInfoList);
@@ -141,7 +126,7 @@ namespace Volian.Print.Library
// B2019-024: First page of Report prints the title at the top and the remainder of the page is blank.
// Check if procedure(s) are printed on that page and if not, change message to "No..." and don't do
// pagebreak.
foreach (ProcedureInfo pi in sortedProcs)
foreach (ProcedureInfo pi in sortedProcs.OfType<ProcedureInfo>())
{
if (pi.IsSelected)
{
@@ -160,17 +145,21 @@ namespace Volian.Print.Library
lbSrchResults.DataSource = sortedResults;
*/
foreach (ProcedureInfo pi in sortedProcs)
foreach (ProcedureInfo pi in sortedProcs.OfType<ProcedureInfo>())
{
if (pi.IsSelected)
{
PdfPTable tt = new PdfPTable(cols);
tt.KeepTogether = true;
tt.AddCell(AddSubTableCell(pi.DisplayNumber, f2, cols, paddingBottom));
PdfPTable tt = new PdfPTable(cols)
{
KeepTogether = true
};
tt.AddCell(AddSubTableCell(pi.DisplayNumber, f2, cols, paddingBottom));
tt.AddCell(AddSubTableCell(pi.MyDifferencesText, f3, cols, paddingBottom));
PdfPCell c = new PdfPCell(tt);
c.Colspan = cols;
t.AddCell(c);
PdfPCell c = new PdfPCell(tt)
{
Colspan = cols
};
t.AddCell(c);
}
}
t.AddCell(BlankCell(cols));
@@ -179,60 +168,76 @@ namespace Volian.Print.Library
if (didSome) doc.NewPage();
t = CreatePdfPTable(cols);
CreatePageHeader(t, f1, f4, cols, paddingBottom, "Approval Consistency Report", "Procedures that should be selected to be approved in order to maintain consistency");
foreach (ProcedureInfo pi in MyItemInfoList)
foreach (ProcedureInfo pi in MyItemInfoList.OfType<ProcedureInfo>())
{
if (!pi.IsSelected)
{
PdfPTable tt = new PdfPTable(cols);
tt.KeepTogether = true;
tt.AddCell(AddSubTableCell(pi.DisplayNumber, f2, cols, paddingBottom));
PdfPTable tt = new PdfPTable(cols)
{
KeepTogether = true
};
tt.AddCell(AddSubTableCell(pi.DisplayNumber, f2, cols, paddingBottom));
tt.AddCell(AddSubTableCell(pi.MyDifferencesText, f3, cols, paddingBottom));
PdfPCell c = new PdfPCell(tt);
c.Colspan = cols;
t.AddCell(c);
PdfPCell c = new PdfPCell(tt)
{
Colspan = cols
};
t.AddCell(c);
}
}
doc.Add(t);
}
private PdfPCell AddSubTableCell(string text, iTextSharp.text.Font f, int cols, float pb)
{
Phrase h = new Phrase();
h.Font = f;
h.Add(text);
PdfPCell c = new PdfPCell(h);
c.Colspan = cols;
c.HorizontalAlignment = Element.ALIGN_LEFT;
c.PaddingBottom = pb;
return c;
Phrase h = new Phrase
{
Font = f
};
h.Add(text);
PdfPCell c = new PdfPCell(h)
{
Colspan = cols,
HorizontalAlignment = Element.ALIGN_LEFT,
PaddingBottom = pb
};
return c;
}
private void CreatePageHeader(PdfPTable t, iTextSharp.text.Font f1, iTextSharp.text.Font f2, int cols, float pb, string hdr1, string hdr2)
{
//report title
Phrase h = new Phrase();
h.Font = f1;
h.Add(hdr1);
PdfPCell c = new PdfPCell(h);
c.Colspan = cols;
c.HorizontalAlignment = Element.ALIGN_CENTER;
c.PaddingBottom = pb;
//c.Border = borders;
t.AddCell(c);
h = new Phrase();
h.Font = f2;
h.Add(hdr2);
c = new PdfPCell(h);
c.Colspan = cols;
c.HorizontalAlignment = Element.ALIGN_CENTER;
c.PaddingBottom = pb;
//c.Border = borders;
t.AddCell(c);
//report title
Phrase h = new Phrase
{
Font = f1
};
h.Add(hdr1);
PdfPCell c = new PdfPCell(h)
{
Colspan = cols,
HorizontalAlignment = Element.ALIGN_CENTER,
PaddingBottom = pb
};
t.AddCell(c);
h = new Phrase
{
Font = f2
};
h.Add(hdr2);
c = new PdfPCell(h)
{
Colspan = cols,
HorizontalAlignment = Element.ALIGN_CENTER,
PaddingBottom = pb
};
t.AddCell(c);
t.AddCell(BlankCell(cols));
}
private PdfPTable CreatePdfPTable(int cols)
{
PdfPTable t = new PdfPTable(cols);
t.HeaderRows = 3;
t.DefaultCell.Padding = 4;
PdfPTable t = new PdfPTable(cols)
{
HeaderRows = 3
};
t.DefaultCell.Padding = 4;
t.WidthPercentage = 100;
float[] widths = new float[] { 1f, 1f, 1f, 1f, 4f };
t.SetWidths(widths);
@@ -251,7 +256,6 @@ namespace Volian.Print.Library
}
catch (Exception ex)
{
StringBuilder msg = new StringBuilder();
document.Add(new Paragraph("Error:"));
while (ex != null)
{
@@ -265,7 +269,7 @@ namespace Volian.Print.Library
if (document.IsOpen())
{
document.Close();
System.Diagnostics.Process.Start(_FileName);
System.Diagnostics.Process.Start(FileName);
}
}
}
@@ -276,33 +280,40 @@ namespace Volian.Print.Library
iTextSharp.text.Font f1 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 12, 1, Color.BLACK);
iTextSharp.text.Font f2 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 10, 0, Color.BLACK);
iTextSharp.text.Font f3 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 8, 0, Color.BLACK);
iTextSharp.text.Font f4 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 10, 2, Color.BLACK);
int cols = 3;
int borders = 0;
int paddingBottom = 6;
PdfPTable t = new PdfPTable(cols);
t.HeaderRows = 1;
t.WidthPercentage = 100;
float[] widths = new float[] { 1f, 1f, 10f };
PdfPTable t = new PdfPTable(cols)
{
HeaderRows = 1,
WidthPercentage = 100
};
float[] widths = new float[] { 1f, 1f, 10f };
t.SetWidths(widths);
Phrase h = new Phrase();
h.Font = f1;
h.Add("Approved Procedures Inconsistencies Report");
PdfPCell c = new PdfPCell(h);
c.Colspan = cols;
c.HorizontalAlignment = 1;
t.AddCell(c);
// C2021-013: Include the Procedure set name & date
h = new Phrase();
h.Font = f1;
string tmp = MyDocVersion.MyFolder.Name + " " + DateTime.Now.ToString("M/d/yyyy");
Phrase h = new Phrase
{
Font = f1
};
h.Add("Approved Procedures Inconsistencies Report");
PdfPCell c = new PdfPCell(h)
{
Colspan = cols,
HorizontalAlignment = 1
};
t.AddCell(c);
// C2021-013: Include the Procedure set name & date
h = new Phrase
{
Font = f1
};
string tmp = MyDocVersion.MyFolder.Name + " " + DateTime.Now.ToString("M/d/yyyy");
h.Add(tmp);
c = new PdfPCell(h);
c.Colspan = cols;
c.HorizontalAlignment = 1;
t.AddCell(c);
c = new PdfPCell(h)
{
Colspan = cols,
HorizontalAlignment = 1
};
t.AddCell(c);
Dictionary<int, string> types = new Dictionary<int, string>();
foreach (ProcedureInfo pi in MyItemInfoList)
foreach (ProcedureInfo pi in MyItemInfoList.OfType<ProcedureInfo>())
{
string type = pi.MyDifferences.ROConsistency.MyROChecks.Length > 0 ? "Reference Object Inconsistencies" : "";
if (type != string.Empty && !types.ContainsKey(0))
@@ -314,15 +325,18 @@ namespace Volian.Print.Library
if (type != string.Empty && !types.ContainsKey(2))
types.Add(2, type);
}
// types.Clear();
if (types.Count == 0)
{
h = new Phrase();
h.Font = f2;
h.Add("No Inconsistencies");
c = new PdfPCell(h);
c.Colspan = cols;
t.AddCell(c);
h = new Phrase
{
Font = f2
};
h.Add("No Inconsistencies");
c = new PdfPCell(h)
{
Colspan = cols
};
t.AddCell(c);
}
else
{
@@ -335,7 +349,7 @@ namespace Volian.Print.Library
ROFSTLookup lu = rofst.GetROFSTLookup(dvi);
if (types.ContainsKey(0))
{
foreach (ProcedureInfo pi in MyItemInfoList)
foreach (ProcedureInfo pi in MyItemInfoList.OfType<ProcedureInfo>())
{
foreach (ROCheck roc in pi.MyDifferences.ROConsistency.MyROChecks)
{
@@ -364,7 +378,7 @@ namespace Volian.Print.Library
//Dictionary<string, List<string>> trs = new Dictionary<string, List<string>>();
if (types.ContainsKey(1))
{
foreach (ProcedureInfo pi in MyItemInfoList)
foreach (ProcedureInfo pi in MyItemInfoList.OfType<ProcedureInfo>())
{
foreach (TransitionCheck trc in pi.MyDifferences.TransitionConsistency.MyTransitionChecks)
{
@@ -397,7 +411,7 @@ namespace Volian.Print.Library
//Dictionary<string, List<string>> lds = new Dictionary<string, List<string>>();
if (types.ContainsKey(2))
{
foreach (ProcedureInfo pi in MyItemInfoList)
foreach (ProcedureInfo pi in MyItemInfoList.OfType<ProcedureInfo>())
{
foreach (LibDocCheck ldc in pi.MyDifferences.LibDocConsistency.MyLibDocChecks)
{
@@ -420,28 +434,38 @@ namespace Volian.Print.Library
Color badColor = new Color(System.Drawing.Color.Khaki);
if (types.ContainsKey(0))
{
h = new Phrase();
h.Font = f2;
h.Add(types[0]);
c = new PdfPCell(h);
c.Colspan = cols;
t.AddCell(c);
h = new Phrase
{
Font = f2
};
h.Add(types[0]);
c = new PdfPCell(h)
{
Colspan = cols
};
t.AddCell(c);
foreach (string rotitle in ros.Keys)
{
t.AddCell(BlankCell(1));
h = new Phrase();
h.Font = f3;
h.Add(rotitle);
c = new PdfPCell(h);
c.Colspan = cols - 1;
c.BackgroundColor = goodColor;
t.AddCell(c);
h = new Phrase
{
Font = f3
};
h.Add(rotitle);
c = new PdfPCell(h)
{
Colspan = cols - 1,
BackgroundColor = goodColor
};
t.AddCell(c);
foreach (KeyValuePair<string,bool> d in ros[rotitle])
{
t.AddCell(BlankCell(2));
h = new Phrase();
h.Font = f3;
h.Add(d.Key);
h = new Phrase
{
Font = f3
};
h.Add(d.Key);
c = new PdfPCell(h);
if (d.Value)
c.BackgroundColor = goodColor;
@@ -451,31 +475,40 @@ namespace Volian.Print.Library
}
}
}
//jcb
if (types.ContainsKey(1))
{
h = new Phrase();
h.Font = f2;
h.Add(types[1]);
c = new PdfPCell(h);
c.Colspan = cols;
t.AddCell(c);
h = new Phrase
{
Font = f2
};
h.Add(types[1]);
c = new PdfPCell(h)
{
Colspan = cols
};
t.AddCell(c);
foreach (string trtitle in trs.Keys)
{
t.AddCell(BlankCell(1));
h = new Phrase();
h.Font = f3;
h.Add(trtitle);
c = new PdfPCell(h);
c.Colspan = cols - 1;
c.BackgroundColor = goodColor;
t.AddCell(c);
h = new Phrase
{
Font = f3
};
h.Add(trtitle);
c = new PdfPCell(h)
{
Colspan = cols - 1,
BackgroundColor = goodColor
};
t.AddCell(c);
foreach (KeyValuePair<string, bool> d in trs[trtitle])
{
t.AddCell(BlankCell(2));
h = new Phrase();
h.Font = f3;
h.Add(d.Key);
h = new Phrase
{
Font = f3
};
h.Add(d.Key);
c = new PdfPCell(h);
if (d.Value)
c.BackgroundColor = goodColor;
@@ -488,28 +521,38 @@ namespace Volian.Print.Library
//end jcb
if (types.ContainsKey(2))
{
h = new Phrase();
h.Font = f2;
h.Add(types[2]);
c = new PdfPCell(h);
c.Colspan = cols;
t.AddCell(c);
h = new Phrase
{
Font = f2
};
h.Add(types[2]);
c = new PdfPCell(h)
{
Colspan = cols
};
t.AddCell(c);
foreach (string ldtitle in lds.Keys)
{
t.AddCell(BlankCell(1));
h = new Phrase();
h.Font = f3;
h.Add(ldtitle);
c = new PdfPCell(h);
c.Colspan = cols - 1;
c.BackgroundColor = goodColor;
t.AddCell(c);
h = new Phrase
{
Font = f3
};
h.Add(ldtitle);
c = new PdfPCell(h)
{
Colspan = cols - 1,
BackgroundColor = goodColor
};
t.AddCell(c);
foreach (KeyValuePair<string, bool> d in lds[ldtitle])
{
t.AddCell(BlankCell(2));
h = new Phrase();
h.Font = f3;
h.Add(d.Key);
h = new Phrase
{
Font = f3
};
h.Add(d.Key);
c = new PdfPCell(h);
if (d.Value)
c.BackgroundColor = goodColor;
+6 -9
View File
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VEPROMS.CSLA.Library;
using System.Collections.Generic;
using iTextSharp.text;
@@ -11,9 +6,11 @@ namespace Volian.Print.Library
{
public class PDFPageSize
{
// C2020-002 paper size is now set in the format files - this class is use to select the page size that PROMS should be using
private static Dictionary<string, Rectangle> dicPDFPageSize = new Dictionary<string, Rectangle>();
private static Dictionary<string, int> dicPDFPageSizePnts = new Dictionary<string, int>();
// C2020-002 paper size is now set in the format files - this class is use to select the page size that PROMS should be using
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
private static Dictionary<string, Rectangle> dicPDFPageSize = new Dictionary<string, Rectangle>();
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
private static Dictionary<string, int> dicPDFPageSizePnts = new Dictionary<string, int>();
private static void BuildPDFPageSizeDic()
{
// the page size is set in the format files using a string description i.e.: <PDFPageSize PaperSize="LETTER" />
File diff suppressed because it is too large Load Diff
+209 -200
View File
@@ -5,7 +5,7 @@ using VEPROMS.CSLA.Library;
using iTextSharp.text.pdf;
using iTextSharp.text;
using System.IO;
using System.Text.RegularExpressions;
using System.Linq;
namespace Volian.Print.Library
{
@@ -13,27 +13,14 @@ namespace Volian.Print.Library
public class PDFTransitionReport
{
public event TransitionReportEvent TransitionProcessed;
private void OnTransitionProcessed(object sender, EventArgs args)
{
if (TransitionProcessed != null) TransitionProcessed(sender, args);
}
public event TransitionReportEvent ProcedureProcessed;
private void OnProcedureProcessed(object sender, EventArgs args)
{
if (ProcedureProcessed != null) ProcedureProcessed(sender, args);
}
public event TransitionReportEvent DocVersionProcessed;
private void OnDocVersionProcessed(object sender, EventArgs args)
{
if (DocVersionProcessed != null) DocVersionProcessed(sender, args);
}
private string _FileName;
public string FileName
{
get { return _FileName; }
set { _FileName = value; }
}
private PdfPCell _CurrentPageNumberCell = null;
private void OnTransitionProcessed(object sender, EventArgs args) => TransitionProcessed?.Invoke(sender, args);
public event TransitionReportEvent ProcedureProcessed;
private void OnProcedureProcessed(object sender, EventArgs args) => ProcedureProcessed?.Invoke(sender, args);
public event TransitionReportEvent DocVersionProcessed;
private void OnDocVersionProcessed(object sender, EventArgs args) => DocVersionProcessed?.Invoke(sender, args);
public string FileName { get; set; }
private PdfPCell _CurrentPageNumberCell = null;
private int _CurrentPageNumber = 1;
public int CurrentPageNumber
{
@@ -51,41 +38,27 @@ namespace Volian.Print.Library
}
}
}
private FolderInfo folderInfo;
private readonly FolderInfo folderInfo;
private ProcedureInfo procedureInfo;
private TransitionInfoList transitionInfoList;
private int _TransitionInfoCount;
public int TransitionInfoCount
{
get { return _TransitionInfoCount; }
set { _TransitionInfoCount = value; }
}
private List<DocVersionInfo> _MyDocVersionList;
public List<DocVersionInfo> MyDocVersionList
{
get { return _MyDocVersionList; }
set { _MyDocVersionList = value; }
}
private int _ProcedureCount;
public int ProcedureCount
{
get { return _ProcedureCount; }
set { _ProcedureCount = value; }
}
private string _PaperSize = "Letter";
public int TransitionInfoCount { get; set; }
public List<DocVersionInfo> MyDocVersionList { get; set; }
public int ProcedureCount { get; set; }
private readonly string _PaperSize = "Letter";
public PDFTransitionReport(FolderInfo fi, string fileName)
{
_FileName = fileName;
FileName = fileName;
folderInfo = fi;
if (fi.ActiveFormat != null)
_PaperSize = fi.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize; // C2020-002 paper size is now set in the format files
}
public PDFTransitionReport(ProcedureInfo pi, string fileName)
{
_FileName = fileName;
FileName = fileName;
procedureInfo = pi;
transitionInfoList = TransitionInfoList.GetTransitionReportData(procedureInfo.MyDocVersion.VersionID, procedureInfo.ItemID);
_TransitionInfoCount = transitionInfoList.Count;
TransitionInfoCount = transitionInfoList.Count;
_PaperSize = pi.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize; // C2020-002 paper size is now set in the format files
}
public void BuildTransitionReport()
@@ -100,13 +73,13 @@ namespace Volian.Print.Library
if (MyDocVersionList.Count == 1)
{
DocVersionInfo dvi = MyDocVersionList[0];
foreach (ProcedureInfo pi in dvi.Procedures)
foreach (ProcedureInfo pi in dvi.Procedures.OfType<ProcedureInfo>())
{
procedureInfo = pi;
transitionInfoList = TransitionInfoList.GetTransitionReportData(dvi.VersionID, procedureInfo.ItemID);
if (transitionInfoList.Count > 0)
{
_TransitionInfoCount = transitionInfoList.Count;
TransitionInfoCount = transitionInfoList.Count;
OnProcedureProcessed(this, new EventArgs());
BuildProcedureReport(document);
}
@@ -122,11 +95,11 @@ namespace Volian.Print.Library
{
ProcedureCount = dvi.Procedures.Count;
OnDocVersionProcessed(this, new EventArgs());
foreach (ProcedureInfo pi in dvi.Procedures)
foreach (ProcedureInfo pi in dvi.Procedures.OfType<ProcedureInfo>())
{
procedureInfo = pi;
transitionInfoList = TransitionInfoList.GetTransitionReportData(dvi.VersionID, procedureInfo.ItemID);
_TransitionInfoCount = transitionInfoList.Count;
TransitionInfoCount = transitionInfoList.Count;
OnProcedureProcessed(this, new EventArgs());
BuildProcedureReport(document);
}
@@ -140,7 +113,6 @@ namespace Volian.Print.Library
}
catch (Exception ex)
{
StringBuilder msg = new StringBuilder();
document.Add(new Paragraph("Error:"));
while (ex != null)
{
@@ -160,11 +132,13 @@ namespace Volian.Print.Library
}
PdfOutline outline = null;
ProcedureInfo lastProcedureInfo = null;
private PdfPTable BuildProcedurePDFTable(Dictionary<int, string> levels, Dictionary<int, iTextSharp.text.Font> fonts, int cols, int paddingBottom, int level, iTextSharp.text.Document doc)
private PdfPTable BuildProcedurePDFTable(Dictionary<int, string> levels, Dictionary<int, iTextSharp.text.Font> fonts, int cols, int paddingBottom, int level)
{
PdfPTable t = new PdfPTable(cols);
t.HeaderRows = 4;
t.DefaultCell.Padding = 4;
PdfPTable t = new PdfPTable(cols)
{
HeaderRows = 4
};
t.DefaultCell.Padding = 4;
t.WidthPercentage = 100;
float[] widths;
if(level == 1 || level == 2 || level == 4)
@@ -172,52 +146,66 @@ namespace Volian.Print.Library
else
widths = new float[] { 33f, 47f, 20f };
t.SetWidths(widths);
//report title
Phrase h = new Phrase();
h.Font = fonts[1];
if (folderInfo != null)
//report title
Phrase h = new Phrase
{
Font = fonts[1]
};
if (folderInfo != null)
h.Add(string.Format("Procedure Set {0} Transition Report", folderInfo.Name));
else
h.Add("Transition Report");
PdfPCell c = new PdfPCell(h);
c.Colspan = cols-1;
c.HorizontalAlignment = Element.ALIGN_LEFT;
c.PaddingBottom = paddingBottom;
c.BackgroundColor = new Color(System.Drawing.Color.DarkGoldenrod);
t.AddCell(c);
//date generated
h = new Phrase();
h.Font = fonts[4];
h.Add(DateTime.Now.ToString("dddd MMMM d, yyyy @ h:mm tt"));
c = new PdfPCell(h);
c.HorizontalAlignment = Element.ALIGN_RIGHT;
c.PaddingBottom = paddingBottom;
c.BackgroundColor = new Color(System.Drawing.Color.DarkGoldenrod);
t.AddCell(c);
//procedure title
h = new Phrase();
h.Font = fonts[2];
h.Add(string.Format("{0} - {1}", procedureInfo.DisplayNumber, procedureInfo.DisplayText));
PdfPCell c = new PdfPCell(h)
{
Colspan = cols - 1,
HorizontalAlignment = Element.ALIGN_LEFT,
PaddingBottom = paddingBottom,
BackgroundColor = new Color(System.Drawing.Color.DarkGoldenrod)
};
t.AddCell(c);
//date generated
h = new Phrase
{
Font = fonts[4]
};
h.Add(DateTime.Now.ToString("dddd MMMM d, yyyy @ h:mm tt"));
c = new PdfPCell(h)
{
HorizontalAlignment = Element.ALIGN_RIGHT,
PaddingBottom = paddingBottom,
BackgroundColor = new Color(System.Drawing.Color.DarkGoldenrod)
};
t.AddCell(c);
//procedure title
h = new Phrase
{
Font = fonts[2]
};
h.Add(string.Format("{0} - {1}", procedureInfo.DisplayNumber, procedureInfo.DisplayText));
PdfDestination dest = new PdfDestination(PdfDestination.FITH, cb.PdfDocument.PageSize.Height);
if (lastProcedureInfo != procedureInfo)
{
outline = new PdfOutline(cb.RootOutline, dest, procedureInfo.DisplayNumber, false);
lastProcedureInfo = procedureInfo;
}
c = new PdfPCell(h);
c.Colspan = cols-1;
c.HorizontalAlignment = Element.ALIGN_LEFT;
c.PaddingBottom = paddingBottom;
c.BackgroundColor = new Color(System.Drawing.Color.Goldenrod);
t.AddCell(c);
c = new PdfPCell(h)
{
Colspan = cols - 1,
HorizontalAlignment = Element.ALIGN_LEFT,
PaddingBottom = paddingBottom,
BackgroundColor = new Color(System.Drawing.Color.Goldenrod)
};
t.AddCell(c);
//page number
_CurrentPageNumberCell = BuildCell(1, string.Format("Page {0}",CurrentPageNumber), fonts[4], new Color(System.Drawing.Color.Goldenrod));
_CurrentPageNumberCell.PaddingBottom = paddingBottom;
t.AddCell(_CurrentPageNumberCell);
//transition category
h = new Phrase();
h.Font = fonts[3];
if (transitionInfoList.Count == 0)
//transition category
h = new Phrase
{
Font = fonts[3]
};
if (transitionInfoList.Count == 0)
h.Add("N/A");
else
{
@@ -225,75 +213,97 @@ namespace Volian.Print.Library
dest = new PdfDestination(PdfDestination.FITH, cb.PdfDocument.PageSize.Height);
new PdfOutline(outline, dest, levels[level]);
}
c = new PdfPCell(h);
c.Colspan = cols;
c.HorizontalAlignment = Element.ALIGN_LEFT;
c.PaddingBottom = paddingBottom;
c.BackgroundColor = new Color(System.Drawing.Color.Khaki);
t.AddCell(c);
//add column headers
h = new Phrase();
h.Font = fonts[4];
h.Add("From Procedure Location");
c = new PdfPCell(h);
c.HorizontalAlignment = Element.ALIGN_CENTER;
c.PaddingBottom = paddingBottom;
c.BackgroundColor = new Color(System.Drawing.Color.PaleGoldenrod);
t.AddCell(c);
h = new Phrase();
h.Font = fonts[4];
h.Add("From Procedure Text");
c = new PdfPCell(h);
c.HorizontalAlignment = Element.ALIGN_CENTER;
c.PaddingBottom = paddingBottom;
c.BackgroundColor = new Color(System.Drawing.Color.PaleGoldenrod);
t.AddCell(c);
h = new Phrase();
h.Font = fonts[4];
h.Add("To Procedure Location");
c = new PdfPCell(h);
c.HorizontalAlignment = Element.ALIGN_CENTER;
c.PaddingBottom = paddingBottom;
c.BackgroundColor = new Color(System.Drawing.Color.PaleGoldenrod);
t.AddCell(c);
c = new PdfPCell(h)
{
Colspan = cols,
HorizontalAlignment = Element.ALIGN_LEFT,
PaddingBottom = paddingBottom,
BackgroundColor = new Color(System.Drawing.Color.Khaki)
};
t.AddCell(c);
//add column headers
h = new Phrase
{
Font = fonts[4]
};
h.Add("From Procedure Location");
c = new PdfPCell(h)
{
HorizontalAlignment = Element.ALIGN_CENTER,
PaddingBottom = paddingBottom,
BackgroundColor = new Color(System.Drawing.Color.PaleGoldenrod)
};
t.AddCell(c);
h = new Phrase
{
Font = fonts[4]
};
h.Add("From Procedure Text");
c = new PdfPCell(h)
{
HorizontalAlignment = Element.ALIGN_CENTER,
PaddingBottom = paddingBottom,
BackgroundColor = new Color(System.Drawing.Color.PaleGoldenrod)
};
t.AddCell(c);
h = new Phrase
{
Font = fonts[4]
};
h.Add("To Procedure Location");
c = new PdfPCell(h)
{
HorizontalAlignment = Element.ALIGN_CENTER,
PaddingBottom = paddingBottom,
BackgroundColor = new Color(System.Drawing.Color.PaleGoldenrod)
};
t.AddCell(c);
return t;
}
PdfContentByte cb;
private void BuildProcedureReport(iTextSharp.text.Document doc)
{
Dictionary<int, string> tranTypes = FormatInfo.GetTransitionTypesByFormatID(procedureInfo.ActiveFormat.FormatID);
Dictionary<int, string> levels = new Dictionary<int, string>();
levels.Add(1, "Internal Transitions");
levels.Add(2, "External From Transitions");
levels.Add(3, "External To Transitions");
levels.Add(4, "Outside From Transitions");
levels.Add(5, "Outside To Transitions");
Dictionary<int, iTextSharp.text.Font> fonts = new Dictionary<int, Font>();
// C2017-036 get best available proportional font for symbols that looks close to Arial
// Note that Microsoft no longer supplies Arial Unicode MS as of Word16
fonts.Add(1, pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 12, 0, Color.BLACK));
fonts.Add(2, pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 10, 0, Color.BLACK));
fonts.Add(3, pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 8, 0, Color.BLACK));
fonts.Add(4, pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 8, 0, Color.BLACK));
Dictionary<int, string> levels = new Dictionary<int, string>
{
{ 1, "Internal Transitions" },
{ 2, "External From Transitions" },
{ 3, "External To Transitions" },
{ 4, "Outside From Transitions" },
{ 5, "Outside To Transitions" }
};
Dictionary<int, iTextSharp.text.Font> fonts = new Dictionary<int, Font>
{
// C2017-036 get best available proportional font for symbols that looks close to Arial
// Note that Microsoft no longer supplies Arial Unicode MS as of Word16
{ 1, pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 12, 0, Color.BLACK) },
{ 2, pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 10, 0, Color.BLACK) },
{ 3, pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 8, 0, Color.BLACK) },
{ 4, pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 8, 0, Color.BLACK) }
};
int lastLevel = transitionInfoList.Count > 0 ? transitionInfoList[0].Level : 0; //set level to first transition level
#region buildtable
int cols = 3;
int paddingBottom = 6;
if (folderInfo != null)
doc.NewPage();
PdfPTable t = BuildProcedurePDFTable(levels, fonts, cols, paddingBottom, lastLevel, doc);
PdfPTable t = BuildProcedurePDFTable(levels, fonts, cols, paddingBottom, lastLevel);
#endregion
//gather data
if (transitionInfoList.Count == 0)
{
Phrase h = new Phrase();
h.Font = fonts[4];
h.Add("This procedure contains no transitions");
PdfPCell c = new PdfPCell(h);
c.Colspan = cols;
c.HorizontalAlignment = Element.ALIGN_LEFT;
c.PaddingBottom = paddingBottom;
t.AddCell(c);
Phrase h = new Phrase
{
Font = fonts[4]
};
h.Add("This procedure contains no transitions");
PdfPCell c = new PdfPCell(h)
{
Colspan = cols,
HorizontalAlignment = Element.ALIGN_LEFT,
PaddingBottom = paddingBottom
};
t.AddCell(c);
}
else
{
@@ -308,37 +318,49 @@ namespace Volian.Print.Library
doc.Add(t);
doc.NewPage();
lastLevel = ti.Level;
t = BuildProcedurePDFTable(levels, fonts, cols, paddingBottom, lastLevel, doc);
t = BuildProcedurePDFTable(levels, fonts, cols, paddingBottom, lastLevel);
}
}
//add from path
Phrase h = new Phrase();
h.Font = fonts[4];
h.Add(StripProcInfo(ti.PathFrom, procedureInfo));
PdfPCell c = new PdfPCell(h);
c.HorizontalAlignment = Element.ALIGN_LEFT;
c.PaddingBottom = paddingBottom;
if (lastLevel > 1 && (!tranTypes[ti.TranType].Contains("{Proc") && !tranTypes[ti.TranType].Contains("other procedure"))) c.BackgroundColor = new Color(System.Drawing.Color.LightCoral);
//add from path
Phrase h = new Phrase
{
Font = fonts[4]
};
h.Add(StripProcInfo(ti.PathFrom, procedureInfo));
PdfPCell c = new PdfPCell(h)
{
HorizontalAlignment = Element.ALIGN_LEFT,
PaddingBottom = paddingBottom
};
if (lastLevel > 1 && (!tranTypes[ti.TranType].Contains("{Proc") && !tranTypes[ti.TranType].Contains("other procedure"))) c.BackgroundColor = new Color(System.Drawing.Color.LightCoral);
t.AddCell(c);
//add from text
h = new Phrase();
h.Font = fonts[4];
ItemInfo myItemInfo = ti.MyContent.ContentItems[0];
//add from text
h = new Phrase
{
Font = fonts[4]
};
ItemInfo myItemInfo = ti.MyContent.ContentItems[0];
h.Add(GetTextPath(myItemInfo, 0));
c = new PdfPCell(h);
c.HorizontalAlignment = Element.ALIGN_LEFT;
c.PaddingBottom = paddingBottom;
if (lastLevel > 1 && (!tranTypes[ti.TranType].Contains("{Proc") && !tranTypes[ti.TranType].Contains("other procedure"))) c.BackgroundColor = new Color(System.Drawing.Color.LightCoral);
c = new PdfPCell(h)
{
HorizontalAlignment = Element.ALIGN_LEFT,
PaddingBottom = paddingBottom
};
if (lastLevel > 1 && (!tranTypes[ti.TranType].Contains("{Proc") && !tranTypes[ti.TranType].Contains("other procedure"))) c.BackgroundColor = new Color(System.Drawing.Color.LightCoral);
t.AddCell(c);
//add to text
h = new Phrase();
h.Font = fonts[4];
myItemInfo = ti.MyItemToID;
//add to text
h = new Phrase
{
Font = fonts[4]
};
myItemInfo = ti.MyItemToID;
h.Add(GetTextPath(myItemInfo, ti.Level));
c = new PdfPCell(h);
c.HorizontalAlignment = Element.ALIGN_LEFT;
c.PaddingBottom = paddingBottom;
if (lastLevel > 1 && (!tranTypes[ti.TranType].Contains("{Proc") && !tranTypes[ti.TranType].Contains("other procedure"))) c.BackgroundColor = new Color(System.Drawing.Color.LightCoral);
c = new PdfPCell(h)
{
HorizontalAlignment = Element.ALIGN_LEFT,
PaddingBottom = paddingBottom
};
if (lastLevel > 1 && (!tranTypes[ti.TranType].Contains("{Proc") && !tranTypes[ti.TranType].Contains("other procedure"))) c.BackgroundColor = new Color(System.Drawing.Color.LightCoral);
t.AddCell(c);
}
}
@@ -357,16 +379,16 @@ namespace Volian.Print.Library
{
StringBuilder sb = new StringBuilder();
if (myItemInfo.IsProcedure)
return myItemInfo.MyProcedure.DisplayNumber + " " + myItemInfo.MyProcedure.DisplayText;
return $"{myItemInfo.MyProcedure.DisplayNumber} {myItemInfo.MyProcedure.DisplayText}";
if (myItemInfo.IsSection)
{
if (level > 1)
return myItemInfo.MyProcedure.DisplayNumber + " " + myItemInfo.MyProcedure.DisplayText + "\r\n " + myItemInfo.DisplayText;
return $"{myItemInfo.MyProcedure.DisplayNumber} {myItemInfo.MyProcedure.DisplayText}\r\n {myItemInfo.DisplayText}";
else
return myItemInfo.DisplayText;
}
if (myItemInfo.IsHigh)
return myItemInfo.ActiveSection.DisplayText + "\r\n " + myItemInfo.DisplayText;
return $"{myItemInfo.ActiveSection.DisplayText}\r\n {myItemInfo.DisplayText}";
else
{
string tmp = "";
@@ -393,10 +415,6 @@ namespace Volian.Print.Library
}
return sb.ToString();
}
public void BuildTransitionReport(FolderInfo fi)
{
System.Windows.Forms.MessageBox.Show("folder");
}
private bool CreateResultsPDF(iTextSharp.text.Document document)
{
bool result = false;
@@ -404,26 +422,20 @@ namespace Volian.Print.Library
int i = 0;
// just for safety, the while loop expects to find a file extension
// so make sure it has one before going into the loop
if (!_FileName.ToUpper().EndsWith(".PDF"))
_FileName += ".pdf";
if (!FileName.ToUpper().EndsWith(".PDF"))
FileName += ".pdf";
// Try to open a file for creating the PDF.
while (result == false)
{
string fileName = _FileName;
// Bug fix: B2013-086
// the folder path part of _FileName contained a folder name with a period
// resulting is an invalid file location/file name.
// Changed the IndexOf call to the LastIndexOf
//int loc = fileName.IndexOf(".");
string fileName = FileName;
int loc = fileName.LastIndexOf(".");
if (loc > -1)
{
string fname = fileName.Substring(0, loc);
fileName = fname + suffix + ".pdf";
fileName = $"{fname}{suffix}.pdf";
}
else
fileName = fileName + suffix + ".pdf";
// string fileName = _FileName.ToLower().Replace(".pdf", suffix + ".pdf");
fileName = $"{fileName}{suffix}.pdf";
try
{
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(fileName, FileMode.Create));
@@ -431,7 +443,7 @@ namespace Volian.Print.Library
document.SetMargins(36, 36, 36, 36);
document.Open();
cb = writer.DirectContent;
_FileName = fileName;
FileName = fileName;
result = true;
}
catch (System.IO.IOException exIO)
@@ -468,28 +480,25 @@ namespace Volian.Print.Library
}
System.Windows.Forms.MessageBox.Show(msg.ToString(), "Error during PDF creation for search:", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
}
private PdfPCell BlankCell(int colSpan)
{
PdfPCell c = new PdfPCell();
c.Colspan = colSpan;
c.Border = 0;
return c;
}
private PdfPCell BuildCell(int colspan, string txt, Font f, iTextSharp.text.Color clr)
{
Phrase h = new Phrase();
h.Font = f;
h.Add(txt);
PdfPCell c = new PdfPCell(h);
c.HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT;
c.Colspan = colspan;
c.BackgroundColor = clr;
return c;
Phrase h = new Phrase
{
Font = f
};
h.Add(txt);
PdfPCell c = new PdfPCell(h)
{
HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT,
Colspan = colspan,
BackgroundColor = clr
};
return c;
}
}
public class MyPageEvent : PdfPageEventHelper
{
private PDFTransitionReport _rpt = null;
private readonly PDFTransitionReport _rpt = null;
public MyPageEvent(PDFTransitionReport rpt)
{
_rpt = rpt;
+20 -61
View File
@@ -1,40 +1,23 @@
using System;
using System.Collections.Generic;
using System.Text;
using iTextSharp.text;
using iTextSharp.text.pdf;
using Volian.Svg.Library;
namespace Volian.Print.Library
{
public class PageCount
{
private bool _CanIncrement = true;
public bool CanIncrement
{
get { return _CanIncrement; }
set { _CanIncrement = value; }
}
private int Increment()
public bool CanIncrement { get; set; } = true;
private int Increment()
{
if (CanIncrement) Total++;
CanIncrement = false;
return Total;
}
private int _Total;
public int Total
{
get { return _Total; }
set { _Total = value; }
}
private string _FinalPageMessage;
public string FinalPageMessage
{
get { return _FinalPageMessage; }
set { _FinalPageMessage = value; }
}
private PageCountTemplates _MyTemplates; // (for each page that has this key)
public int Total { get; set; }
public string FinalPageMessage { get; set; }
private PageCountTemplates _MyTemplates; // (for each page that has this key)
internal PageCountTemplates MyTemplates
{
get
@@ -53,10 +36,10 @@ namespace Volian.Print.Library
foreach (PageCountTemplate pct in MyTemplates)
{
cnt++;
string fstr = pct.Text.Replace("{OF}", _Total.ToString());
string fstr = pct.Text.Replace("{OF}", Total.ToString());
if (pct.Text.Contains("{TOCPAGE}"))
{
fstr = pct.Text.Replace("{TOCPAGE}", _Total.ToString());
fstr = pct.Text.Replace("{TOCPAGE}", Total.ToString());
}
if (fstr.Contains("{FINALPAGE}"))
{
@@ -140,45 +123,21 @@ namespace Volian.Print.Library
public class PageCountTemplate
{
private string _Text;
public string Text // "Page 1 of {OF}"
{
get { return _Text; }
set { _Text = value; }
}
private System.Drawing.Font _MyFont;
public System.Drawing.Font MyFont
{
get { return _MyFont; }
set { _MyFont = value; }
}
private int _Alignment; // iTextSharp Element.<XYZ>
public int Alignment
{
get { return _Alignment; }
set { _Alignment = value; }
}
private System.Drawing.Color _MyColor;
public System.Drawing.Color MyColor
{
get { return _MyColor; }
set { _MyColor = value; }
}
private PdfTemplate _MyTemplate;
public PdfTemplate MyTemplate
{
get { return _MyTemplate; }
set { _MyTemplate = value; }
}
public PageCountTemplate(PdfWriter pdfWriter, string text, System.Drawing.Font myFont, int alignment, System.Drawing.Color color)
public string Text // "Page 1 of {OF}"
{ get; set; }
public System.Drawing.Font MyFont { get; set; }
public int Alignment { get; set; }
public System.Drawing.Color MyColor { get; set; }
public PdfTemplate MyTemplate { get; set; }
public PageCountTemplate(PdfWriter pdfWriter, string text, System.Drawing.Font myFont, int alignment, System.Drawing.Color color)
{
// Create Template can be called with a small, i.e. 1, width/height because when
// it is actually drawn, the bounding box overrides the CreateTemplate values.
_MyTemplate = pdfWriter.DirectContent.CreateTemplate(1, 1);
_Text = text;
_MyFont = myFont;
_MyColor = color;
_Alignment = alignment;
MyTemplate = pdfWriter.DirectContent.CreateTemplate(1, 1);
Text = text;
MyFont = myFont;
MyColor = color;
Alignment = alignment;
}
}
public class PageCountTemplates : List<PageCountTemplate>
+119 -272
View File
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Text;
using VEPROMS.CSLA.Library;
using Volian.Base.Library;
using iTextSharp.text.pdf;
@@ -10,53 +9,29 @@ namespace Volian.Print.Library
{
public partial class vlnParagraph
{
private string _PageBreakReason = null;
public string PageBreakReason
{
get { return _PageBreakReason; }
set { _PageBreakReason = value; }
}
private bool _CompressPartOfStep = false;
public bool CompressPartOfStep
{
get { return _CompressPartOfStep; }
set { _CompressPartOfStep = value; }
}
private bool _CompressFirstPartOfStep = false;
public bool CompressFirstPartOfStep
{
get { return _CompressFirstPartOfStep; }
set { _CompressFirstPartOfStep = value; }
}
private bool _BreakHighLevelStepWithSection = false;
public bool BreakHighLevelStepWithSection
{
get { return _BreakHighLevelStepWithSection; }
set { _BreakHighLevelStepWithSection = value; }
}
/// <summary>
/// This variable is used to match 16 bit pagination
/// </summary>
private bool _Match16BitPagination = false;
private bool _CompressFoldout = false;
public bool CompressFoldout
{
get { return _CompressFoldout; }
set { _CompressFoldout = value; }
}
/// <summary>
/// Dtermines if the current step is preceded by a Page Break
/// </summary>
/// <param name="yLocation"></param>
/// <param name="yTopMargin"></param>
/// <param name="yBottomMargin"></param>
/// <returns>
/// 0 - No page break
/// 1 - Break on High Level Step
/// 2 - Break within a Step
/// 3 - Break on High Level Step (SevenLinesPerInch)
/// </returns>
private int Paginate(float yLocation, float yTopMargin, float yBottomMargin)
public string PageBreakReason { get; set; } = null;
public bool CompressPartOfStep { get; set; } = false;
public bool CompressFirstPartOfStep { get; set; } = false;
public bool BreakHighLevelStepWithSection { get; set; } = false;
/// <summary>
/// This variable is used to match 16 bit pagination
/// </summary>
private readonly bool _Match16BitPagination = false;
public bool CompressFoldout { get; set; } = false;
/// <summary>
/// Dtermines if the current step is preceded by a Page Break
/// </summary>
/// <param name="yLocation"></param>
/// <param name="yTopMargin"></param>
/// <param name="yBottomMargin"></param>
/// <returns>
/// 0 - No page break
/// 1 - Break on High Level Step
/// 2 - Break within a Step
/// 3 - Break on High Level Step (SevenLinesPerInch)
/// </returns>
private int Paginate(float yLocation, float yTopMargin, float yBottomMargin)
{
// Check if paginate on a separate section, if within a section. Top level section pagination happens in PromsPrinter
float yPageSize = yTopMargin - yBottomMargin;
@@ -85,15 +60,15 @@ namespace Volian.Print.Library
if (MyPromsPrinter.SupInfoPrintType == E_SupInfoPrintType.SupInfoPdfPrint)
{
int retval = 0;
SectionInfo supInfoSect = MyItemInfo.ActiveSection as SectionInfo; // C2018-003 fixed use of getting the active section
if (supInfoSect != null && supInfoSect.StepSectPageBreaksForSupInfo != null && supInfoSect.StepSectPageBreaksForSupInfo.Contains(MyItemInfo.ItemID))
{
MyPromsPrinter.SupInfoPdfPageCount++;
retval = 1;
}
// Printing the supplemental information pages to a pdf: add an item to the dictionary that says what page in the supinfo pdf
// this item can be found on.
if (MyItemInfo.IsSupInfoPart)
// C2018-003 fixed use of getting the active section
if (MyItemInfo.ActiveSection is SectionInfo supInfoSect && supInfoSect.StepSectPageBreaksForSupInfo != null && supInfoSect.StepSectPageBreaksForSupInfo.Contains(MyItemInfo.ItemID))
{
MyPromsPrinter.SupInfoPdfPageCount++;
retval = 1;
}
// Printing the supplemental information pages to a pdf: add an item to the dictionary that says what page in the supinfo pdf
// this item can be found on.
if (MyItemInfo.IsSupInfoPart)
{
MyPromsPrinter.SupInfoPdfPage.Add(MyItemInfo.ItemID, MyPromsPrinter.SupInfoPdfPageCount);
}
@@ -141,37 +116,36 @@ namespace Volian.Print.Library
if (MyItemInfo.MyParent.IsHigh && MyItemInfo.IsNote && (MyItemInfo.MyParent.Cautions == null || MyItemInfo.MyParent.Cautions.Count == 0) && MyItemInfo.MyPrevious == null) return 1;
// if this is a substep that has a preferredpage break, and it has caution/note that is where the page break had to go
if (MyItemInfo.IsSubStep && ChildrenAbove != null && ChildrenAbove.Count > 0) return 0;
// B2017-228: The following flags a break within the step. Before returning a '2' (flags break within step), clear it out of the
// ParaBreaks. Without the 'RemoveAt', a page break will occur after this step also.
string reason = "Unknown";
if (MyPageHelper.ParaBreaks != null && MyPageHelper.ParaBreaks.Count > 0 && this == MyPageHelper.ParaBreaks[0])
if (MyPageHelper.ParaBreaks != null && MyPageHelper.ParaBreaks.Count > 0 && this == MyPageHelper.ParaBreaks[0])
{
MyPageHelper.ParaBreaks.RemoveAt(0);
reason = AddReason("Partial Step - Case 1");
ShowPageBreak(1, reason, "Yes", YSize, yPageSize, yWithinMargins, ManualPageBreak);
// B2017-228: The following flags a break within the step. Before returning a '2' (flags break within step), clear it out of the
// ParaBreaks. Without the 'RemoveAt', a page break will occur after this step also.
string reason = AddReason("Partial Step - Case 1");
ShowPageBreak(1, reason, "Yes", YSize, yPageSize, yWithinMargins, ManualPageBreak);
}
return 2;
}
}
}
// if the EndForSingle format flag is set to false, then we do not print an End message if the section
// is a single column section.
//bool _skipEndMessage = MyPageHelper.MySection.SectionConfig.Section_ColumnMode == SectionConfig.SectionColumnMode.One && !MyItemInfo.ActiveFormat.MyStepSectionLayoutData.EndForSingle;
SectionInfo si = MyItemInfo.ActiveSection as SectionInfo; // C2018-003 fixed use of getting the active section
bool _skipEndMessage = si != null && si.SectionConfig.Section_ColumnMode == SectionConfig.SectionColumnMode.One && !MyItemInfo.ActiveFormat.MyStepSectionLayoutData.EndForSingle;
// if the EndForSingle format flag is set to false, then we do not print an End message if the section
// is a single column section.
//bool _skipEndMessage = MyPageHelper.MySection.SectionConfig.Section_ColumnMode == SectionConfig.SectionColumnMode.One && !MyItemInfo.ActiveFormat.MyStepSectionLayoutData.EndForSingle;
// C2018-003 fixed use of getting the active section
bool _skipEndMessage = MyItemInfo.ActiveSection is SectionInfo si && si.SectionConfig.Section_ColumnMode == SectionConfig.SectionColumnMode.One && !MyItemInfo.ActiveFormat.MyStepSectionLayoutData.EndForSingle;
// TODO: This does not account for a long step as the last step that would exceed more than one page and
// that has an end message that needs to be accounted for in determining pagination. To do that the last
// child should be the only paragraph that accounts for the End message.
//
// If last step & there should be an end message, pagination tests need to account for the 3 lines the end
// message uses. The 3 is for a line above, the end message line & the line below (in case there is a border/box line).
// TODO: This does not account for a long step as the last step that would exceed more than one page and
// that has an end message that needs to be accounted for in determining pagination. To do that the last
// child should be the only paragraph that accounts for the End message.
//
// If last step & there should be an end message, pagination tests need to account for the 3 lines the end
// message uses. The 3 is for a line above, the end message line & the line below (in case there is a border/box line).
// The 3 was changed to 2 for the end line & the line below. The blank line below the step gives the blank
// line above the end message, thus 2 not 3. This change was made on July 20, 2011 by RHM & KBR. The
// procedure in questions was VEWCNEMG\EMGAPP.PRC, ES-01, Step 8.
//float yEndMsg = !_skipEndMessage && !MyItemInfo.IsSection && MyItemInfo.MyHLS != null && MyItemInfo.MyHLS.NextItem == null && (MyItemInfo.MyDocStyle.End.Message ?? "") != "" ? 2 * SixLinesPerInch : 0;
float yEndMsg = (!_skipEndMessage && !MyItemInfo.IsSection && MyItemInfo.MyHLS != null && MyItemInfo.MyHLS.NextItem == null)? GetEndMessageHeight(MyItemInfo.MyDocStyle) : 0; // B2018-068 account for mult-line End Messages
// The 3 was changed to 2 for the end line & the line below. The blank line below the step gives the blank
// line above the end message, thus 2 not 3. This change was made on July 20, 2011 by RHM & KBR. The
// procedure in questions was VEWCNEMG\EMGAPP.PRC, ES-01, Step 8.
//float yEndMsg = !_skipEndMessage && !MyItemInfo.IsSection && MyItemInfo.MyHLS != null && MyItemInfo.MyHLS.NextItem == null && (MyItemInfo.MyDocStyle.End.Message ?? "") != "" ? 2 * SixLinesPerInch : 0;
float yEndMsg = (!_skipEndMessage && !MyItemInfo.IsSection && MyItemInfo.MyHLS != null && MyItemInfo.MyHLS.NextItem == null)? GetEndMessageHeight() : 0; // B2018-068 account for mult-line End Messages
// also consider if there is a phone list at the bottom of the page, add the amount of space the phone
// list requires onto yEndMsg to make it easier to figure out pagination (include an extra line for the
@@ -196,9 +170,9 @@ namespace Volian.Print.Library
// location of a pagebreak. ParaBreaks contains the paragraphs that break within a step.
if (MyPageHelper.ParaBreaks.Count > 0)
{
string reason = "Unknown";
// if on current step and it is also the substep that will cause a pagebreak, i.e. the top substep in pagebreaks[[0]:
if (this == MyPageHelper.ParaBreaks[0])
string reason;
// if on current step and it is also the substep that will cause a pagebreak, i.e. the top substep in pagebreaks[[0]:
if (this == MyPageHelper.ParaBreaks[0])
{
MyPageHelper.ParaBreaks.RemoveAt(0);
reason = AddReason("Partial Step - Case 1");
@@ -230,14 +204,7 @@ namespace Volian.Print.Library
// B2018-065 Calvert's continue message was not including the substep number in AOP-1A Attachment 1, added AERandRNO check
else if (!MyPageHelper.ParaBreaks[0].PageBreakOnStep && this.YTopMost >= MyPageHelper.ParaBreaks[0].YTopMost && AERandRNO(this.MyItemInfo, MyPageHelper.ParaBreaks[0].MyItemInfo))
{
//vlnParagraph removed = MyPageHelper.ParaBreaks[0];// 2018-081 Remember where the page break was going to be
MyPageHelper.ParaBreaks.RemoveAt(0);
//if (MyParent == removed && MyItemInfo.IsRNOPart && MyParent.MyItemInfo.IsHigh)// B2018-081 If The High Level Step was going to break from the High Level RNO
//{
// reason = AddReason("Partial Step - Case 4B");
// ShowPageBreak(1, reason, "Yes", YSize, yPageSize, yWithinMargins, ManualPageBreak);
// return 0;
//}
reason = AddReason("Partial Step - Case 4");
ShowPageBreak(1, reason, "Yes", YSize, yPageSize, yWithinMargins, ManualPageBreak);
return 2; // break on this item within a step
@@ -276,9 +243,8 @@ namespace Volian.Print.Library
// flag SectionPageBreak is set to true to flag that a pagebreak should not be done
// on that first step.
StepConfig sc = firstChild.MyItemInfo.MyConfig as StepConfig;
ManualPageBreak = MyPageHelper.OriginalPageBreak ? (sc == null ? false : sc.Step_ManualPagebreak) :
sc == null ? false :
(MyPageHelper.MyPromsPrinter.RemoveManualPageBreaks == null)? sc.Step_NewManualPagebreak : false;
ManualPageBreak = MyPageHelper.OriginalPageBreak ? (sc != null && sc.Step_ManualPagebreak) :
sc != null && ((MyPageHelper.MyPromsPrinter.RemoveManualPageBreaks == null) && sc.Step_NewManualPagebreak);
// C2021-010: Remove trailing returns/spaces & manual page breaks & allow save.
if (sc != null && sc.Step_NewManualPagebreak && MyPageHelper.MyPromsPrinter.RemoveManualPageBreaks != null &&
!MyPageHelper.MyPromsPrinter.RemoveManualPageBreaks.Contains(firstChild.MyItemInfo.ItemID)) MyPageHelper.MyPromsPrinter.RemoveManualPageBreaks.Add(firstChild.MyItemInfo.ItemID);
@@ -290,10 +256,7 @@ namespace Volian.Print.Library
}
// can the title and the first step fit?
// add the first child's size + (the section title's size)
//if (ySizeIncludingFirst > (yLocation - yBottomMargin - SixLinesPerInch)) return 1;
//if (ySizeIncludingFirst > (yLocation - yBottomMargin) && ySizeIncludingFirst < yPageSize)
vlnParagraph firstStepChild = firstChild;
//while (firstStepChild.MyItemInfo.IsSection && firstStepChild.ChildrenBelow.Count > 0) firstStepChild = firstStepChild.ChildrenBelow[0];
if (firstStepChild.MyItemInfo.IsNumbered)
while (firstStepChild.ChildrenBelow.Count > 0 && (firstStepChild.MyItemInfo.IsSection || firstStepChild.MyItemInfo.IsHigh))
{
@@ -308,13 +271,12 @@ namespace Volian.Print.Library
firstStepChild = firstStepChild.MyParent.ChildrenBelow[firstStepChild.MyParent.ChildrenBelow.Count - 1];
float ySizeIncludingFirstStep = firstStepChild.YSize + (firstStepChild.YTopMost - YTopMost);
float ySizeBtmCtnMess = GetBottomContinueMessageSize(MyItemInfo.MyDocStyle);
float ySizeBtmEndMess = GetBottomEndMessageSize(MyItemInfo.MyDocStyle);
float ySizeBtmEndMess = GetBottomEndMessageSize();
bool firstSubstepExceedsSpaceAvailable = ySizeIncludingFirstStep > (yWithinMargins - ySizeBtmCtnMess -ySizeBtmEndMess);
if (KeepStepsOnPage && firstSubstepExceedsSpaceAvailable && !isFirstChild)
KeepStepsOnPage = false;
if (ySizeIncludingFirst == YSize) KeepStepsOnPage = false;
//float ySectionEndMsg = !_skipEndMessage && MyItemInfo.IsSection && MyItemInfo.Steps != null && MyItemInfo.Steps.Count == 1 && (MyItemInfo.MyDocStyle.End.Message ?? "") != "" ? 2 * SixLinesPerInch : 0;
float ySectionEndMsg = (!_skipEndMessage && MyItemInfo.IsSection && MyItemInfo.Steps != null && MyItemInfo.Steps.Count == 1) ? GetEndMessageHeight(MyItemInfo.MyDocStyle) : 0; // B2018-068 account for mult-line End Messages
float ySectionEndMsg = (!_skipEndMessage && MyItemInfo.IsSection && MyItemInfo.Steps != null && MyItemInfo.Steps.Count == 1) ? GetEndMessageHeight() : 0; // B2018-068 account for mult-line End Messages
if (MyPageHelper.NotesToFootNotes != null && MyPageHelper.NotesToFootNotes.Count > 0)
{
float vpHeight = SixLinesPerInch;
@@ -401,11 +363,10 @@ namespace Volian.Print.Library
return 1;
}
//MyPageHelper.HLSText = MyItemInfo.DisplayText; // save the High Level Step Text
//Console.WriteLine("{0} Paginate", MyPageHelper.HLSText);
StepConfig sc1 = MyItemInfo.MyConfig as StepConfig;
ManualPageBreak = MyPageHelper.OriginalPageBreak ? (sc1 == null ? false : sc1.Step_ManualPagebreak) :
sc1 == null ? false : (MyPageHelper.MyPromsPrinter.RemoveManualPageBreaks == null) ? sc1.Step_NewManualPagebreak : false;
ManualPageBreak = MyPageHelper.OriginalPageBreak ? (sc1 != null && sc1.Step_ManualPagebreak) :
sc1 != null && ((MyPageHelper.MyPromsPrinter.RemoveManualPageBreaks == null) && sc1.Step_NewManualPagebreak);
// C2021-010: Remove trailing returns/spaces & manual page breaks & allow save.
if (sc1 != null && sc1.Step_NewManualPagebreak &&
MyPageHelper.MyPromsPrinter.RemoveManualPageBreaks != null && !MyPageHelper.MyPromsPrinter.RemoveManualPageBreaks.Contains(MyItemInfo.ItemID)) MyPageHelper.MyPromsPrinter.RemoveManualPageBreaks.Add(MyItemInfo.ItemID);
@@ -423,7 +384,6 @@ namespace Volian.Print.Library
string firstStep = "No";
if (MyItemInfo.IsHigh && MyItemInfo.MyPrevious == null)
firstStep = "Yes";
//if (!ManualPageBreak && mySize + yEndMsg <= yWithinMargins) // Don't Paginate if there is enough room, will fit on page
// Pagination Fix - Break1LineShort1
float yExtra = (yWithinMargins == yPageSize ? 0 : SixLinesPerInch - MyItemInfo.MyDocStyle.Layout.FooterLength) ?? 0;
// Adjust yExtra and mySize for Component List items.
@@ -452,12 +412,11 @@ namespace Volian.Print.Library
// B2017-254 Fixed Pagination Logic when checking to see if the current item is the last high level step
if (MyItemInfo.IsHigh && mySize >= (2 * SixLinesPerInch) && MyItemInfo.MyDocStyle.Layout.FooterLength > 0 && (MyItemInfo.MyDocStyle.End.Message == null || MyItemInfo.MyDocStyle.End.Message == "") && MyItemInfo.NextItem == null && (MyItemInfo.Steps == null || MyItemInfo.Steps.Count == 0) && (MyItemInfo.RNOs == null || MyItemInfo.RNOs.Count == 0))
mySize -= SixLinesPerInch;
//// Account for extra lines in the end message (flag < 0)
float adjMsgY = 0;
if (MyItemInfo.IsHigh && MyItemInfo.NextItem == null && MyItemInfo.MyDocStyle.End.Flag < 0) // Adjust this many lines down the page.
if (MyItemInfo.IsHigh && MyItemInfo.NextItem == null && MyItemInfo.MyDocStyle.End.Flag < 0) // Adjust this many lines down the page.
{
adjMsgY = (float)-MyItemInfo.MyDocStyle.End.Flag * SixLinesPerInch;
if (yEndMsg != 0) yEndMsg += adjMsgY;
//// Account for extra lines in the end message (flag < 0)
float adjMsgY = (float)-MyItemInfo.MyDocStyle.End.Flag * SixLinesPerInch;
if (yEndMsg != 0) yEndMsg += adjMsgY;
}
// F2023-015 check if on the first step of a sub-section that starts on its own page (separate pagination)
// Beaver Valley as two sub-sections that are printed continuously followed by a third sub-section printed separate.
@@ -489,7 +448,6 @@ namespace Volian.Print.Library
ShowPageBreak(-1, "HLS will fit on page", firstStep, YSize, yPageSize, yWithinMargins,ManualPageBreak);
return 0;
}
// !MyItemInfo.IsHigh - if (MyItemInfo.IsRNOPart && MyParent.XOffset < XOffset) return 0; // Don't paginate on an RNO to the right
// YSize includes a blank line after the step which we don't want to include in the page break test, thus the
// YSize - SixLinesPerInch:
@@ -504,8 +462,6 @@ namespace Volian.Print.Library
if (MyItemInfo.IsStep && MyItemInfo.MyHLS.FormatStepData.StepLayoutData.STBoxindex != null && MyItemInfo.MyHLS.FormatStepData.StepLayoutData.STBoxindex >= 0 &&
(MyItemInfo.RNOs == null || MyItemInfo.RNOs.Count == 0))
mySize += (2 * SixLinesPerInch);
//if (firstStep == "No")
// ResetDocStyleAndValues(ref yTopMargin, ref yBottomMargin);
if (MyPageHelper.DidFirstPageDocStyle && MyItemInfo.ActiveSection != null && (MyItemInfo.ActiveSection.MyDocStyle.StructureStyle.Where & E_DocStyleUse.UseOnAllButFirstPage) > 0)// C2018-003 fixed use of getting the active section
yPageSizeNextPage = GetYPageSizeUseOnAllButFirstPage();
@@ -532,33 +488,28 @@ namespace Volian.Print.Library
// Keep figure (the only figure, i.e. count==1) with its parent.
if (ChildrenBelow.Count == 1 && ChildrenBelow[0].MyItemInfo.IsFigure) KeepStepsOnPage = false;
float sectionSpace = 0;
if (doSectionTitleContinued)
{
if (SectionShowTitles)
{
vlnParagraph paraSect = MyParent;
while (!paraSect.MyItemInfo.IsSection) paraSect = paraSect.MyParent;
if (paraSect.ContinueHeight > 24)
sectionSpace = paraSect.ContinueHeight;
else
sectionSpace = 2 * SixLinesPerInch;
// sectionSpace = 3 * SixLinesPerInch;// this should actuall use the physical size of the continue messsage.
// Fixing this caused problems with pagination ex Calvert Unit 2 IO-1l section 6.1.B step 2
//if (MyItemInfo.ActiveSection.DisplayText.Length < 40) sectionSpace = SixLinesPerInch;
yPageSizeNextPage -= sectionSpace;
yExtra -= sectionSpace;
//yExtra2 -= sectionSpace; // This was removed for Calvert STP O-73H-2 Section 6.3.O.4 and 6.3.R.3
}
}
// Added for section that was breaking from steps this code was removed to fix B2020-112
//if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvert && yPageSizeNextPage < yWithinMargins + 3 * 72 && MyItemInfo.MyPrevious == null)
// KeepStepsOnPage = true;
float mySize7LPI = mySize; // +SixLinesPerInch;
if (doSectionTitleContinued)
{
if (SectionShowTitles)
{
vlnParagraph paraSect = MyParent;
while (!paraSect.MyItemInfo.IsSection) paraSect = paraSect.MyParent;
float sectionSpace;
if (paraSect.ContinueHeight > 24)
sectionSpace = paraSect.ContinueHeight;
else
sectionSpace = 2 * SixLinesPerInch;
// this should actuall use the physical size of the continue messsage.
// Fixing this caused problems with pagination ex Calvert Unit 2 IO-1l section 6.1.B step 2
yPageSizeNextPage -= sectionSpace;
yExtra -= sectionSpace;
}
}
float mySize7LPI = mySize;
if (_Match16BitPagination) mySize7LPI += SixLinesPerInch;
float tableSpaceAvailable = TableSpaceAvailable;// RHM20150525 - Table Scrunch
float ySizeBtmCtnMess1 = GetBottomContinueMessageSize(MyItemInfo.MyDocStyle);
float ySizeBtmEndMess1 = GetBottomEndMessageSize(MyItemInfo.MyDocStyle);
float ySizeBtmEndMess1 = GetBottomEndMessageSize();
// B2017-154 Don't leave an orphan on the next page if the high level step and first sub-step will fit on the current page
if (MyItemInfo.ActiveFormat.MyStepSectionLayoutData.NoOrphans1 && KeepStepsOnPage && ChildrenBelow.Count == 2)// Handle Orphans when there are two sub-steps and only one will fit.
{
@@ -604,7 +555,6 @@ namespace Volian.Print.Library
// ySize7LPI includes a blank line after the step which we don't want to include in the page break test.
else if (!KeepStepsOnPage && MyItemInfo.ActiveFormat.MyStepSectionLayoutData.CompressSteps
//&& (mySize7LPI - SixLinesPerInch + yEndMsg - tableSpaceAvailable) < (yPageSizeNextPage * SixLinesPerInch / _SevenLinesPerInch))// RHM20150525 - Table Scrunch
// if this is the first step, then the step has to fit in the space that remains on the page
// otherwise it needs to fit on a blank page
// This was originally (10/12/2015) added for Farley Shared AOP 79 but was found to be unnecessary
@@ -631,24 +581,9 @@ namespace Volian.Print.Library
float myFirstPieceSize = GetFirstPieceSize(); //Case 0
if (_Match16BitPagination) myFirstPieceSize += 2 * SixLinesPerInch;
// TODO: Put this line back to case 0, i.e. previous line. This fixes a 16-bit vs 32-bit pagination diff in EO30 Step 20.
//float myFirstPieceSize = GetFirstPieceSize() + 2 * SixLinesPerInch; //Case 10 - this is to match 16bit
//Case 10 - this is to match 16bit
//is the amount of space left (yWithinMargins) is greater than 1/2 of the current page (yPageSize / 2):
// VCS EOP-4.3 Step 15
// ***** Adjust yWithinMargins for the bottom continue message
//DocStyle docstyle = MyItemInfo.MyDocStyle;
//string myBottomMsg = docstyle.Continue.Bottom.Message;
//float myBottomMsgSpace = ((myBottomMsg ?? "") != "") ? 2 * SixLinesPerInch : 0;
//switch (docstyle.Continue.Bottom.Location)
//{
// case E_ContBottomLoc.BottomOfPage: // place continue message at bottom of page
// // The following format flag was added for FNP, without the flag (which stops the reset of BottomMsgSpace)
// // a number of FNP procedures had overwritten steps/bottom continue message. An example can be
// // found in FNP = SAMGS;FNP-1-SACRG-2, step 1.
// if (!docstyle.Continue.Bottom.NoOverrideSpace)
// myBottomMsgSpace = 0;
// break;
//}
//float yWithinMarginsCM = yWithinMargins - myBottomMsgSpace;
//// **** Adjust yWithinMargins for the bottom continue message
// B2018-080 Don't break if HLS and High Level RNO each have one line of text and there are substeps (keep single line HSL and High Level RNO with their substeps) AEP AOP Unit 1 016-004 steps 36 & 74
// B2018-081 The previous fix caused a different issue
@@ -668,8 +603,6 @@ namespace Volian.Print.Library
ySpaceOnFirstPage = yWithinMargins; // Accounts for Section Title Line
//ShowPageBreak(8, CheckForCompression("First HLS has to split on current page"), firstStep, YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak);
//}
//else
// ShowPageBreak(6, CheckForCompression("HLS will have to split on current page"), "Special", YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak);
//BuildPageBreakList(yWithinMargins + SixLinesPerInch, yPageSizeNextPage + yExtra2, KeepStepsOnPage); // Case 5 - Determine items where page break(s) occur
// B2020-027: adjust for lines that may print on first page of section only, added MyPageHelper.PrintedSectionPage
// B2020-108: The bug itself was related to keeping a table with its parent. However compression for some pages was
@@ -695,7 +628,6 @@ namespace Volian.Print.Library
// o888o
if (firstStep == "Yes")
{
//ySpaceOnFirstPage = yWithinMargins; // Accounts for Section Title Line
ShowPageBreak(8, CheckForFirstCompression("First HLS has to split on current page"), firstStep, YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak);
}
else
@@ -754,6 +686,7 @@ namespace Volian.Print.Library
ShowPageBreak(3, CheckForFirstCompression("HLS will have to split on new page"), "Yes", YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak);
return 1; // Paginate on High Level Steps
}
//For Debugging:
//if (yWithinMargins > yPageSize / 2)
//{
// Console.WriteLine("'PageBreak',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);
@@ -780,7 +713,7 @@ namespace Volian.Print.Library
return hasAER && hasRNO;
}
// B2018-058 the the end message height accounting for multi-line end messages
private float GetEndMessageHeight(DocStyle docstyle)
private float GetEndMessageHeight()
{
float EndMsgHeight = 0;
string endmsg = MyItemInfo.MyDocStyle.End.Message ?? "";
@@ -791,12 +724,12 @@ namespace Volian.Print.Library
}
return EndMsgHeight;
}
private float GetBottomEndMessageSize(DocStyle docstyle)
private float GetBottomEndMessageSize()
{
float myBottomMsgSpace = 0;
if (MyItemInfo.IsHigh && MyItemInfo.NextItem == null && MyItemInfo.MyDocStyle.End.Flag < 0) // Adjust this many lines down the page.
{
docstyle = MyItemInfo.MyDocStyle;
DocStyle docstyle = MyItemInfo.MyDocStyle;
string myBottomMsg = docstyle.End.Message;
myBottomMsgSpace = ((myBottomMsg ?? "") != "") ? 2 * SixLinesPerInch : 0;
if (myBottomMsg != null && docstyle.End.Flag < 0) myBottomMsgSpace += (-(float)docstyle.End.Flag * SixLinesPerInch);
@@ -806,20 +739,20 @@ namespace Volian.Print.Library
private string CheckForFirstCompression(string reason)
{
if (MyPageHelper.ParaBreaks.Count > 0 && MyPageHelper.ParaBreaks[0].CompressFirstPartOfStep)
return reason + " - 7 LPI";
return $"{reason} - 7 LPI";
return reason;
}
private string CheckForCompression(string reason)
{
if (CompressPartOfStep)
return reason + " - 7 LPI";
return $"{reason} - 7 LPI";
return reason;
}
private string AddReason(string prefix)
{
string retval = prefix;
if (PageBreakReason != null)
retval += " - " + PageBreakReason;
retval += $" - {PageBreakReason}";
return retval;
}
private bool SectionShowTitles
@@ -864,8 +797,6 @@ namespace Volian.Print.Library
DebugText.WriteLine("*****PaginateError");
yPageStart = yTopMargin + YVeryTop;
yLocation = yPageStart - YOffset;
//MyItemInfo.ItemID, YSize, yPageSize, yLocation
//_MyLog.ErrorFormat("<<< ERROR >>> Forced Pagination - ItemID = {0}\r\nLocation = '{1}'", MyItemInfo.ItemID, MyItemInfo.ShortPath);
_MyLog.ErrorFormat("<<< ERROR >>> Forced Pagination\r\n==>'Forced Pagination',{0},'{1}','{2}'"
, MyItemInfo.ItemID, MyItemInfo.MyDocVersion.MyFolder.Name, MyItemInfo.ShortPath);
if (DebugPagination.IsOpen) DebugPagination.WriteLine("=====>,'Yes','Forced Pagination',{0},{1},,{3},'{4}'", MyItemInfo.ItemID, YSize, 0, yLocation, MyItemInfo.ShortPath);
@@ -927,11 +858,8 @@ namespace Volian.Print.Library
return _AlternateBreaks;
}
}
private void AddAlternateBreak(vlnParagraph vp)
{
AlternateBreaks.Add(vp);
}
private bool CheckAlternates(vlnParagraph vpBrk)
private void AddAlternateBreak(vlnParagraph vp) => AlternateBreaks.Add(vp);
private bool CheckAlternates(vlnParagraph vpBrk)
{
if (_AlternateBreaks == null) return false;
foreach(vlnParagraph vp in AlternateBreaks)
@@ -957,7 +885,7 @@ namespace Volian.Print.Library
public float yPageSizeForPagination = -1;
private void BuildPageBreakList(float ySpaceOnCurPage, float yPageSize, bool KeepStepsOnPage, float yEndMsg, bool doSectionTitleContinued, bool onNewPage)
{
float topContinueHeight = 2 * SixLinesPerInch;
float topContinueHeight; //Defaults to: 2 * SixLinesPerInch;
int profileDepth = ProfileTimer.Push(">>>> BuildPageBreakList");
// if this paragraph is flagged to pagebreakonstep (i.e. these are used by background documents
// to get each hls/caution/note to be on its own page), then any of the children above should
@@ -997,9 +925,8 @@ namespace Volian.Print.Library
// the following logic was added to fix Pagination for VCS BDMG1 Step 4
if (ChildrenRight.Count > 0 && ChildrenRight[0].YOffset == YOffset)
{
float myFirstPieceRNOSize = 0;
myFirstPieceRNOSize = ChildrenRight[0].GetFirstPieceSize();
if(myFirstPieceRNOSize < ySpaceOnCurPage)
float myFirstPieceRNOSize = ChildrenRight[0].GetFirstPieceSize();
if (myFirstPieceRNOSize < ySpaceOnCurPage)
if (ChildrenBelow.Count > 0)
{
float myFirstPieceAERSize = ChildrenBelow[0].GetFirstPieceSize() + ChildrenBelow[0].YOffset - YOffset;
@@ -1008,7 +935,6 @@ namespace Volian.Print.Library
}
}
if (myFirstPieceSize < ySpaceOnCurPage) yLowerLimit = Math.Max(myFirstPieceSize + yStart, yLowerLimit);
//while ((YSize - yTop) >= ySpaceOnCurPage)
// Pagination Fix Break1LineShort3b
DocStyle docstyle = MyItemInfo.MyDocStyle;
float myBottomMsgSpace = GetBottomContinueMessageSize(docstyle);
@@ -1052,21 +978,12 @@ namespace Volian.Print.Library
// The following code determines space required by the Checklist header (Wolf Creek) if a break occurs
// Their 2 HLS that define the checklists have 'UseSmartTemplate'.
float accountForSmartTemplateHeader = 0;
//if (MyItemInfo.InList(878)) Console.WriteLine("Here");
if (MyItemInfo.FormatStepData.UseSmartTemplate)
{
if (((MyItemInfo.MyDocStyle.End.Message ?? "") == "") || MyItemInfo.MyHLS.NextItem != null)
ySpaceOnCurPage += SixLinesPerInch;
accountForSmartTemplateHeader = Height - (2 * SixLinesPerInch);
}
// This was added so that if a page break was immediately necessary the code would use the current step.
// However, a better solution was found and put in Paginate()
//if (YSize == Height + SixLinesPerInch && YSize + yEndMsg >= ySpaceOnCurPage)
//{
// _MyLog.WarnFormat("Would have been unable to break {0},{1}",MyItemInfo.ItemID, MyItemInfo.ShortPath);
// MyPageHelper.ParaBreaks.Add(this);
// return;
//}
// ooooo ooo . oooooooooo. oooo
// `888b. `8' .o8 `888' `Y8b `888
// 8 `88b. 8 .ooooo. oooo ooo .o888oo 888 888 oooo d8b .ooooo. .oooo. 888 oooo
@@ -1170,7 +1087,8 @@ namespace Volian.Print.Library
myBottomMsgSpace, MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[40].ContinueOnly, yTop);
if (paraBreak2 != null && paraBreak != paraBreak2)
{
yLoc = ySpaceOnCurPage - (paraBreak2.YOffset - (YTopMost + yTop - paraBreak2.Height));
//For Debugging:
//yLoc = ySpaceOnCurPage - (paraBreak2.YOffset - (YTopMost + yTop - paraBreak2.Height));
if (paraBreak.YOffset == paraBreak2.YOffset + paraBreak2.Height)
{
//_MyLog.WarnFormat("Fix Break when no blank line {0},{1},{2}", paraBreak2.MyItemInfo.ShortPath, paraBreak2.MyItemInfo.ItemID,yLoc);
@@ -1211,10 +1129,7 @@ namespace Volian.Print.Library
}
if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm) // only do the following for Calvert Alarms
{
//if (lastBreak != null && lastBreak.MyItemInfo.InList(42656,42923)) Console.WriteLine("here");
// Or Step whose parent fits on a page should break at the parent step
//if (MyItemInfo.InList(119826)) Console.WriteLine("here");
//if (paraBreak.MyItemInfo.InList(40339))
float ySpaceOnNextPage = yPageSize - (myTopMsgSpace + SixLinesPerInch) - myBottomMsgSpace;
if (paraBreak.MyItemInfo.IsOr && paraBreak.MyParent.YSize < ySpaceOnNextPage)
{
@@ -1307,7 +1222,8 @@ namespace Volian.Print.Library
if (firstLevel.MyParent.ChildrenBelow != null && firstLevel.MyParent.ChildrenBelow.Count > 0 && firstLevel.MyParent.ChildrenBelow[0] != firstLevel &&
firstLevel.YSize < yPageSize - (myTopMsgSpace + SixLinesPerInch))
{
vlnParagraph firstLevel1 = firstLevel;
//For Debugging:
//vlnParagraph firstLevel1 = firstLevel;
if (firstLevel.ChildrenAbove != null && firstLevel.ChildrenAbove.Count > 0) // If the aerParent has caution or note
firstLevel = firstLevel.ChildrenAbove[0];//, break on the caution or note.
if (firstLevel != lastBreak && paraBreak != firstLevel)
@@ -1320,14 +1236,10 @@ namespace Volian.Print.Library
}
// If the break is going to happen on a table, and the tables parent would fit on a page with the table
// and the text in the parent includes the word table, then break on the parent
//if (lastBreak != paraBreak.MyParent && paraBreak.MyItemInfo.IsTable && paraBreak.YSize < ySpaceOnCurPage && paraBreak.MyParent.MyItemInfo.DisplayText.ToUpper().Contains("TABLE"))
// paraBreak = paraBreak.MyParent;
//paraBreak.ShowPageBreak(999, paraBreak.MyItemInfo.ShortPath, "Yes",paraBreak.YTop, paraBreak.YSize, paraBreak.Height, false);
//_MyLog.InfoFormat("Place to break\r\n==>'Place to Break',{0},'{1}','{2}'"
//, paraBreak.MyItemInfo.ItemID, paraBreak.MyItemInfo.MyDocVersion.MyFolder.Name, paraBreak.MyItemInfo.ShortPath);
// yTopNew is y Location of this page break. YTopMost is top of HLS, including any Cautions/Notes/Boxes/etc
//float yTopNew = paraBreak.YVeryTop - YTopMost;
//float yTopNew = paraBreak.YTopMost - YTopMost;
if (JustATableThatWillFit(paraBreak, yPageSize - (myTopMsgSpace + yEndMsg)))
paraBreak = paraBreak.ChildrenBelow[0];
// B2020-112: complicated AER/RNO. yEndMsg was accounted for twice -> put endmsg part back in, it broke wcn and didn't affect bge
@@ -1412,14 +1324,6 @@ namespace Volian.Print.Library
PageBreakOnStepList.RemoveAt(0);
yTopNew = paraBreak.YTop - YTopMost;
}
// The following code caused forced pagination for Catawba EOP BG - EP/1/A/5000/FR-C.1.SC..S16..N2..S4..S1.
//else if(PageBreakOnStepList[0].YSize - yTop <= ySpaceOnCurPage)
//{
// DebugPagination.WriteLine("======>>>>> Other Condition");
// paraBreak = PageBreakOnStepList[0];
// PageBreakOnStepList.RemoveAt(0);
// yTopNew = paraBreak.YTop - YTopMost;
//}
}
RemoveProcessedParagraphs(myList, yTopNew - yTop);
yTop = yTopNew;
@@ -1440,13 +1344,6 @@ namespace Volian.Print.Library
// B2017-252 Pagination Fix - RNP was not paginating correctly. Added logic to set ySPaceOnCurPage if ySpaceOnNextPage was larger
if (!usedPageBreakOnStepList || ySpaceOnNextPage1 > ySpaceOnCurPage) ySpaceOnCurPage = ySpaceOnNextPage1;
//ySpaceOnCurPage = yPageSize - (myTopMsgSpace + SixLinesPerInch); // Allow for continue message and blank line.
//if (paraBreak.YTopMost != paraBreak.YVeryTop && MyPageHelper.TopMessage == null && MyPageHelper.BottomMessage == null)
// ySpaceOnCurPage = yPageSize;
//ySpaceOnCurPage = yPageSize; // Allow for continue message and blank line.
//DocStyle docstyle = MyItemInfo.MyDocStyle;
//string myMsg = docstyle.Continue.Bottom.Message;
//if ((myMsg ?? "") != "") ySpaceOnCurPage -= 2 * SixLinesPerInch; // Allow for continue message and blank line.
yLowerLimit = ySpaceOnCurPage / 2;
if (_Match16BitPagination) yLowerLimit -= 1.5F * SixLinesPerInch; // 276 for HLP
yStart = 0;
@@ -1505,7 +1402,6 @@ namespace Volian.Print.Library
{
// C2023-015: Pagination on a sub-step added. Do the code if supplemental info or if format supports sub-step pagination
// C2023-018: Remove the supplemental info & alarm check, doing the possible page breaks on sub-steps
//if (!MyItemInfo.MyDocStyle.SupplementalInformation && !MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.AlarmPagination) return null;
SortedList<float, vlnParagraph> sdpara = null;
foreach (int stepLevel in myList.Keys) // loop thru StepLevels, starting with lowest.
{
@@ -1534,8 +1430,7 @@ namespace Volian.Print.Library
private float GetBottomContinueMessageSize(DocStyle docstyle)
{
float myBottomMsgSpace = 0;
docstyle = MyItemInfo.MyDocStyle;
float myBottomMsgSpace;
string myBottomMsg = docstyle.Continue.Bottom.Message;
myBottomMsgSpace = ((myBottomMsg ?? "") != "") ? 2 * SixLinesPerInch : 0;
if (myBottomMsg != null && myBottomMsg.Contains("par")) myBottomMsgSpace += SixLinesPerInch;
@@ -1603,7 +1498,7 @@ namespace Volian.Print.Library
float? yLocationMin=null;
vlnParagraph minPara2 = null;
float? yLocationMin2=null;
float yAddForBtmMsg = 0;
float yAddForBtmMsg;
// useful for debugging pagination issues, lastbreak gets the paragraph at the top of the previous page, shows all
// of the locations within 'range' on the next page.
//if (lastBreak != null && lastBreak.MyItemInfo.InList(72481))
@@ -1670,16 +1565,9 @@ namespace Volian.Print.Library
// Note that this bug fix for WCN was commented out. Harry Julian wanted this on 11/15/19. A new bug will be written for the WCN error.
// B2019-173 reintroduced the 'IsHigh' portion and added IsRNOPart, the HLS & RNOPart print at same location on page so code needs
// to account for either. second iteration of this fix removed IsRNOPart (see code in Paginate)
&& !myParent.MyItemInfo.IsHigh) /*|| myPara.MyItemInfo.IsRNOPart)) */// B2018-104: don't return if my parent is a high level - a top continue message was printing
&& !myParent.MyItemInfo.IsHigh) // B2018-104: don't return if my parent is a high level - a top continue message was printing
{
//_MyLog.WarnFormat("\r\nMyParentBreak {0},{1},{2},{3},{4}", myParent, myParent.YSize, yUpperLimit, myParent.ChildrenRight[0].YSize, spaceOnPage);
// Removed the following and moved logic to Paginate method for the second iteration of the bug fix. This code below AND the IsRNOPart above caused another
// pagination problem. The insert and subsequent removal of this code are both done under bug B22019-173.
// Initial code for B2019-173: make minPara2 the first step on next page
//if (minPara2 != null && minPara2.MyParent == myParent && minPara2 != lastBreak && minPara2.MyItemInfo.Ordinal == 1)
//{
// return minPara2;
//}
if (myParent != lastBreak)
return myParent;
}
@@ -1736,17 +1624,11 @@ namespace Volian.Print.Library
}
}
}
//while (myPara.MyParent.YTop == myPara.YTop) myPara = myPara.MyParent;
while (myPara.MyParent != null && myPara.MyParent.YTop == myPara.YTop) myPara = myPara.MyParent;
int everyNLines = myPara.MyItemInfo.MyPrevious != null && myPara.MyItemInfo.FormatStepData == null ? 1 : myPara.MyItemInfo.FormatStepData.StepLayoutData.EveryNLines ?? 1;
bool inSameBox = InSameBox(myPara, minPara2); // if this note/caution is in same box as the break, don't break within the notes/cautions in the same box
if (!inSameBox && myPara.ChildrenAbove.Count == 0 && wcnChkLstBorder - yLocation < yUpperLimit + yAddForBtmMsg || (everyNLines != 99 && (wcnChkLstBorder - yLocation == yUpperLimit + yAddForBtmMsg))) // Fix for OFN-RJ-23
//if (-yLocation < yUpperLimit) // Before
//if (-yLocation < yWithinMargins && myList[stepLevel][yLocation].MyItemInfo.MyPrevious != null)
{
//ItemInfo prev = myList[stepLevel][yLocation].MyItemInfo.MyPrevious;
//if (myList[stepLevel][yLocation].MyItemInfo.ItemID == 5609) Console.WriteLine("aer");
//if (myList[stepLevel][yLocation].MyItemInfo.ItemID == 4312) Console.WriteLine("rno");
// The top of this step is more than 1/2 way down the page
if ((-yLocation + yStart) >= yLowerLimit)
if (myPara != lastBreak)
@@ -1819,13 +1701,14 @@ namespace Volian.Print.Library
return minPara ?? minPara2;
}
// B2020-013 premature break in RNO column - Callaway OTO-AC-00002 step 2
// B2020-016 bad pagination on RNOs for Robinson AOP-010 step 27 , AOP-024 Step 10, EOP E-0 step 10, EOP ECA-2.1 step 28
// B2020-073 was not keeping all of RNO sub-step together - Comanche Peak FRC-0.1 (unit 1) Step 14
// B2020-081 was breaking on an AER substep that has an long RNO - should keep AER substep and part of RNO on the page = D.C. Cook "Current (Post FLEX) U1 NOP NOT [EOPs]" set, ES-0.1 step 1.
// B2020-085 was breaking first child of second RNO (third IF in RNO) - should break on second child of second RNO - D.C. Cook AOP Unit 1 002-020 Step 15
// B2020-099 was breaking on last sub-step of previous RNO - Calvert Approved Procedures; Abnormal Procedures Unit 2; AOP-2A; Section VII; Step 11.RNO.11.1.c
private vlnParagraph HasSecondRNOThatWillFit(float yStart, float yLowerLimit, float yUpperLimit, StepLevelList myList, int stepLevel, float yTop)
// B2020-013 premature break in RNO column - Callaway OTO-AC-00002 step 2
// B2020-016 bad pagination on RNOs for Robinson AOP-010 step 27 , AOP-024 Step 10, EOP E-0 step 10, EOP ECA-2.1 step 28
// B2020-073 was not keeping all of RNO sub-step together - Comanche Peak FRC-0.1 (unit 1) Step 14
// B2020-081 was breaking on an AER substep that has an long RNO - should keep AER substep and part of RNO on the page = D.C. Cook "Current (Post FLEX) U1 NOP NOT [EOPs]" set, ES-0.1 step 1.
// B2020-085 was breaking first child of second RNO (third IF in RNO) - should break on second child of second RNO - D.C. Cook AOP Unit 1 002-020 Step 15
// B2020-099 was breaking on last sub-step of previous RNO - Calvert Approved Procedures; Abnormal Procedures Unit 2; AOP-2A; Section VII; Step 11.RNO.11.1.c
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping myList and stepLevel for Debugging")]
private vlnParagraph HasSecondRNOThatWillFit(float yStart, float yLowerLimit, float yUpperLimit, StepLevelList myList, int stepLevel, float yTop)
{
// B2020-120: for calvert alarms/condition response table, don't run code for second rno
if (this.ChildrenAbove != null && this.ChildrenAbove.Count > 0) if (HasCalvertMacro) return this;
@@ -1856,12 +1739,6 @@ namespace Volian.Print.Library
if ((chld.YTopMost + yStart + yTop - yTopParent) < yUpperLimit)
return chld; // second RNO will fit, use this instead of myPara
// check to see if there is AER substep children that would be split if we pagination on the RNO
// B2020-150 commented out below. Found it is not needed for B2020-085 fix but it was what cause B2020-150
//foreach (vlnParagraph chld in parent.ChildrenBelow)
// if (chld.YOffset < this.YOffset && YBottomMostExcludingRNO(chld) > this.YTopMost) // B2020-085 Does AER child start before myPara and length greater than myPara start
// return null; // the AER text positioning overlaps the RNO text positioning (caused AER sub-steps to be split onto next page (i.e. RO step) have pagination logic keep looking for place to break
return this; // current myPara is good
}
@@ -1903,7 +1780,8 @@ namespace Volian.Print.Library
}
return false;
}
private static int MaxBreakLevel(float yLocation, StepLevelList myList, int maxLevel, vlnParagraph myParaBreak)
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping yLocation for Debugging")]
private static int MaxBreakLevel(float yLocation, StepLevelList myList, int maxLevel, vlnParagraph myParaBreak)
{
foreach (int stepLevel in myList.Keys)
foreach (float yLoc in myList[stepLevel].Keys)
@@ -1935,27 +1813,7 @@ namespace Volian.Print.Library
if (MyParent == null || MyParent.MyItemInfo.IsHigh) return false;
return MyParent.HasAncestor(myParaBreak);
}
//private void WalkStepLevel(float yTopMost)
//{
// foreach (vlnParagraph child in ChildrenAbove)
// child.WalkStepLevel(yTopMost);
// foreach (vlnParagraph child in ChildrenLeft)
// child.WalkStepLevel(yTopMost);
// ShowStepLevel(yTopMost);
// foreach (vlnParagraph child in ChildrenRight)
// child.WalkStepLevel(yTopMost);
// foreach (vlnParagraph child in ChildrenBelow)
// child.WalkStepLevel(yTopMost);
//}
//private void ShowStepLevel(float yTopMost)
//{
// ItemInfo item = MyItemInfo;
// ItemInfo parent = item.ActiveParent as ItemInfo;
// //if (para.MyItemInfo.ItemID == 205)
// // Console.Write("");
// DebugPagination.WriteLine("'StepLevel',{0},{1},{2},{3},{4},{5},{6},{7},{8},{9}", YVeryTop - yTopMost, YSize, YBottomMost - yTopMost, item.ItemID, item.DBSequence, item.StepLevel, item.MyContent.Type % 10000,
// parent.MyContent.Type % 10000, item.HasCautionOrNote ? 1 : 0, parent.Cautions == null ? 0 : 1);
//}
public float TableSpaceAvailable// RHM20150525 - Table Scrunch
{
get // B2019-111 Keep AER Table with parent when RNO extends past the end of the page.
@@ -1992,18 +1850,7 @@ namespace Volian.Print.Library
}
public partial class VlnSvgPageHelper : SvgPageHelper
{
private bool _OriginalPageBreak; // use 16bit page breaks.
public bool OriginalPageBreak
{
get { return _OriginalPageBreak; }
set { _OriginalPageBreak = value; }
}
// This handles Page Breaks within a Step
private List<vlnParagraph> _ParaBreaks = new List<vlnParagraph>();
public List<vlnParagraph> ParaBreaks
{
get { return _ParaBreaks; }
set { _ParaBreaks = value; }
}
}
public bool OriginalPageBreak { get; set; }
public List<vlnParagraph> ParaBreaks { get; set; } = new List<vlnParagraph>();
}
}
+12 -61
View File
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using LBWordLibrary;
using VEPROMS.CSLA.Library;
using System.Text.RegularExpressions;
@@ -10,12 +7,12 @@ namespace Volian.Print.Library
{
public class Placekeeper : IDisposable
{
private LBApplicationClass _WordApp;
private LBDocumentClass _WordDoc;
private LBSelection _WordSel;
private readonly LBApplicationClass _WordApp;
private readonly LBDocumentClass _WordDoc;
private readonly LBSelection _WordSel;
private LBTable _WordTbl;
private const string TheQuickBrownFox = "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.";
private VE_Font _pkFont;
private readonly VE_Font _pkFont;
public Placekeeper()
{
_WordApp = new LBApplicationClass();
@@ -28,37 +25,11 @@ namespace Volian.Print.Library
_WordApp.Visible = true;
_WordApp.Activate();
}
//public Placekeeper(pkParagraph myPlacekeeper)
//{
// _WordApp = new LBApplicationClass();
// _WordDoc = _WordApp.Documents.Add();
// _WordSel = _WordApp.Selection;
// _WordApp.Visible = true;
// AddTable();
// AddHeader();
// AddSectionHeader(myPlacekeeper.MyParagraph.MyItemInfo.DisplayNumber, myPlacekeeper.MyParagraph.MyItemInfo.DisplayText);
// foreach (pkParagraph pgh in myPlacekeeper.MyChildren)
// {
// AddHighLevelStep(pgh.MyParagraph.MyItemInfo.MyTab.CleanText, pgh.MyParagraph.MyItemInfo.DisplayText, pgh.MyParagraph.MyItemInfo.FormatStepType==9 ? "C" : "", pgh.MyParagraph.MyItemInfo.PageNumber.ToString());
// if (pgh.MyChildren.Count > 0)
// {
// StartSubStep();
// foreach (pkParagraph cpgh in pgh.MyChildren)
// {
// ContinueSubStep(cpgh.MyParagraph.MyItemInfo.DisplayText, 1);
// foreach (pkParagraph ccpgh in cpgh.MyChildren)
// ContinueSubStep(ccpgh.MyParagraph.MyItemInfo.DisplayText, 2);
// }
// FinishSubstep("", "");
// }
// }
//}
public Placekeeper(pkParagraphs myPlacekeepers, VE_Font pkFont)
{
_WordApp = new LBApplicationClass();
_WordDoc = _WordApp.Documents.Add();
_WordSel = _WordApp.Selection;
//_WordApp.Visible = true;
_pkFont = pkFont;
AddTable();
AddHeader();
@@ -97,7 +68,7 @@ namespace Volian.Print.Library
if (cpgh.MyCautionsAndNotes.Count > 0)
AddNotesOrCautions(cpgh,level, ref conAct);
if (!conAct)
conAct = IsContinuousActionPlacekeeper(conAct, cpgh);
conAct = IsContinuousActionPlacekeeper(cpgh);
ContinueSubStep(cpgh.MyParagraph.MyItemInfo.FormattedDisplayText, level);
AddChildren(cpgh, level+1, ref conAct);
}
@@ -108,19 +79,14 @@ namespace Volian.Print.Library
foreach (pkParagraph cpgh in pgh.MyCautionsAndNotes)
{
if (!conAct)
conAct = IsContinuousActionPlacekeeper(conAct, cpgh);
conAct = IsContinuousActionPlacekeeper(cpgh);
ContinueNoteOrCaution(cpgh.MyParagraph.MyItemInfo, level);
}
}
private static bool IsContinuousActionPlacekeeper(bool conAct, pkParagraph pkPar)
{
StepConfig sc = pkPar.MyParagraph.MyItemInfo.MyConfig as StepConfig;
conAct = (sc.Step_Placekeeper.ToUpper() == "C");
return conAct;
}
private static bool IsContinuousActionPlacekeeper(pkParagraph pkPar) => (pkPar.MyParagraph.MyItemInfo.MyConfig as StepConfig).Step_Placekeeper.ToUpper() == "C";
private void ContinueNoteOrCaution(ItemInfo ii, int level)
private void ContinueNoteOrCaution(ItemInfo ii, int level)
{
string NoteCautionTab = "NOTE: ";
if (ii.IsCaution) NoteCautionTab = "CAUTION: ";
@@ -176,22 +142,17 @@ namespace Volian.Print.Library
_WordTbl.TopPadding = 6F;
_WordTbl.BottomPadding = 6F;
LBColumn col = _WordTbl.Columns.First;
//col.SetWidth(12F, LBWdRulerStyle.wdAdjustNone);
//col = col.Next;
col.SetWidth(72 * .91F, LBWdRulerStyle.wdAdjustNone);
col = col.Next;
col.SetWidth(72 * 4.1F, LBWdRulerStyle.wdAdjustNone);
col = col.Next;
//col.SetWidth(72 * .81F, LBWdRulerStyle.wdAdjustNone);
col.SetWidth(72 * .76F, LBWdRulerStyle.wdAdjustNone);
col = col.Next;
//col.SetWidth(72 * .81F, LBWdRulerStyle.wdAdjustNone);
col.SetWidth(72 * .76F, LBWdRulerStyle.wdAdjustNone);
_WordTbl.Rows.AllowBreakAcrossPages = 0;
}
private void AddHeader()
{
//Advance();
WriteCell("START", true, true);
SetIndent(0.32F, -0F);
WriteCell("FUNCTION", true, true);
@@ -219,7 +180,6 @@ namespace Volian.Print.Library
// follow through in fixing an Out of Window Handles bug, use new function to see if
// we can retrieve the font from a dictionary instead a doing a New and using another
// window handle B2017-117
//System.Drawing.Font font = new System.Drawing.Font(_pkFont.Family, (float)_pkFont.Size);
System.Drawing.Font font = VE_Font.GetWinSysFont(_pkFont.Family, (float)_pkFont.Size);
iTextSharp.text.Font iFont = Volian.Svg.Library.VolianPdf.GetFont(font);
float w = 0;
@@ -227,8 +187,6 @@ namespace Volian.Print.Library
{
w += iFont.BaseFont.GetWidthPointKerned(c.ToString(), (float)_pkFont.Size);
}
// indented text didn't always line up doing it this way
//float w = iFont.BaseFont.GetWidthPointKerned(txt, (float)_pkFont.Size);
return w;
}
private void AddHighLevelStep(string number, string text, string done, string page)
@@ -276,7 +234,6 @@ namespace Volian.Print.Library
{
Advance(2);
SetIndent(.64F, -.31F);
//_WordSel.InsertSymbol(8226, _WordSel.Font, System.Reflection.Missing.Value, System.Reflection.Missing.Value);
WriteCell("\u2022" + "\t" + text, false, true);
SetAlignment(LBWdParagraphAlignment.wdAlignParagraphCenter, LBWdCellVerticalAlignment.wdCellAlignVerticalBottom);
WriteCell(done, false, true);
@@ -316,7 +273,7 @@ namespace Volian.Print.Library
SetAlignment(LBWdParagraphAlignment.wdAlignParagraphCenter, LBWdCellVerticalAlignment.wdCellAlignVerticalBottom);
WriteCell(page, false, false);
}
static Regex rgx = new Regex(@"\\(b|ul|up[1-9]|dn0|up0|dn[1-9]|b0|ulnone)( |$|(?=\\))");
static readonly Regex rgx = new Regex(@"\\(b|ul|up[1-9]|dn0|up0|dn[1-9]|b0|ulnone)( |$|(?=\\))");
private void WriteRTF(string text)
{
//if (text.Contains("\\"))
@@ -381,13 +338,7 @@ namespace Volian.Print.Library
{
_WordSel.MoveRight(LBWdUnits.wdCell, count, false);
}
private void Advance()
{
Advance(1);
}
public void Dispose()
{
_WordApp.Quit(false);
}
}
private void Advance() => Advance(1);
public void Dispose() => _WordApp.Quit(false);
}
}
File diff suppressed because it is too large Load Diff
+47 -113
View File
@@ -1,12 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text;
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.factories;
using Itenso.Rtf;
using Itenso.Rtf.Parser;
using Itenso.Rtf.Interpreter;
using Itenso.Rtf.Support;
using System.IO;
using VEPROMS.CSLA.Library;
@@ -36,25 +31,15 @@ namespace Volian.Print.Library
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
private string _Rtf;
#endregion
public string Rtf
{
get { return _Rtf; }
set { _Rtf = value; }
}
private string _FileName;
public string Rtf { get; set; }
public string FileName
public string FileName { get; set; }
public Rtf2Pdf(string rtf, string fileName)
{
get { return _FileName; }
set { _FileName = value; }
}
public Rtf2Pdf(string rtf, string fileName)
{
_Rtf = rtf;
_FileName = fileName;
Rtf = rtf;
FileName = fileName;
}
public void Process()
{
@@ -83,67 +68,31 @@ namespace Volian.Print.Library
yTop = newYTop;
}
}
private static string _PaperSize = "LETTER"; // default paper size
public static string PaperSize // C2020-002 paper size is now set in the format files
{
get { return Rtf2Pdf._PaperSize; }
set { Rtf2Pdf._PaperSize = value; }
}
private Rectangle _PaperSizeRec = PageSize.LETTER; // default paper size
public Rectangle PaperSizeRec
{
get { return PDFPageSize.UsePaperSize(PaperSize); }
}
private static bool _PdfDebug = true;
public static bool PdfDebug
{
get { return Rtf2Pdf._PdfDebug; }
set { Rtf2Pdf._PdfDebug = value; }
}
private static System.Drawing.PointF _Offset = new System.Drawing.PointF(0, 0);
public static string PaperSize // C2020-002 paper size is now set in the format files
{ get; set; } = "LETTER";
public Rectangle PaperSizeRec => PDFPageSize.UsePaperSize(PaperSize); // default paper size = PageSize.LETTER
public static bool PdfDebug { get; set; } = true;
private static System.Drawing.PointF _Offset = new System.Drawing.PointF(0, 0);
public static System.Drawing.PointF Offset
{
get { return Rtf2Pdf._Offset; }
set { Rtf2Pdf._Offset = value; }
get { return _Offset; }
set { _Offset = value; }
}
public static float FillWidth = 0; // max text width (used in autoToc code)
private static int _TextAtCounter = 0;
public static int TextAtCounter
public static float FillWidth = 0; // max text width (used in autoToc code)
public static int TextAtCounter { get; set; } = 0;
private static int NextTextAtCounter => ++TextAtCounter;
public class VlnSplitCharacter : ISplitCharacter
{
get { return Rtf2Pdf._TextAtCounter; }
set { Rtf2Pdf._TextAtCounter = value; }
}
private static int NextTextAtCounter
{
get
{
int retval = ++TextAtCounter;
//if (InList(retval, 17)) Console.WriteLine("TextAt {0}", retval);
return retval;
}
}
public class VlnSplitCharacter : ISplitCharacter
{
public bool IsSplitCharacter(int start, int current, int end, char[] cc, PdfChunk[] ck)
{
return (cc[current] == ' ');
}
public bool IsSplitCharacter(char c)
{
return (c == ' ');
}
}
private static TableScrunching _AllowTableScrunching = TableScrunching.AllPhases; // RHM20150507 Table Scrunch
public static TableScrunching AllowTableScrunching
{
get { return Rtf2Pdf._AllowTableScrunching; }
set { Rtf2Pdf._AllowTableScrunching = value; }
}
public static bool GetTableScrunchingStatus(TableScrunching val)
{
return (val & _AllowTableScrunching) == val;
}
public static VlnSplitCharacter mySplitter = new VlnSplitCharacter();
public bool IsSplitCharacter(int start, int current, int end, char[] cc, PdfChunk[] ck) => (cc[current] == ' ');
public bool IsSplitCharacter(char c) => (c == ' ');
}
public static TableScrunching AllowTableScrunching { get; set; } = TableScrunching.AllPhases;
public static bool GetTableScrunchingStatus(TableScrunching val) => (val & AllowTableScrunching) == val;
public static VlnSplitCharacter mySplitter = new VlnSplitCharacter();
public static string ChunkTextAttributesInfo(Chunk chk1) // C2018-004 create meta file for baseline compares
{
string rtnval = "Atrbs:";
@@ -180,11 +129,8 @@ namespace Volian.Print.Library
return rtnval;
}
public static int _lastPageNum = 0; // C2018-004 create meta file for baseline compares
public static float TextAt(PdfContentByte cb, Paragraph iParagraph, float x, float y, float width, float height, string debugText, float yBottomMargin)
{
return TextAt(cb, iParagraph, x, y, width, height, debugText, yBottomMargin, null);
}
public static float TextAt(PdfContentByte cb, Paragraph iParagraph, float x, float y, float width, float height, string debugText, float yBottomMargin, int? itmID)
public static float TextAt(PdfContentByte cb, Paragraph iParagraph, float x, float y, float width, float height, string debugText, float yBottomMargin) => TextAt(cb, iParagraph, x, y, width, height, debugText, yBottomMargin, null);
public static float TextAt(PdfContentByte cb, Paragraph iParagraph, float x, float y, float width, float height, string debugText, float yBottomMargin, int? itmID)
{
if (cb.PdfDocument.PageNumber != _lastPageNum) // C2018-004 create meta file for baseline compares
{
@@ -192,7 +138,7 @@ namespace Volian.Print.Library
_lastPageNum = cb.PdfDocument.PageNumber;
}
VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper;
PdfLayer textLayer = _MyPageHelper == null ? null : _MyPageHelper.TextLayer;
PdfLayer textLayer = _MyPageHelper?.TextLayer;
float left = x + Offset.X;
float top = y + Offset.Y;
// B2020-059 - Barakah 1T4-OP-EOP-AC-0001 Instructions and Contingency Actions section step 6 last table in RNO is compressed - cause first bullet substep in AER to print on top HLS text
@@ -224,8 +170,6 @@ namespace Volian.Print.Library
chk.Attributes.Add("NoSplit", false);
}
}
float right = left + width;
float bottom = top - height;
ColumnText myColumnText = new ColumnText(cb);
myColumnText.SetSimpleColumn(left, top, left + width, yBottomMargin);
myColumnText.AddElement(iParagraph);
@@ -259,22 +203,22 @@ namespace Volian.Print.Library
}
return myColumnText.YLine;
}
//For Debugging:
private static bool InList(int value, params int [] examples)
{
foreach (int ex in examples)
if (ex == value) return true;
return false;
}
public static float FigureAt(PdfContentByte cb, iTextSharp.text.Image image, float x, float y, float width, float height, string debugText, float yBottommargin, bool hasBorder, int itmID, float sixLinesPerInch)
public static float FigureAt(PdfContentByte cb, iTextSharp.text.Image image, float x, float y, float width, float height, string debugText, bool hasBorder, int itmID, float sixLinesPerInch)
{
if (cb.PdfDocument.PageNumber != _lastPageNum) // C2018-004 create meta file for baseline compares
{
Volian.Base.Library.BaselineMetaFile.WriteLine("Page Change from {0} to {1}", _lastPageNum, cb.PdfDocument.PageNumber);
_lastPageNum = cb.PdfDocument.PageNumber;
}
VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper;
PdfLayer textLayer = _MyPageHelper == null ? null : _MyPageHelper.TextLayer;
float left = x + Offset.X;
PdfLayer textLayer = !(cb.PdfWriter.PageEvent is VlnSvgPageHelper _MyPageHelper) ? null : _MyPageHelper.TextLayer;
float left = x + Offset.X;
float top = y + Offset.Y + sixLinesPerInch;
float bottom = top - height;
image.ScaleAbsoluteWidth(width);
@@ -309,21 +253,16 @@ namespace Volian.Print.Library
return bottom;
}
private static float _GridTopAdjust = -10;
public static float GridTopAdjust
{
get { return _GridTopAdjust; }
set { _GridTopAdjust = value; }
}
public static float GridAt(PdfContentByte cb, vlnTable myGrid, float x, float y, float width, float height, string debugText, float yBottomMargin, bool hasBorder)
public static float GridTopAdjust { get; set; } = -10;
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "debugText Kept For Debugging")]
public static float GridAt(PdfContentByte cb, vlnTable myGrid, float x, float y, float width, float height, string debugText, float yBottomMargin, bool hasBorder)
{
if (cb.PdfDocument.PageNumber != _lastPageNum) // C2018-004 create meta file for baseline compares
{
Volian.Base.Library.BaselineMetaFile.WriteLine("Page Change from {0} to {1}", _lastPageNum, cb.PdfDocument.PageNumber);
_lastPageNum = cb.PdfDocument.PageNumber;
}
//VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper; // RHM20150507 Table Scrunch
//PdfLayer textLayer = _MyPageHelper == null ? null : _MyPageHelper.TextLayer; // RHM20150507 Table Scrunch
float left = x + Offset.X;
float top = y + Offset.Y;
float right = left + width;
@@ -331,7 +270,6 @@ namespace Volian.Print.Library
int paperSizePoints = PDFPageSize.PaperSizePoints(myGrid.MyFlexGrid.MyDVI.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize); // C2020-002 paper size is now set in the format files
ColumnText myColumnText = new ColumnText(cb);
myColumnText.SetSimpleColumn(left, top, left + width, yBottomMargin);
//if (textLayer != null) cb.BeginLayer(textLayer); // RHM20150507 Table Scrunch
// C2018-004 create meta file for baseline compares
if (top + GridTopAdjust > paperSizePoints) // B2019-110 Table continued on the next page - off the top of page
{
@@ -340,14 +278,12 @@ namespace Volian.Print.Library
}
Volian.Base.Library.BaselineMetaFile.WriteLine("GD left={0} top={1} right={2} bottom={3} Mygrid.ItmID={4}", left, top + GridTopAdjust, right, bottom, myGrid.ItemID);
myGrid.ToPdf(myColumnText, left, top + GridTopAdjust);
//if (textLayer != null) cb.EndLayer(); // RHM20150507 Table Scrunch
return bottom;
}
internal static void DrawPdfDebug(PdfContentByte cb, float left, float top, float right, float bottom, string debugText, float yDescent)
{
VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper;
PdfLayer debugLayer = _MyPageHelper == null ? null : _MyPageHelper.DebugLayer;
if (debugLayer == null) return;
PdfLayer debugLayer = !(cb.PdfWriter.PageEvent is VlnSvgPageHelper _MyPageHelper) ? null : _MyPageHelper.DebugLayer;
if (debugLayer == null) return;
System.Drawing.Color sysColor = PrintOverride.OverrideDebugColor(System.Drawing.Color.Gray);
cb.SaveState();
cb.BeginLayer(debugLayer);
@@ -374,19 +310,17 @@ namespace Volian.Print.Library
cb.RestoreState();
}
internal static float RtfRawAt(PdfContentByte cb, System.Drawing.Image image, float XOffset, float yLocation, float Width, float Height, string debug, float yBottomMargin, bool hasBorder)
internal static float RtfRawAt(PdfContentByte cb, System.Drawing.Image image, float XOffset, float yLocation, float Width, float Height, string debug, bool hasBorder)
{
VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper;
PdfLayer textLayer = _MyPageHelper == null ? null : _MyPageHelper.TextLayer;
float left = XOffset + Offset.X;
PdfLayer textLayer = !(cb.PdfWriter.PageEvent is VlnSvgPageHelper _MyPageHelper) ? null : _MyPageHelper.TextLayer;
float left = XOffset + Offset.X;
float top = yLocation + Offset.Y;
float bottom = top - Height;
float scale = .6f;
iTextSharp.text.Image it_image=null;
try
{
it_image = iTextSharp.text.Image.GetInstance(image,iTextSharp.text.Color.WHITE);
float itxtWid = scale * Width * 300 / 72;
try
{
iTextSharp.text.Image it_image = iTextSharp.text.Image.GetInstance(image, iTextSharp.text.Color.WHITE);
float itxtWid = scale * Width * 300 / 72;
float itxtHt = scale * Height * 300 / 72;
it_image.ScaleAbsoluteWidth(scale * Width);
it_image.ScaleAbsoluteHeight(scale * Height);
+88 -145
View File
@@ -1,18 +1,13 @@
using System;
using System.Collections.Generic;
using System.Text;
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.factories;
using Itenso.Rtf;
using Itenso.Rtf.Parser;
using Itenso.Rtf.Interpreter;
//using Itenso.Rtf.Model;
using Itenso.Rtf.Support;
using Microsoft.Win32;
using Volian.Base.Library;
using System.Text.RegularExpressions;
using VEPROMS.CSLA.Library;
using System.Linq;
namespace Volian.Print.Library
{
@@ -21,17 +16,13 @@ namespace Volian.Print.Library
public static bool CompressSub = false;
public static bool CompressSuper = false;
public static bool CompressPropSubSup = false;
private static System.Drawing.Color _TextColor = System.Drawing.Color.Empty;
public static System.Drawing.Color TextColor
public static System.Drawing.Color TextColor { get; set; } = System.Drawing.Color.Empty;
public static System.Drawing.Color OverrideTextColor(System.Drawing.Color color)
{
get { return _TextColor; }
set { _TextColor = value; }
}
public static System.Drawing.Color OverrideTextColor(System.Drawing.Color color)
{
if (_TextColor == System.Drawing.Color.Empty)
if (TextColor == System.Drawing.Color.Empty)
return color;
return _TextColor;
return TextColor;
}
private static System.Drawing.Color _SvgColor = System.Drawing.Color.Empty;
public static System.Drawing.Color SvgColor
@@ -45,29 +36,21 @@ namespace Volian.Print.Library
return color;
return _SvgColor;
}
private static System.Drawing.Color _BoxColor = System.Drawing.Color.Empty;
public static System.Drawing.Color BoxColor
public static System.Drawing.Color BoxColor { get; set; } = System.Drawing.Color.Empty;
public static System.Drawing.Color OverrideBoxColor(System.Drawing.Color color)
{
get { return _BoxColor; }
set { _BoxColor = value; }
}
public static System.Drawing.Color OverrideBoxColor(System.Drawing.Color color)
{
if (_BoxColor == System.Drawing.Color.Empty)
if (BoxColor == System.Drawing.Color.Empty)
return color;
return _BoxColor;
return BoxColor;
}
private static System.Drawing.Color _ChangeBarColor = System.Drawing.Color.Empty;
public static System.Drawing.Color ChangeBarColor
public static System.Drawing.Color ChangeBarColor { get; set; } = System.Drawing.Color.Empty;
public static System.Drawing.Color OverrideChangeBarColor(System.Drawing.Color color)
{
get { return _ChangeBarColor; }
set { _ChangeBarColor = value; }
}
public static System.Drawing.Color OverrideChangeBarColor(System.Drawing.Color color)
{
if (_ChangeBarColor == System.Drawing.Color.Empty)
if (ChangeBarColor == System.Drawing.Color.Empty)
return color;
return _ChangeBarColor;
return ChangeBarColor;
}
private static System.Drawing.Color _DebugColor = System.Drawing.Color.Empty;
public static System.Drawing.Color DebugColor
@@ -93,43 +76,17 @@ namespace Volian.Print.Library
public class Rtf2iTextSharp : RtfVisualVisitorBase
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private bool _HasIndent = false;
public bool HasIndent
{
get { return _HasIndent; }
set { _HasIndent = value; }
}
private IRtfDocument _RtfDoc;
private Paragraph _MyParagraph = new Paragraph();
public bool HasIndent { get; set; } = false;
private readonly IRtfDocument _RtfDoc;
private readonly Paragraph _MyParagraph = new Paragraph();
private iTextSharp.text.Font _MyFont;
// Allow for definition of a default font: if the font is not proportional, this gets set.
// It is needed to set the chunk's font if the first character of a cell is a hardspace (or various
// other special cases (see its use below). Without this, pdfs were using the Helvetica font,
// which is a default itextsharp font (this was causing a problem for HLP, their pdfs could not
// contain a Helvetica font when putting them in their production environment).
private iTextSharp.text.Font _DefaultFont;
public iTextSharp.text.Font DefaultFont
{
get { return _DefaultFont; }
set { _DefaultFont = value; }
}
private string _MyDebugID = null;
public string MyDebugID
{
get { return _MyDebugID; }
set { _MyDebugID = value; }
}
public bool DoPdfLinks = false;
// public Rtf2iTextSharp(IRtfDocument rtfDoc, Document doc, PdfWriter writer)
public Rtf2iTextSharp(IRtfDocument rtfDoc)
{
if (rtfDoc == null)
throw new ArgumentNullException("rtfDoc");
_RtfDoc = rtfDoc;
}
public Paragraph Convert()
public iTextSharp.text.Font DefaultFont { get; set; }
public string MyDebugID { get; set; } = null;
public bool DoPdfLinks = false;
public Rtf2iTextSharp(IRtfDocument rtfDoc) => _RtfDoc = rtfDoc ?? throw new ArgumentNullException("rtfDoc");
public Paragraph Convert()
{
int profileDepth = ProfileTimer.Push(">>>> Rtf2ITextSharp.Convert");
_MyParagraph.Clear();
@@ -138,7 +95,6 @@ namespace Volian.Print.Library
{
visual.Visit(this);
}
//_MyParagraph.SetLeading(0, 1);
ProfileTimer.Pop(profileDepth);
return _MyParagraph;
}
@@ -177,6 +133,7 @@ namespace Volian.Print.Library
_lastWasLineBreak = 0; // B2017-191 reset hard return count
break;
}
//For Debugging:
//_MyParagraph.Add(string.Format("<{0}>", visualBreak.BreakKind.ToString()));
}
private void AddChunk(string str, iTextSharp.text.Font font)
@@ -188,8 +145,9 @@ namespace Volian.Print.Library
}
protected override void DoVisitSpecial(IRtfVisualSpecialChar visualSpecialChar)
{
//_MyParagraph.Add(string.Format("<special {0}>", visualSpecialChar.CharKind.ToString()));
iTextSharp.text.Font activeFont = _MyFont ?? DefaultFont;
//For Debugging:
//_MyParagraph.Add(string.Format("<special {0}>", visualSpecialChar.CharKind.ToString()));
iTextSharp.text.Font activeFont = _MyFont ?? DefaultFont;
switch (visualSpecialChar.CharKind)
{
case RtfVisualSpecialCharKind.Bullet:
@@ -248,23 +206,15 @@ namespace Volian.Print.Library
if (c <= '\x7F') return false;
return true;
}
//For Debugging:
private bool ContainsAnySymbols(string p)
{
foreach (char c in p)
if (c > '\x7F' && c != '\xA0' && c != '\xB0') return true;
return false;
}
// The funcction below was used for the first few lines of DoVisitText which have been commented-out
//private object FixText(string str)
//{
// StringBuilder sb = new StringBuilder();
// foreach (char c in str)
// if (c < ' ' || c > '\xFF')
// sb.Append(string.Format("[{0}]", (int)c));
// else
// sb.Append(c);
// return sb.ToString();
//}
// ParseLink & GetDefaultItemInfo (which used to be in vlnParagraph) support coding that was added to DoVisitText for
// doing pdflink for each transition/ro in a step, see bug B2019-052
private RoUsageInfo _Roui = null;
@@ -278,8 +228,9 @@ namespace Volian.Print.Library
if (_LinkInfoText.Contains(@"\v"))
throw new Exception("LinkText.ParseLink found RTF token");
Match m = Regex.Match(_LinkInfoText, @"[#]Link:([A-Za-z]*):(.*)");
string _MyValue = m.Groups[1].Value;
string _MyLink = "#Link:" + m.Groups[2].Value + ":" + m.Groups[3].Value;
//For Debugging:
//string _MyValue = m.Groups[1].Value;
//string _MyLink = "#Link:" + m.Groups[2].Value + ":" + m.Groups[3].Value;
switch (m.Groups[1].Value)
{
case "ReferencedObject":
@@ -319,7 +270,7 @@ namespace Volian.Print.Library
if (myItemInfo.IsProcedure && myItemInfo.Sections != null)
{
SectionInfo siProcedureSteps = null;
foreach (SectionInfo si in myItemInfo.Sections)
foreach (SectionInfo si in myItemInfo.Sections.OfType<SectionInfo>())
{
if (si.IsDefaultSection)
{
@@ -347,7 +298,7 @@ namespace Volian.Print.Library
private static int chkStart = -1;
protected override void DoVisitText(IRtfVisualText visualText)
{
//Code to find text (non-symbol) being output with a symbol font
//Debugging Code to find text (non-symbol) being output with a symbol font
//if(visualText.Format.Font.Name=="VESymbFix" && visualText.Text.Length > 1)
//{
// string s = visualText.Text;
@@ -375,44 +326,43 @@ namespace Volian.Print.Library
{
try
{
Chunk chk = _MyParagraph.Chunks[i] as Chunk;
if (chk != null)
{
if (_linkType == 2 && _Ti != null) // transition
{
ItemInfo tiDefault = GetDefaultItemInfo(_Ti.MyItemToID);
ItemInfo from = _Ti.MyContent.ContentItems[0];
if (_Ti.MyItemToID.MyProcedure.ItemID == from.MyProcedure.ItemID &&
!((from.ActiveSection.MyConfig as SectionConfig).Section_IsFoldout == "Y")) //C2019-042 Section_IsFoldout checks Section Number, Section Title, and use of check box
{ // Local Go To
// B2020-028, 029 and 030: all were related to print of supplemental information when printing with
// pdf links. The pdf links in the temporary supinfo pdf caused a crash on save of file because they didn't exist.
if (_Ti.MyItemToID.MyContent.Type > 9999 && !from.IsInSupInfo) // internal to this file
{
chk.SetLocalGoto(string.Format("ItemID={0}", tiDefault.ItemID));
chk.SetBackground(Color.CYAN);
chk.SetBackground(new Color(System.Drawing.Color.LightCyan));
}
}
else if (_Ti != null && !from.IsInSupInfo) // Remote Go To. Added SupInfo check for B2020 bugs (see above)
{
// C2024-009 add PDF file prefix and suffix if available to the PDF file name in the transition reference.
DocVersionConfig dvc = _Ti.MyItemToID.MyProcedure.MyDocVersion.DocVersionConfig;
string remotePDFName = dvc.Print_PDFFilePrefix + _Ti.MyItemToID.MyProcedure.DisplayNumber.Replace("/", "_") + dvc.Print_PDFFileSuffix + ".pdf";
chk.SetRemoteGoto(remotePDFName, string.Format("ItemID={0}", tiDefault.ItemID));
chk.SetBackground(new Color(System.Drawing.Color.PeachPuff));
}
}
else if (_linkType == 1 && _Roui != null && !_Roui.MyContent.ContentItems[0].IsInSupInfo) // referenced object. Added SupInfo check for B2020 bugs (see above)
{
if (_Roui.ROID.Substring(0, 4) != "FFFF")
{
chk.SetRemoteGoto("completeroreport.pdf", string.Format("ROID={0}", _Roui.ROID.Substring(0, 12).ToUpper()));
chk.SetBackground(new Color(System.Drawing.Color.LightGreen));
}
}
}
}
if (_MyParagraph.Chunks[i] is Chunk chk)
{
if (_linkType == 2 && _Ti != null) // transition
{
ItemInfo tiDefault = GetDefaultItemInfo(_Ti.MyItemToID);
ItemInfo from = _Ti.MyContent.ContentItems[0];
if (_Ti.MyItemToID.MyProcedure.ItemID == from.MyProcedure.ItemID &&
!((from.ActiveSection.MyConfig as SectionConfig).Section_IsFoldout == "Y")) //C2019-042 Section_IsFoldout checks Section Number, Section Title, and use of check box
{ // Local Go To
// B2020-028, 029 and 030: all were related to print of supplemental information when printing with
// pdf links. The pdf links in the temporary supinfo pdf caused a crash on save of file because they didn't exist.
if (_Ti.MyItemToID.MyContent.Type > 9999 && !from.IsInSupInfo) // internal to this file
{
chk.SetLocalGoto(string.Format("ItemID={0}", tiDefault.ItemID));
chk.SetBackground(Color.CYAN);
chk.SetBackground(new Color(System.Drawing.Color.LightCyan));
}
}
else if (_Ti != null && !from.IsInSupInfo) // Remote Go To. Added SupInfo check for B2020 bugs (see above)
{
// C2024-009 add PDF file prefix and suffix if available to the PDF file name in the transition reference.
DocVersionConfig dvc = _Ti.MyItemToID.MyProcedure.MyDocVersion.DocVersionConfig;
string remotePDFName = $"{dvc.Print_PDFFilePrefix}{_Ti.MyItemToID.MyProcedure.DisplayNumber.Replace("/", "_")}{dvc.Print_PDFFileSuffix}.pdf";
chk.SetRemoteGoto(remotePDFName, string.Format("ItemID={0}", tiDefault.ItemID));
chk.SetBackground(new Color(System.Drawing.Color.PeachPuff));
}
}
else if (_linkType == 1 && _Roui != null && !_Roui.MyContent.ContentItems[0].IsInSupInfo) // referenced object. Added SupInfo check for B2020 bugs (see above)
{
if (_Roui.ROID.Substring(0, 4) != "FFFF")
{
chk.SetRemoteGoto("completeroreport.pdf", string.Format("ROID={0}", _Roui.ROID.Substring(0, 12).ToUpper()));
chk.SetBackground(new Color(System.Drawing.Color.LightGreen));
}
}
}
}
catch (Exception ex)
{
_MyLog.ErrorFormat("Error creating pdf links {0}", ex.Message);
@@ -630,6 +580,7 @@ namespace Volian.Print.Library
}
}
//For Debugging:
private string ShowSpecialCharacters(string p)
{
StringBuilder sb = new StringBuilder();
@@ -642,31 +593,23 @@ namespace Volian.Print.Library
sb.Append(c);
}
return sb.ToString();
}// DoVisitText
}
// ----------------------------------------------------------------------
protected override void DoVisitImage(IRtfVisualImage visualImage)
{
//_MyParagraph.Add(new Chunk("<Image>"));
//DateTime dt1 = DateTime.Now;
//System.Drawing.Image img2 = visualImage.ImageForDrawing;
//Console.WriteLine("1 Time Span {0}", TimeSpan.FromTicks(DateTime.Now.Ticks - dt1.Ticks).TotalMilliseconds);
//img2.Save(@"c:\datacvrt\x.png");
System.IO.MemoryStream ms = new System.IO.MemoryStream();
{
//Console.WriteLine("2 Time Span {0}", TimeSpan.FromTicks(DateTime.Now.Ticks - dt1.Ticks).TotalMilliseconds);
//Console.WriteLine("Size {0}", visualImage.ImageForDrawing.Size);
visualImage.ImageForDrawing.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
//Console.WriteLine("3 Time Span {0}", TimeSpan.FromTicks(DateTime.Now.Ticks - dt1.Ticks).TotalMilliseconds);
ms.Seek(0, System.IO.SeekOrigin.Begin);
//Console.WriteLine("4 Time Span {0}", TimeSpan.FromTicks(DateTime.Now.Ticks - dt1.Ticks).TotalMilliseconds);
iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(ms);
//Console.WriteLine("5 Time Span {0}", TimeSpan.FromTicks(DateTime.Now.Ticks - dt1.Ticks).TotalMilliseconds);
_MyParagraph.Add(img);
//Console.WriteLine("6 Time Span {0}", TimeSpan.FromTicks(DateTime.Now.Ticks - dt1.Ticks).TotalMilliseconds);
_lastWasLineBreak = 0; // B2017-191 reset hard return count
} // DoVisitImage
using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
{
visualImage.ImageForDrawing.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
ms.Seek(0, System.IO.SeekOrigin.Begin);
iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(ms);
_MyParagraph.Add(img);
}
}
_lastWasLineBreak = 0; // B2017-191 reset hard return count
}
}
}
File diff suppressed because it is too large Load Diff
@@ -106,6 +106,7 @@
<ItemGroup>
<Compile Include="CompleteRORpt.cs" />
<Compile Include="CPSGen.cs" />
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="Grid2Pdf.cs" />
<Compile Include="MergedPdf.cs" />
<Compile Include="PageCount.cs" />
+26 -45
View File
@@ -1,46 +1,26 @@
using System;
using System.Collections.Generic;
using System.Text;
using iTextSharp.text;
using iTextSharp.text.pdf;
using System.IO;
using Microsoft.Win32;
using Volian.Base.Library;
namespace Volian.Print.Library
{
public class pdf
{
private Document _MyDocument;
public Document MyDocument
public Document MyDocument { get; set; }
public PdfWriter MyWriter { get; set; }
public string MyFileName { get; set; }
public PdfContentByte ContentByte => MyWriter.DirectContent;
public pdf(string myFileName)
{
get { return _MyDocument; }
set { _MyDocument = value; }
}
private PdfWriter _MyWriter;
public PdfWriter MyWriter
{
get { return _MyWriter; }
set { _MyWriter = value; }
}
private string _MyFileName;
public string MyFileName
{
get { return _MyFileName; }
set { _MyFileName = value; }
}
public PdfContentByte ContentByte
{
get { return _MyWriter.DirectContent; }
}
public pdf(string myFileName)
{
_MyFileName = myFileName;
_MyDocument = new Document(PageSize.LETTER);
MyFileName = myFileName;
MyDocument = new Document(PageSize.LETTER);
try
{
_MyWriter = PdfWriter.GetInstance(_MyDocument, new FileStream(myFileName, FileMode.Create));
_MyWriter.SetAtLeastPdfVersion(PdfWriter.VERSION_1_7);
MyWriter = PdfWriter.GetInstance(MyDocument, new FileStream(myFileName, FileMode.Create));
MyWriter.SetAtLeastPdfVersion(PdfWriter.VERSION_1_7);
}
catch (Exception ex)
{
@@ -49,24 +29,21 @@ namespace Volian.Print.Library
}
public pdf(string myFileName, Rectangle mySize)
{
_MyFileName = myFileName;
_MyDocument = new Document(mySize);
MyFileName = myFileName;
MyDocument = new Document(mySize);
try
{
_MyWriter = PdfWriter.GetInstance(_MyDocument, new FileStream(myFileName, FileMode.Create));
_MyWriter.SetAtLeastPdfVersion(PdfWriter.VERSION_1_7);
MyWriter = PdfWriter.GetInstance(MyDocument, new FileStream(myFileName, FileMode.Create));
MyWriter.SetAtLeastPdfVersion(PdfWriter.VERSION_1_7);
}
catch (Exception ex)
{
Console.WriteLine("{0} - {1}\r\n{2}", ex.GetType().Name, ex.Message, ex.StackTrace);
}
}
public void Close()
{
MyDocument.Close();
}
private Color _WatermarkColor = Color.BLUE;
private float _WatermarkOpacity = .10F;
public void Close() => MyDocument.Close();
private readonly Color _WatermarkColor = Color.BLUE;
private readonly float _WatermarkOpacity = .10F;
public void WatermarkPageNumber(int pageNumber)
{
Rectangle pageSize = ContentByte.PdfWriter.PageSize; // Get page size
@@ -84,9 +61,11 @@ namespace Volian.Print.Library
ContentByte.SetLineWidth(.5F);
ContentByte.SetFontAndSize(myBasefont, myFontSize);// Set font and size
ContentByte.SetColorStroke(_WatermarkColor);
PdfGState gs2 = new PdfGState();
gs2.StrokeOpacity = _WatermarkOpacity;
ContentByte.SetGState(gs2);
PdfGState gs2 = new PdfGState
{
StrokeOpacity = _WatermarkOpacity
};
ContentByte.SetGState(gs2);
ContentByte.ShowTextAlignedKerned(PdfContentByte.ALIGN_CENTER, strPage, pageSize.Width / 2, 0, 0);// Draw the text
ContentByte.EndText();
ContentByte.FillStroke(); // Controlled by TextRenderMode above
@@ -108,9 +87,11 @@ namespace Volian.Print.Library
{
PdfPatternPainter myPatternPainter;
myPatternPainter = ContentByte.CreatePattern(radius * 4, radius * 2, radius * 4, radius * 2);
PdfGState gState = new PdfGState();
gState.FillOpacity = _WatermarkOpacity;
myPatternPainter.SetGState(gState);
PdfGState gState = new PdfGState
{
FillOpacity = _WatermarkOpacity
};
myPatternPainter.SetGState(gState);
myPatternPainter.SetColorFill(_WatermarkColor);
myPatternPainter.Rectangle(0, 0, radius, radius);
myPatternPainter.Rectangle(radius * 2, radius, radius, radius);
+7 -18
View File
@@ -1,27 +1,16 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Volian.Print.Library
{
public class pkParagraph
{
private vlnParagraph _MyParagraph;
public vlnParagraph MyParagraph
{
get { return _MyParagraph; }
}
private pkParagraphs _MyChildren;
public pkParagraphs MyChildren
{
get { return _MyChildren; }
}
private pkParagraphs _MyCautionsAndNotes;
public pkParagraphs MyCautionsAndNotes
{
get { return _MyCautionsAndNotes; }
}
public pkParagraph(vlnParagraph myParagraph)
private readonly vlnParagraph _MyParagraph;
public vlnParagraph MyParagraph => _MyParagraph;
private readonly pkParagraphs _MyChildren;
public pkParagraphs MyChildren => _MyChildren;
private readonly pkParagraphs _MyCautionsAndNotes;
public pkParagraphs MyCautionsAndNotes => _MyCautionsAndNotes;
public pkParagraph(vlnParagraph myParagraph)
{
_MyParagraph = myParagraph;
_MyChildren = new pkParagraphs();
+81 -115
View File
@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Text;
using System.Drawing;
using iTextSharp.text.pdf;
using iTextSharp.text;
using VEPROMS.CSLA.Library;
@@ -12,23 +11,11 @@ namespace Volian.Print.Library
public partial class vlnBox : vlnPrintObject
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private int _LineType; /* how to represent?? */
private System.Drawing.Color _Color;
public System.Drawing.Color Color
{
get { return _Color; }
set { _Color = value; }
}
private Box _MyBox;
public Box MyBox
{
get { return _MyBox; }
set { _MyBox = value; }
}
// the following two fields are used if 'boxed' step, thus
// no 'Box' was defined in format file.
public override float Height
public Box MyBox { get; set; }
// the following two fields are used if 'boxed' step, thus
// no 'Box' was defined in format file.
public override float Height
{
get
{
@@ -41,26 +28,13 @@ namespace Volian.Print.Library
public string DefBox = null;
public float DefEnd = 0;
private bool _ContainsPageBreak = false;
public bool ContainsPageBreak
{
get { return _ContainsPageBreak; }
set { _ContainsPageBreak = value; }
}
private bool _DoubleBoxHls = false; // BGE double lined box around HLS
public bool DoubleBoxHls
{
get { return _DoubleBoxHls; }
set { _DoubleBoxHls = value; }
}
public const string DOUBLEboxHLS = "DoubleBox";
public bool ContainsPageBreak { get; set; } = false;
public bool DoubleBoxHls { get; set; } = false;
public const string DOUBLEboxHLS = "DoubleBox";
//private bool _DoBottom = true;
public vlnBox()
{
}
public vlnBox(vlnParagraph paragraph)
{
}
public const string BoxThin = "\x2510.\x2500.\x250c.\x2502. . .\x2518.\x2514. .\x2500. . ";
const string BoxThick = "\x2584.\x2584.\x2584.\x2588. . .\x2580.\x2580. .\x2580. . ";
const string BoxDouble = "\x2557.\x2550.\x2554.\x2551. . .\x255D.\x255A. .\x2550. . ";
@@ -95,10 +69,9 @@ namespace Volian.Print.Library
if (MyBox == null) return yPageStart;
cb.SaveState();
VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper;
PdfLayer textLayer = _MyPageHelper == null ? null : _MyPageHelper.TextLayer;
PdfLayer textLayer = _MyPageHelper?.TextLayer;
if (textLayer != null) cb.BeginLayer(textLayer);
MyContentByte = cb;
//Console.WriteLine("'{0}','{1}'", CharToAsc(MyBox.BoxStyle), MyParent.MyItemInfo.ShortPath);
float top = CalculateYOffset(yPageStart, yTopMargin) - (7*MyPageHelper.YMultiplier);
float bottom = top - (Height * MyPageHelper.YMultiplier);
float left = (float)((MyBox.Start ?? 0) + MyParent.MyItemInfo.MyDocStyle.Layout.LeftMargin);
@@ -157,7 +130,7 @@ namespace Volian.Print.Library
else
{
const float llxOffset = 3;
float lineThickness = 0;
float lineThickness;
switch (MyBox.BoxStyle)
{
case BoxThin:
@@ -331,23 +304,23 @@ namespace Volian.Print.Library
// create a new font without any styles such as underline.
E_Style es = ((vef.Style & E_Style.Bold) == E_Style.Bold) ? E_Style.Bold : E_Style.None;
// if the box has a font, use it - otherwise use this item info's font
VE_Font vf = null;
bool UseBoxFont = false;
try
bool UseBoxFont = false;
try
{
UseBoxFont = MyParent.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionPrintData.DiffContActBox;
}
catch // done this way in case one of the format properties is null in the previous statement, UseBoxFont will be false.
{
}
if (UseBoxFont)
vf = new VE_Font(vef.Family, (int)vef.Size, es, (float)MyParent.MyItemInfo.FormatStepData.Font.CPI);
else
vf = new VE_Font(MyParent.MyItemInfo.FormatStepData.Font.Family, (int)MyParent.MyItemInfo.FormatStepData.Font.Size, es, (float)MyParent.MyItemInfo.FormatStepData.Font.CPI);
// if the box has a font, use it - otherwise use this item info's font
VE_Font vf;
if (UseBoxFont)
vf = new VE_Font(vef.Family, (int)vef.Size, es, (float)MyParent.MyItemInfo.FormatStepData.Font.CPI);
else
vf = new VE_Font(MyParent.MyItemInfo.FormatStepData.Font.Family, (int)MyParent.MyItemInfo.FormatStepData.Font.Size, es, (float)MyParent.MyItemInfo.FormatStepData.Font.CPI);
// To find the length of the line, account for the length of the upper right corner also (BXURC)
int urcLen = MyBox.BXHorz[MyBox.BXHorz.Length - 1] == ' ' && MyBox.BXURC[0] == ' ' ? 1 : MyBox.BXURC.Length;
// To find the length of the line, account for the length of the upper right corner also (BXURC)
int urcLen = MyBox.BXHorz[MyBox.BXHorz.Length - 1] == ' ' && MyBox.BXURC[0] == ' ' ? 1 : MyBox.BXURC.Length;
float endHorz = (float)MyBox.End - (float)MyBox.Start - (float)(urcLen * (72 / vf.CPI));
float bxHorzTextWidth = GetTextWidth(vf, MyBox.BXHorz); // get the width of the BXHorz string
@@ -355,21 +328,21 @@ namespace Volian.Print.Library
StringBuilder sb = new StringBuilder();
sb.Append(MyBox.BXULC);
float size = GetTextWidth(vf, MyBox.BXULC); //(float)(MyBox.BXULC.Length * (72 / vf.CPI));
string bxstr = null;
if (!ContainsPageBreak) // Only do top line if there is no page break.
string bxstr;
if (!ContainsPageBreak) // Only do top line if there is no page break.
{
while (size < endHorz)
{
sb.Append(MyBox.BXHorz);
size = size + bxHorzTextWidth; //(float)(MyBox.BXHorz.Length * (72 / vf.CPI));
size += bxHorzTextWidth; //(float)(MyBox.BXHorz.Length * (72 / vf.CPI));
}
// Tack on the right upper corner. For some formats, the upper right corner in the
// had the first character as a space, this would put two spaces in a row at the
// end of the string, so remove the space before tacking on the upper right corner:
bxstr = sb.ToString();
if (bxstr[bxstr.Length - 1] == ' ' && MyBox.BXURC[0] == ' ') bxstr = bxstr.TrimEnd();
bxstr = bxstr + MyBox.BXURC;
size = size + GetTextWidth(vf, MyBox.BXURC);//(float)((MyBox.BXURC.Length) * (72 / vf.CPI));
bxstr += MyBox.BXURC;
size += GetTextWidth(vf, MyBox.BXURC);//(float)((MyBox.BXURC.Length) * (72 / vf.CPI));
Rtf = GetRtf(bxstr, vf);
IParagraph = null; // set to null so that next access of IParagraph sets the Rtf.
Rtf2Pdf.TextAt(cb, IParagraph, left, top, size + 10, 100, "", yBottomMargin);
@@ -384,15 +357,15 @@ namespace Volian.Print.Library
while (size < endHorz)
{
sb.Append(MyBox.BXHorz);
size = size + bxHorzTextWidth;//(float)(MyBox.BXHorz.Length * (72 / vf.CPI));
size += bxHorzTextWidth;//(float)(MyBox.BXHorz.Length * (72 / vf.CPI));
}
bxstr = sb.ToString().TrimEnd() + MyBox.BXLRC;
size = size + GetTextWidth(vf, MyBox.BXLRC); //(float)((MyBox.BXLRC.Length) * (72 / vf.CPI));
size += GetTextWidth(vf, MyBox.BXLRC); //(float)((MyBox.BXLRC.Length) * (72 / vf.CPI));
Rtf = GetRtf(bxstr, vf);
IParagraph = null; // set to null so that next access of IParagraph sets the Rtf.
Rtf2Pdf.TextAt(cb, IParagraph, left, bottom, size + 10, 100, "", yBottomMargin);
}
private string symblsStr = "\u25CF\u0394"; // string of possible symbol character in a tab
private readonly string symblsStr = "\u25CF\u0394"; // string of possible symbol character in a tab
// add symbol characters as needed
// "\u25CF" - solid bullet
// \x0394 - delta
@@ -409,8 +382,6 @@ namespace Volian.Print.Library
// follow through in fixing an Out of Window Handles bug, use new function to see if
// we can retrieve the font from a dictionary instead a doing a New and using another
// window handle
//System.Drawing.Font font = new System.Drawing.Font(vefont.Family, (float)vefont.Size, GetSysFontStyle(vefont));
//System.Drawing.Font symbFont = new System.Drawing.Font(symblFontName, (float)vefont.Size);
System.Drawing.Font font = VE_Font.GetWinSysFont(vefont.Family, (float)vefont.Size, GetSysFontStyle(vefont));
System.Drawing.Font symbFont = VE_Font.GetWinSysFont(symblFontName, (float)vefont.Size);
iTextSharp.text.Font iFont = Volian.Svg.Library.VolianPdf.GetFont(font);
@@ -424,10 +395,10 @@ namespace Volian.Print.Library
else
w += iFont.BaseFont.GetWidthPointKerned(c.ToString(), (float)vefont.Size);
}
//float w = iFont.BaseFont.GetWidthPointKerned(Text.Replace("\u25CF","@"), (float)vefont.Size);
return w;
}
private void DrawAsteriskSide(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin, float top, float bottom, float left, float right, VE_Font vef)
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "top and bottom kept for debugging")]
private void DrawAsteriskSide(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin, float top, float bottom, float left, float right, VE_Font vef)
{
// set the top & bottom of sides. If there is a page break in the middle of box, adjust these.
// The vlnBox property, ContainsPageBreak, flags that a break occurred.
@@ -453,23 +424,23 @@ namespace Volian.Print.Library
// create a new font without any styles such as underline.
E_Style es = ((vef.Style & E_Style.Bold) == E_Style.Bold) ? E_Style.Bold : E_Style.None;
// if the box has a font, use it - otherwise use this item info's font
VE_Font vf = null;
bool UseBoxFont = false;
try
bool UseBoxFont = false;
try
{
UseBoxFont = MyParent.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionPrintData.DiffContActBox;
}
catch // done this way in case one of the format properties is null in the previous statement, UseBoxFont will be false.
{
}
if (UseBoxFont)
vf = new VE_Font(vef.Family, (int)vef.Size, es, (float)MyParent.MyItemInfo.FormatStepData.Font.CPI);
else
vf = new VE_Font(MyParent.MyItemInfo.FormatStepData.Font.Family, (int)MyParent.MyItemInfo.FormatStepData.Font.Size, es, (float)MyParent.MyItemInfo.FormatStepData.Font.CPI);
// if the box has a font, use it - otherwise use this item info's font
VE_Font vf;
if (UseBoxFont)
vf = new VE_Font(vef.Family, (int)vef.Size, es, (float)MyParent.MyItemInfo.FormatStepData.Font.CPI);
else
vf = new VE_Font(MyParent.MyItemInfo.FormatStepData.Font.Family, (int)MyParent.MyItemInfo.FormatStepData.Font.Size, es, (float)MyParent.MyItemInfo.FormatStepData.Font.CPI);
// Left side first:
Rtf = GetRtf(MyBox.BXVert, vf);
// Left side first:
Rtf = GetRtf(MyBox.BXVert, vf);
IParagraph = null; // set to null so that next access of IParagraph sets the Rtf.
// start down one line because the top/bottom code draws the corner
float vertDiff = top - (SixLinesPerInch * MyPageHelper.YMultiplier);
@@ -503,17 +474,8 @@ namespace Volian.Print.Library
}
return sb.ToString();
}
private static List<string> _UnimplementedBoxStyles = new List<string>();
private string CharToAsc(string p)
{
StringBuilder sb = new StringBuilder();
foreach (char c in p)
{
if (c >= ' ' && c < 127) sb.Append(c);
else sb.Append(string.Format("\\x{0:x}", (int)c));
}
return sb.ToString();
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
private static List<string> _UnimplementedBoxStyles = new List<string>();
private void DrawAsteriskTopBottomHLS(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin, ref float top, ref float bottom, float left, VE_Font vef)
{
// this box is not drawn, it is a series of asterisks drawn above and below text.
@@ -527,45 +489,45 @@ namespace Volian.Print.Library
bottom = ytmpbottom1;
// create a new font without any styles such as underline.
E_Style es = ((vef.Style & E_Style.Bold) == E_Style.Bold) ? E_Style.Bold : E_Style.None;
// if the box has a font, use it - otherwise use this item info's font
VE_Font vf = null;
bool UseBoxFont = false;
try
bool UseBoxFont = false;
try
{
UseBoxFont = MyParent.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionPrintData.DiffContActBox;
}
catch // done this way in case one of the format properties is null in the previous statement, UseBoxFont will be false.
{
}
if (UseBoxFont)
vf = new VE_Font(vef.Family, (int)vef.Size, es, (float)MyParent.MyItemInfo.FormatStepData.Font.CPI);
else
vf = new VE_Font(MyParent.MyItemInfo.FormatStepData.Font.Family, (int)MyParent.MyItemInfo.FormatStepData.Font.Size, es, (float)MyParent.MyItemInfo.FormatStepData.Font.CPI);
// if the box has a font, use it - otherwise use this item info's font
VE_Font vf;
if (UseBoxFont)
vf = new VE_Font(vef.Family, (int)vef.Size, es, (float)MyParent.MyItemInfo.FormatStepData.Font.CPI);
else
vf = new VE_Font(MyParent.MyItemInfo.FormatStepData.Font.Family, (int)MyParent.MyItemInfo.FormatStepData.Font.Size, es, (float)MyParent.MyItemInfo.FormatStepData.Font.CPI);
// To find the length of the line, account for the length of the upper right corner also (BXURC)
int urcLen = MyBox.BXHorz[MyBox.BXHorz.Length - 1] == ' ' && MyBox.BXURC[0] == ' ' ? 1 : MyBox.BXURC.Length;
// To find the length of the line, account for the length of the upper right corner also (BXURC)
int urcLen = MyBox.BXHorz[MyBox.BXHorz.Length - 1] == ' ' && MyBox.BXURC[0] == ' ' ? 1 : MyBox.BXURC.Length;
float endHorz = (float)MyBox.End - (float)MyBox.Start - (float)(urcLen * (72 / vf.CPI));
float bxHorzTextWidth = GetTextWidth(vf, MyBox.BXHorz); // get the width of the BXHorz string
// Do the top line first:
StringBuilder sb = new StringBuilder();
sb.Append(MyBox.BXULC);
float size = GetTextWidth(vf, MyBox.BXULC); //(float)(MyBox.BXULC.Length * (72 / vf.CPI));
string bxstr = null;
if (!ContainsPageBreak) // Only do top line if there is no page break.
float size = GetTextWidth(vf, MyBox.BXULC);
string bxstr;
if (!ContainsPageBreak) // Only do top line if there is no page break.
{
while (size < endHorz)
{
sb.Append(MyBox.BXHorz);
size = size + bxHorzTextWidth; //(float)(MyBox.BXHorz.Length * (72 / vf.CPI));
size += bxHorzTextWidth;
}
// Tack on the right upper corner. For some formats, the upper right corner in the
// had the first character as a space, this would put two spaces in a row at the
// end of the string, so remove the space before tacking on the upper right corner:
bxstr = sb.ToString();
if (bxstr[bxstr.Length - 1] == ' ' && MyBox.BXURC[0] == ' ') bxstr = bxstr.TrimEnd();
bxstr = bxstr + MyBox.BXURC;
size = size + GetTextWidth(vf, MyBox.BXURC);//(float)((MyBox.BXURC.Length) * (72 / vf.CPI));
bxstr += MyBox.BXURC;
size += GetTextWidth(vf, MyBox.BXURC);//(float)((MyBox.BXURC.Length) * (72 / vf.CPI));
Rtf = GetRtf(bxstr, vf);
IParagraph = null; // set to null so that next access of IParagraph sets the Rtf.
Rtf2Pdf.TextAt(cb, IParagraph, left, top, size + 10, 100, "", yBottomMargin);
@@ -576,24 +538,25 @@ namespace Volian.Print.Library
sb.Remove(0, sb.Length);
sb.Append(MyBox.BXLLC);
size = GetTextWidth(vf, MyBox.BXLLC); //(float)(MyBox.BXLLC.Length * (72 / vf.CPI));
size = GetTextWidth(vf, MyBox.BXLLC);
while (size < endHorz)
{
sb.Append(MyBox.BXHorz);
size = size + bxHorzTextWidth;//(float)(MyBox.BXHorz.Length * (72 / vf.CPI));
size += bxHorzTextWidth;
}
bxstr = sb.ToString().TrimEnd() + MyBox.BXLRC;
size = size + GetTextWidth(vf, MyBox.BXLRC); //(float)((MyBox.BXLRC.Length) * (72 / vf.CPI));
size += GetTextWidth(vf, MyBox.BXLRC);
Rtf = GetRtf(bxstr, vf);
IParagraph = null; // set to null so that next access of IParagraph sets the Rtf.
Rtf2Pdf.TextAt(cb, IParagraph, left, bottom, size + 10, 100, "", yBottomMargin);
}
private void DrawAsteriskSideHLS(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin, float top, float bottom, float left, float right, VE_Font vef)
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "top and bottom kept for debugging")]
private void DrawAsteriskSideHLS(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin, float top, float bottom, float left, float right, VE_Font vef)
{
// set the top & bottom of sides. If there is a page break in the middle of box, adjust these.
// The vlnBox property, ContainsPageBreak, flags that a break occurred.
float yOffBreak = 0;
if (!ContainsPageBreak)
// set the top & bottom of sides. If there is a page break in the middle of box, adjust these.
// The vlnBox property, ContainsPageBreak, flags that a break occurred.
float yOffBreak;
if (!ContainsPageBreak)
{
top = CalculateYOffset(yPageStart, yTopMargin);
if (MyPageHelper.YMultiplier != 1) top += 2;
@@ -613,8 +576,11 @@ namespace Volian.Print.Library
}
else
{
top = CalculateYOffset(yPageStart, yTopMargin);
yOffBreak = MyPageHelper.ParaBreaks.Count > 0 ? MyPageHelper.ParaBreaks[0].YOffset : 0;
#pragma warning disable IDE0059 // Unnecessary assignment of a value - Keeping top for Debugging
top = CalculateYOffset(yPageStart, yTopMargin);
#pragma warning restore IDE0059 // Unnecessary assignment of a value
yOffBreak = MyPageHelper.ParaBreaks.Count > 0 ? MyPageHelper.ParaBreaks[0].YOffset : 0;
if (yOffBreak > 0)
bottom = (yPageStart - yOffBreak) * MyPageHelper.YMultiplier;
else
@@ -636,23 +602,23 @@ namespace Volian.Print.Library
// create a new font without any styles such as underline.
E_Style es = ((vef.Style & E_Style.Bold) == E_Style.Bold) ? E_Style.Bold : E_Style.None;
// if the box has a font, use it - otherwise use this item info's font
VE_Font vf = null;
bool UseBoxFont = false;
try
bool UseBoxFont = false;
try
{
UseBoxFont = MyParent.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionPrintData.DiffContActBox;
}
catch // done this way in case one of the format properties is null in the previous statement, UseBoxFont will be false.
{
}
if (UseBoxFont)
vf = new VE_Font(vef.Family, (int)vef.Size, es, (float)MyParent.MyItemInfo.FormatStepData.Font.CPI);
else
vf = new VE_Font(MyParent.MyItemInfo.FormatStepData.Font.Family, (int)MyParent.MyItemInfo.FormatStepData.Font.Size, es, (float)MyParent.MyItemInfo.FormatStepData.Font.CPI);
// if the box has a font, use it - otherwise use this item info's font
VE_Font vf;
if (UseBoxFont)
vf = new VE_Font(vef.Family, (int)vef.Size, es, (float)MyParent.MyItemInfo.FormatStepData.Font.CPI);
else
vf = new VE_Font(MyParent.MyItemInfo.FormatStepData.Font.Family, (int)MyParent.MyItemInfo.FormatStepData.Font.Size, es, (float)MyParent.MyItemInfo.FormatStepData.Font.CPI);
// Left side first:
Rtf = GetRtf(MyBox.BXVert, vf);
// Left side first:
Rtf = GetRtf(MyBox.BXVert, vf);
IParagraph = null; // set to null so that next access of IParagraph sets the Rtf.
// start down one line because the top/bottom code draws the corner
float vertDiff = top - (SixLinesPerInch * MyPageHelper.YMultiplier);
+27 -76
View File
@@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using iTextSharp.text.pdf;
using iTextSharp.text;
using VEPROMS.CSLA.Library;
@@ -10,45 +8,26 @@ namespace Volian.Print.Library
{
public class vlnChangeBarMessage
{
private float _ParentX;
public float ParentX
{
get { return _ParentX; }
set { _ParentX = value; }
}
private string _Message;
public string Message
{
get { return _Message; }
set { _Message = value; }
}
private static int _UniqueMessageId = 0;
public float ParentX { get; set; }
public string Message { get; set; }
private static int _UniqueMessageId = 0;
public static int UniqueMessageId
{
get { return vlnChangeBarMessage._UniqueMessageId++; }
set { vlnChangeBarMessage._UniqueMessageId = value; }
get { return _UniqueMessageId++; }
set { _UniqueMessageId = value; }
}
private int _MessageId = UniqueMessageId;
public int MessageId
public int MessageId { get; set; } = UniqueMessageId;
public vlnChangeBarMessage(float parentx, string msg)
{
get { return _MessageId; }
set { _MessageId = value; }
}
public vlnChangeBarMessage(float parentx, string msg)
{
_ParentX = parentx;
_Message = msg;
ParentX = parentx;
Message = msg;
}
}
public partial class vlnChangeBar : vlnPrintObject
{
private bool _HasChangeBar;
public bool HasChangeBar
{
get { return _HasChangeBar; }
set { _HasChangeBar = value; }
}
protected float _YChangeBarBottom;
public bool HasChangeBar { get; set; }
protected float _YChangeBarBottom;
public float YChangeBarBottom
{
get
@@ -62,36 +41,15 @@ namespace Volian.Print.Library
_Height = _YOffset - _YChangeBarBottom;
}
}
private SortedDictionary<float, vlnChangeBarMessage> _Messages;
public SortedDictionary<float, vlnChangeBarMessage> Messages
{
get { return _Messages; }
set { _Messages = value; }
}
private int _MessageAlignment;
public int MessageAlignment
{
get { return _MessageAlignment; }
set { _MessageAlignment = value; }
}
private float _YExtendLine = 4.75F;
public float YExtendLine
{
get { return _YExtendLine; }
set {_YExtendLine = value; }
}
public float YChangeBarBottomExtend
{
get {return YChangeBarBottom - YExtendLine; }
}
private bool _BottomIsTable = false;
public bool BottomIsTable
{
get { return _BottomIsTable; }
set { _BottomIsTable = value; }
}
private bool _IsRev;
private bool _MsgAtTop; // flags that message should be drawn at top of change bar
public SortedDictionary<float, vlnChangeBarMessage> Messages { get; set; }
public int MessageAlignment { get; set; }
public float YExtendLine { get; set; } = 4.75F;
public float YChangeBarBottomExtend => YChangeBarBottom - YExtendLine;
public bool BottomIsTable { get; set; } = false;
private readonly bool _IsRev;
private readonly bool _MsgAtTop; // flags that message should be drawn at top of change bar
public vlnChangeBar(PdfContentByte cb, vlnParagraph parent, float xoff, float yoff, int msgAlignment, bool isRev, bool msgAtTop)
{
// for grids, a y adjustment is made to match 16bit output, see the variable 'GridTopAdjust'. Take this
@@ -113,7 +71,7 @@ namespace Volian.Print.Library
{
// see if any of children don't have changebar
if ((vpo as vlnRNOSeparator).ExtendChangeBar)
_YExtendLine = (vpo.Height + vpo.YOffset - ((scale * parent.Height) + parent.YOffset)) * MyPageHelper.YMultiplier;
YExtendLine = (vpo.Height + vpo.YOffset - ((scale * parent.Height) + parent.YOffset)) * MyPageHelper.YMultiplier;
}
}
foreach (vlnPrintObject vph in parent.PartsAbove)
@@ -152,13 +110,10 @@ namespace Volian.Print.Library
}
}
}
_MessageAlignment = msgAlignment;
MessageAlignment = msgAlignment;
}
public override string ToString()
{
return string.Format("vlnChangeBar: X={0} Y={1} H={2} B={3} ID={4}", XOffset, YOffset, Height, YChangeBarBottom, MyParent.MyItemInfo.ItemID);
}
public override float ToPdf(PdfContentByte cb, float yPageStart, ref float yTopMargin, ref float yBottomMargin)
public override string ToString() => string.Format("vlnChangeBar: X={0} Y={1} H={2} B={3} ID={4}", XOffset, YOffset, Height, YChangeBarBottom, MyParent.MyItemInfo.ItemID);
public override float ToPdf(PdfContentByte cb, float yPageStart, ref float yTopMargin, ref float yBottomMargin)
{
float? topMost = null;
cb.SaveState();
@@ -170,12 +125,10 @@ namespace Volian.Print.Library
// calculate a new starting position for the change bar
if (_MyParent is vlnParagraph)
{
vlnParagraph pgh = _MyParent as vlnParagraph;
topMost = cb.PdfWriter.PageSize.Height - yPageStart;
}
VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper;
PdfLayer textLayer = _MyPageHelper == null ? null : _MyPageHelper.TextLayer;
if (textLayer != null) cb.BeginLayer(textLayer);
PdfLayer textLayer = !(cb.PdfWriter.PageEvent is VlnSvgPageHelper _MyPageHelper) ? null : _MyPageHelper.TextLayer;
if (textLayer != null) cb.BeginLayer(textLayer);
float yAdj = -3.75F; //0.5F;
float xAdj = 3F;
//cb.SetColorStroke(Color.GREEN);
@@ -226,8 +179,6 @@ namespace Volian.Print.Library
// follow through in fixing an Out of Window Handles bug, use new function to see if
// we can retrieve the font from a dictionary instead a doing a New and using another
// window handle B21017-117
//iTextSharp.text.Font iFont = _IsRev? Volian.Svg.Library.VolianPdf.GetFont(new System.Drawing.Font("Letter Gothic", 10F)):
// Volian.Svg.Library.VolianPdf.GetFont(new System.Drawing.Font("Letter Gothic", 5.5F));
iTextSharp.text.Font iFont = _IsRev? Volian.Svg.Library.VolianPdf.GetFont(VE_Font.GetWinSysFont("Letter Gothic", 10F)):
Volian.Svg.Library.VolianPdf.GetFont(VE_Font.GetWinSysFont("Letter Gothic", 5.5F));
+3 -11
View File
@@ -1,21 +1,13 @@
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 vlnHeader: vlnText
{
private string _OrigStr;
public float HeaderWidth
{
get { return _WidthAdjust + (MyFont.CharsToTwips * Text.Length); }
}
public vlnHeader(vlnParagraph myParent, PdfContentByte cb, string origStr, string cleanStr, float xoffset, float yoffset, VE_Font vFont)
private readonly string _OrigStr;
public float HeaderWidth => _WidthAdjust + (MyFont.CharsToTwips * Text.Length);
public vlnHeader(vlnParagraph myParent, PdfContentByte cb, string origStr, string cleanStr, float xoffset, float yoffset, VE_Font vFont)
{
MyParent = myParent;
MyContentByte = cb;
+4 -16
View File
@@ -1,10 +1,4 @@
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
{
@@ -13,13 +7,8 @@ namespace Volian.Print.Library
private bool _UseInternalY = false;
// B2020-121: Account for Header on Caution or Note
public bool UseInternalY { get => _UseInternalY; set => _UseInternalY = value; }
private string _MacroDef;
public string MacroDef
{
get { return _MacroDef; }
set { _MacroDef = value; }
}
public vlnMacro(float xoffset, float yoffset, string macroDef)
public string MacroDef { get; set; }
public vlnMacro(float xoffset, float yoffset, string macroDef)
{
YOffset = yoffset;
XOffset = xoffset;
@@ -33,9 +22,8 @@ namespace Volian.Print.Library
if (UseInternalY) yLocation = YOffset; // B2020-121: Account for Header on Caution or Note
// Adjust the starting point for the Macro if the LPI is 7
if (MyPageHelper.YMultiplier != 1) yLocation += SixLinesPerInch - _SevenLinesPerInch;
VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper;
PdfLayer textLayer = _MyPageHelper == null ? null : _MyPageHelper.TextLayer;
if (textLayer != null) cb.BeginLayer(textLayer);
PdfLayer textLayer = !(cb.PdfWriter.PageEvent is VlnSvgPageHelper _MyPageHelper) ? 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;
File diff suppressed because it is too large Load Diff
+71 -175
View File
@@ -1,14 +1,10 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using iTextSharp.text.pdf;
using iTextSharp.text;
using Itenso.Rtf;
using Itenso.Rtf.Parser;
using Itenso.Rtf.Interpreter;
using Itenso.Rtf.Support;
using Volian.Controls.Library;
using VEPROMS.CSLA.Library;
using Volian.Base.Library;
using System.Text.RegularExpressions;
@@ -24,22 +20,14 @@ namespace Volian.Print.Library
get { return _UniqueDebugId++; }
set { _UniqueDebugId = value; }
}
private int _DebugId = UniqueDebugId;
public int DebugId
{
get { return _DebugId; }
set { _DebugId = value; }
}
protected static float _WidthAdjust = 1; // 1 Point - adjusted to match 16-bit line wrapping. For editting it's 3.
public int DebugId { get; set; } = UniqueDebugId;
protected static float _WidthAdjust = 1; // 1 Point - adjusted to match 16-bit line wrapping. For editting it's 3.
protected static float _WidthAdjustBox = 6;
private static float _SixLinesPerInch = 12; // twips
public static float SixLinesPerInch
{
get { return vlnPrintObject._SixLinesPerInch; }
set { vlnPrintObject._SixLinesPerInch = value; }
}
protected static float _SevenLinesPerInch = 10.1F;//72F / 7F;
public static float SixLinesPerInch { get; set; } = 12;
protected static float _SevenLinesPerInch = 10.1F;//72F / 7F;
protected float _XOffset;
public float XOffset
@@ -64,31 +52,13 @@ namespace Volian.Print.Library
set
{
_MyParent = value;
if (_MyParent != null)
{
}
}
}
private bool _HasIndent = false;
public bool HasIndent
{
get { return _HasIndent; }
set { _HasIndent = value; }
}
private bool _IsCompressed = false;
public bool IsCompressed
{
get { return _IsCompressed; }
set { _IsCompressed = value; }
}
private string _ImageText; // ro definition, value part of #Link in case of image/figure
public string ImageText
{
get { return _ImageText; }
set { _ImageText = value; }
}
protected string _Rtf; // may become iTextSharp paragraph
public bool HasIndent { get; set; } = false;
public bool IsCompressed { get; set; } = false;
public string ImageText { get; set; }
protected string _Rtf; // may become iTextSharp paragraph
public virtual string Rtf
{
get { return _Rtf; }
@@ -96,15 +66,9 @@ namespace Volian.Print.Library
}
public class VlnSplitCharacter : ISplitCharacter
{
public bool IsSplitCharacter(int start, int current, int end, char[] cc, PdfChunk[] ck)
{
return (cc[current] == ' ');
}
public bool IsSplitCharacter(char c)
{
return (c == ' ');
}
}
public bool IsSplitCharacter(int start, int current, int end, char[] cc, PdfChunk[] ck) => (cc[current] == ' ');
public bool IsSplitCharacter(char c) => (c == ' ');
}
public static VlnSplitCharacter mySplitter = new VlnSplitCharacter();
// B2018-034 Attributes were being lost when the IsCompressed flag was true.
// The following variable was changed to a public so that it could be used
@@ -114,6 +78,7 @@ namespace Volian.Print.Library
{
get
{
//For Debugging:
// If the paragraph iscompressed, it may have been created as not compressed since compression
// is not set when paragraph is initially created, it is set during pagination tests.
//if (_IParagraph == null || IsCompressed)
@@ -186,49 +151,10 @@ namespace Volian.Print.Library
}
set { _Height = value; }
}
public float GetParagraphHeight(PdfContentByte cb, Paragraph iParagraph, string suffix, float width)
{
return GetParagraphHeight(cb, iParagraph, suffix, width, true);
}
public float GetParagraphHeight(PdfContentByte cb, Paragraph iParagraph, string suffix, float width, bool throwException)
{
float heightAll = GetHeight(cb, iParagraph, suffix, width, throwException);
return heightAll;
}
private static void RestoreLastCharacter(Paragraph iParagraph, Chunk chk)
{
iParagraph.RemoveAt(iParagraph.Count - 1);
iParagraph.Add(chk);
}
private static Chunk RemoveLastCharacter(Paragraph iParagraph)
{
if (iParagraph.Count == 0)
return null;
object obj = iParagraph[iParagraph.Count-1];
Chunk chk = obj as Chunk;
if (chk == null)
return null;
string s = chk.Content;
if (s.Length > 1 || iParagraph.Count > 1) // don't remove last character if it's the only one
{
iParagraph.RemoveAt(iParagraph.Count - 1);
if (s.Length > 0)
{
if (s == "\xA0") // If this is a space at the end put it back
{
iParagraph.Add(chk);
return null;
}
else
{
s = s.Substring(0, s.Length - 1);
iParagraph.Add(new Chunk(s, chk.Font));
}
}
}
return chk;
}
public static float GetHeight(PdfContentByte cb, Paragraph iParagraph, string suffix, float width, bool throwException)
public float GetParagraphHeight(PdfContentByte cb, Paragraph iParagraph, string suffix, float width) => GetParagraphHeight(cb, iParagraph, suffix, width, true);
public float GetParagraphHeight(PdfContentByte cb, Paragraph iParagraph, string suffix, float width, bool throwException) => (float)GetHeight(cb, iParagraph, suffix, width, throwException);
public static float GetHeight(PdfContentByte cb, Paragraph iParagraph, string suffix, float width, bool throwException)
{
ColumnText myColumnText = new ColumnText(cb);
float pgHeight = cb.PdfDocument.PageSize.Height; // C2020-002 paper size is now set in the format files
@@ -243,7 +169,6 @@ namespace Volian.Print.Library
{
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)
{
@@ -255,7 +180,6 @@ namespace Volian.Print.Library
iParagraph.IndentationLeft = 0;
return GetHeight(cb, iParagraph, suffix, width, throwException);
}
//throw (new Exception("Paragraph longer than a page"));
Console.WriteLine("Paragraph longer than a page");
}
return pgHeight - myColumnText.YLine; // This gives the height of the Paragraph // C2020-002 paper size is now set in the format files
@@ -266,23 +190,19 @@ namespace Volian.Print.Library
float h = GetParagraphHeight(cb, iParagraph, string.Empty, iWidth);
int iWidthMax = iWidth; // maximum width in Characters
int iDelta = iWidth / 2;
iWidth = iWidth / 2;
iWidth /= 2;
while (iDelta > 0)
{
float h2 = GetParagraphHeight(cb, iParagraph, string.Empty, iWidth,false);
iDelta = iDelta / 2;
iDelta /= 2;
if (h2 == h) iWidthMax = iWidth;
iWidth += (h2>h ? 1: -1) * iDelta;
}
return (float) iWidthMax;
}
private PdfContentByte _MyContentByte;
public PdfContentByte MyContentByte
{
get { return _MyContentByte; }
set { _MyContentByte = value; }
}
private VlnSvgPageHelper _MyPageHelper;
public PdfContentByte MyContentByte { get; set; }
private VlnSvgPageHelper _MyPageHelper;
public VlnSvgPageHelper MyPageHelper
{
get
@@ -296,50 +216,34 @@ namespace Volian.Print.Library
public vlnPrintObject()
{
}
/// <summary>
/// No conversion necessary: twips -> twips
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static int ToInt(int value)
{
return value;
}
/// <summary>
/// No conversion necessary: int? twips -> int twips
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static int ToInt(int? value)
{
return ToInt((int)value);
}
/// <summary>
/// No conversion necessary: string twips -> int twips
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static int ToInt(string value)
{
return ToInt((int)Convert.ToSingle(value));
}
/// <summary>
/// No conversion necessary: value from a list in a string, twips -> int twips
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static int ToInt(string value, int i)
{
string s = (value.Contains(",")) ? value.Split(",".ToCharArray())[i] : value;
return ToInt(s);
}
public static string GetRtf(string text, VE_Font vFont)
/// <summary>
/// No conversion necessary: twips -> twips
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static int ToInt(int value) => value;
/// <summary>
/// No conversion necessary: int? twips -> int twips
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static int ToInt(int? value) => ToInt((int)value);
/// <summary>
/// No conversion necessary: string twips -> int twips
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static int ToInt(string value) => ToInt((int)Convert.ToSingle(value));
/// <summary>
/// No conversion necessary: value from a list in a string, twips -> int twips
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static int ToInt(string value, int i) => ToInt((value.Contains(",")) ? value.Split(",".ToCharArray())[i] : value);
public static string GetRtf(string text, VE_Font vFont)
{
StringBuilder rtfSB = new StringBuilder();
//DisplayText vlntxt = new DisplayText(text.TrimStart(" ".ToCharArray()), vFont, false);
DisplayText vlntxt = new DisplayText(text, vFont, false);
//rtfSB.Append(AddFontTable(vlntxt.TextFont.WindowsFont));
//rtfSB.Append(AddFontTable(vFont.WindowsFont));
rtfSB.Append(AddFontTable(vFont));
rtfSB.Append(vlntxt.StartText);
rtfSB.Append("}");
@@ -413,11 +317,8 @@ namespace Volian.Print.Library
float fE = iFont.BaseFont.GetWidthPointKerned("!", 12);
return fW == fE;
}
public static iTextSharp.text.Paragraph RtfToParagraph(string rtf)
{
return RtfToParagraph(rtf, false, false);
}
public static iTextSharp.text.Paragraph RtfToParagraph(string rtf, bool hasIndent, bool doPdfLinks)
public static iTextSharp.text.Paragraph RtfToParagraph(string rtf) => RtfToParagraph(rtf, false, false);
public static iTextSharp.text.Paragraph RtfToParagraph(string rtf, bool hasIndent, bool doPdfLinks)
{
if (hasIndent)
{
@@ -427,11 +328,13 @@ namespace Volian.Print.Library
}
IRtfDocument rtfDoc = RtfInterpreterTool.BuildDoc(rtf);
Rtf2iTextSharp rtf2IText = new Rtf2iTextSharp(rtfDoc);
rtf2IText.DoPdfLinks = doPdfLinks;
rtf2IText.HasIndent = hasIndent;
iTextSharp.text.Paragraph para = rtf2IText.Convert();
para.SetLeading(_SixLinesPerInch, 0);
Rtf2iTextSharp rtf2IText = new Rtf2iTextSharp(rtfDoc)
{
DoPdfLinks = doPdfLinks,
HasIndent = hasIndent
};
iTextSharp.text.Paragraph para = rtf2IText.Convert();
para.SetLeading(SixLinesPerInch, 0);
if (rtf.Contains("\x05")) // note that this is for existing customer data as of August 2015.
{
// if there is a hanging indent, the iTextSharp paragraph properties must be set
@@ -459,22 +362,17 @@ namespace Volian.Print.Library
// Change the chunks to only split on spaces rather than spaces and hyphens
foreach (object obj in para)//Fix the code to check for chunks before assuming chunks
{
Chunk chk = obj as Chunk;
if (chk != null && (chk.Attributes==null || !chk.Attributes.ContainsKey("NoSplit")))
{
if (chk.Attributes == null) chk.Attributes = new System.Collections.Hashtable();
chk.SetSplitCharacter(mySplitter);
chk.Attributes.Add("NoSplit", false);
}
}
if (obj is Chunk chk && (chk.Attributes == null || !chk.Attributes.ContainsKey("NoSplit")))
{
if (chk.Attributes == null) chk.Attributes = new System.Collections.Hashtable();
chk.SetSplitCharacter(mySplitter);
chk.Attributes.Add("NoSplit", false);
}
}
return para;
}
private static string FixNumber(string num)
{
if (num == "") return ("0");
return num;
}
public static float CalculateHangingIndent(string rtf)
private static string FixNumber(string num) => num == "" ? "0" : num;
public static float CalculateHangingIndent(string rtf)
{
float chkW=0;
IRtfDocument rtfDoc2 = RtfInterpreterTool.BuildDoc(rtf.Replace("\x05", @"\f1 \u9999? \f0 "));
@@ -515,9 +413,8 @@ namespace Volian.Print.Library
}
public void DebugPdf(PdfContentByte cb, float left, float top)
{
VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper;
PdfLayer debugLayer = _MyPageHelper == null ? null : _MyPageHelper.DebugLayer;
if (debugLayer == null) return;
PdfLayer debugLayer = !(cb.PdfWriter.PageEvent is VlnSvgPageHelper _MyPageHelper) ? null : _MyPageHelper.DebugLayer;
if (debugLayer == null) return;
cb.SaveState();
cb.BeginLayer(debugLayer);
ColumnText ct = new ColumnText(cb);
@@ -531,9 +428,8 @@ namespace Volian.Print.Library
cb.EndLayer();
cb.RestoreState();
}
public virtual float YBottom
{ get { return YOffset + Height;} }
}
public virtual float YBottom => YOffset + Height;
}
public partial class vlnPrintObjects : List<vlnPrintObject>
{
public float ToPdf(PdfContentByte cb, float yPageStart, ref float yTopMargin, ref float yBottomMargin)
+9 -30
View File
@@ -1,40 +1,20 @@
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; }
}
public VE_Font MyFont { get; set; }
public bool ExtendChangeBar { get; set; }
public float XLength { get; set; } = 0;
/* 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)
/* 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;
ExtendChangeBar = formatInfo.PlantFormat.FormatData.ProcData.ChangeBarData.ChangeBarToRNOSep && extendChangeBar;
YOffset = yoffset;
XOffset = xoffset;
XLength = formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionPrintData.RNOSepLineLength??0;
@@ -60,9 +40,8 @@ namespace Volian.Print.Library
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);
PdfLayer textLayer = !(cb.PdfWriter.PageEvent is VlnSvgPageHelper _MyPageHelper) ? 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);
+16 -75
View File
@@ -1,9 +1,5 @@
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
@@ -59,35 +55,21 @@ namespace Volian.Print.Library
return (float)_TabOffset * MyFont.CharsToTwips;
}
}
private vlnMacro _MyMacro;
public vlnMacro MyMacro
{
get { return _MyMacro; }
set { _MyMacro = value; }
}
private string symblsStr = "\u25CF\u0394"; // string of possible symbol character in a tab
// add symbol characters as needed
// "\u25CF" - solid bullet
// \u0394 - delta
public vlnMacro MyMacro { get; set; }
private System.Drawing.FontStyle GetSysFontStyle(VE_Font f)
{
if (f.Style == E_Style.Italics)
return System.Drawing.FontStyle.Italic;
return FontStyle.Regular;
}
public float GetTextWidth(VE_Font vefont, string txt)
{
return GetTextWidth(vefont, txt, SymbolFontName);
}
private float GetTextWidth(VE_Font vefont, string txt, string symblFontName)
private readonly string symblsStr = "\u25CF\u0394"; // string of possible symbol character in a tab
// add symbol characters as needed
// "\u25CF" - solid bullet
// \u0394 - delta
private System.Drawing.FontStyle GetSysFontStyle(VE_Font f) => f.Style == E_Style.Italics ? System.Drawing.FontStyle.Italic : FontStyle.Regular;
public float GetTextWidth(VE_Font vefont, string txt) => GetTextWidth(vefont, txt, SymbolFontName);
private float GetTextWidth(VE_Font vefont, string txt, string symblFontName)
{
// follow through in fixing an Out of Window Handles bug, use new function to see if
// we can retrieve the font from a dictionary instead a doing a New and using another
// window handle B2017-117
//System.Drawing.Font font = new System.Drawing.Font(vefont.Family, (float)vefont.Size, GetSysFontStyle(vefont));
//System.Drawing.Font symbFont = new System.Drawing.Font(symblFontName, (float)vefont.Size);
System.Drawing.Font font = VE_Font.GetWinSysFont(vefont.Family, (float)vefont.Size, GetSysFontStyle(vefont));
System.Drawing.Font symbFont = VE_Font.GetWinSysFont(symblFontName, (float)vefont.Size);
iTextSharp.text.Font iFont = Volian.Svg.Library.VolianPdf.GetFont(font);
@@ -101,30 +83,14 @@ namespace Volian.Print.Library
else
w += iFont.BaseFont.GetWidthPointKerned(c.ToString(), (float)vefont.Size);
}
//float w = iFont.BaseFont.GetWidthPointKerned(Text.Replace("\u25CF","@"), (float)vefont.Size);
return w;
}
bool _ScriptCaution = false;
public bool ScriptCaution
{
get { return _ScriptCaution; }
set { _ScriptCaution = value; }
}
bool _SeparateBullet = false;
public bool ScriptCaution { get; set; } = false;
public bool SeparateBullet
{
get { return _SeparateBullet; }
set { _SeparateBullet = value; }
}
private string _SymbolFontName;
public string SymbolFontName
{
get { return _SymbolFontName; }
set { _SymbolFontName = value; }
}
public vlnTab(PdfContentByte cb, vlnParagraph myparent, string origTab, string cleanTab, float xoffset, float yoffset, VE_Font vFont, bool doSectTab, string symblFontName, bool removedUnderline)
public bool SeparateBullet { get; set; } = false;
public string SymbolFontName { get; set; }
public vlnTab(PdfContentByte cb, vlnParagraph myparent, string origTab, string cleanTab, float xoffset, float yoffset, VE_Font vFont, bool doSectTab, string symblFontName, bool removedUnderline)
{
SymbolFontName = symblFontName;
bool alignAsIfBulleted = false;
@@ -149,20 +115,14 @@ namespace Volian.Print.Library
Width = 90;
}
else if ((myparent.MyItemInfo.FormatStepData != null) && (myparent.MyItemInfo.FormatStepData.TabData.IdentWidth ?? 0) > 0)
//if ((myparent.MyItemInfo.FormatStepData != null) && (myparent.MyItemInfo.FormatStepData.TabData.IdentWidth ?? 0) > 0)
Width = (float)myparent.MyItemInfo.FormatStepData.TabData.IdentWidth;
else if (CCCs != IIIs)
{
float tPtPerChar = myparent.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.TabPtsPerChar ?? 6;
Width = (tPtPerChar == 0 ? 6 : tPtPerChar) * origTab.Length;
// Check the following, it may be needed for FPL:
//origTab1 = origTab1.TrimStart(" ".ToCharArray());
// 6 = number of points per character. 4 characters between end of tab and beginning of text
// origTab1.Trim... is number of non-space characters of the tab string.
//Width = 6 * (4 + origTab1.Trim(" ".ToCharArray()).Length);
}
else
Width = GetTextWidth(MyFont, (Text != null ? Text : origTab), symblFontName); //MyFont.CharsToTwips * (Text != null ? Text.Length : origTab.Length);
Width = GetTextWidth(MyFont, (Text ?? origTab), symblFontName);
// Pairie Island (NSP) Caution and Note tabs use a larger font
// When using a bullet, we need to use the font size of the Caution/Note text instead of the tab.
@@ -195,7 +155,7 @@ namespace Volian.Print.Library
Width = (float)myparent.MyItemInfo.FormatStepData.TabData.IdentWidth;
else
{
origTab = origTab + " ";
origTab += " ";
origTab = origTab.TrimStart(" ".ToCharArray());
if (mindx > 2) // ouch!
Width = 6f * (origTab.Length - 1); // FPL (macro is after {numeric}) FPL is good with genmac output!
@@ -204,7 +164,7 @@ namespace Volian.Print.Library
}
}
else
Width = GetTextWidth(MyFont, (cleanTab != null ? cleanTab : origTab), symblFontName);//MyFont.CharsToTwips * (cleanTab != null ? cleanTab.Length : origTab.Length);
Width = GetTextWidth(MyFont, (cleanTab ?? origTab), symblFontName);//MyFont.CharsToTwips * (cleanTab != null ? cleanTab.Length : origTab.Length);
}
else
{
@@ -219,8 +179,6 @@ namespace Volian.Print.Library
int sep = origTab.IndexOfAny(". ".ToCharArray());
string prefix = ((vFont.Style & E_Style.Bold) > 0) ? @"\b\ul " : @"\ul ";
string suffix = ((vFont.Style & E_Style.Bold) > 0) ? @"\b0\ulnone " : @"\ulnone ";
//origTab = @"\ul " + origTab.Substring(0, sep-1) + @"\ulnone" + origTab.Substring(sep-1);
//origTab = @"\ul " + origTab.Substring(0, sep) + @"\ulnone" + origTab.Substring(sep);
origTab = prefix + origTab.Substring(0, sep) + suffix + origTab.Substring(sep);
}
@@ -238,7 +196,6 @@ namespace Volian.Print.Library
// follow through in fixing an Out of Window Handles bug, use new function to see if
// we can retrieve the font from a dictionary instead a doing a New and using another
// window handle B2017-117
//vFont.WindowsFont = new System.Drawing.Font(vFont.Family, (float)vFont.Size, style);
vFont.WindowsFont = VE_Font.GetWinSysFont(vFont.Family, (float)vFont.Size, style);
int indxC = origTab.IndexOf(":");
origTab = @"\ul " + origTab.Substring(0, indxC) + @"\ulnone" + origTab.Substring(indxC);
@@ -255,7 +212,6 @@ namespace Volian.Print.Library
// follow through in fixing an Out of Window Handles bug, use new function to see if
// we can retrieve the font from a dictionary instead a doing a New and using another
// window handle B2017-117
//vFont.WindowsFont = new System.Drawing.Font(vFont.Family, (float)vFont.Size, style);
vFont.WindowsFont = VE_Font.GetWinSysFont(vFont.Family, (float)vFont.Size, style);
int indxC = origTab.IndexOf(ut.Text);
string prefix = ((vFont.Style & E_Style.Bold) > 0) ? @"\b\ul " : @"\ul ";
@@ -294,7 +250,6 @@ namespace Volian.Print.Library
(myparent.MyItemInfo.MyPrevious.MyContent.Type == myparent.MyItemInfo.MyContent.Type)))
{
//if (scriptCaution)
// Rtf = Rtf.Replace("CAUTION ", @"\u61472?\u61472?\u61472?\u61472?\u61472?\u61472?\u61472?\u61472?\u61472?");
Rtf = Rtf.Replace("Caution:", " ");
Rtf = Rtf.Replace("Note:", " ");
Rtf = Rtf.Replace("CAUTION:", " ");
@@ -305,19 +260,6 @@ namespace Volian.Print.Library
Rtf = Rtf.Replace("NOTE", " ");
}
}
//if (ScriptCaution && Rtf.Contains("Caution"))
//{
// // NSP script caution
// iTextSharp.text.Font myfont = pdf.GetFont(vFont.Family, 28, 0, iTextSharp.text.Color.BLACK);
// if (!myfont.BaseFont.CharExists(0x43)) // Capital 'C' exists as text
// {
// //VE_Font vf = new VE_Font("VolianScript", 28, E_Style.Italics, 12);
// // Capital 'C' exists as Symbol
// Rtf = Rtf.Replace("Caution ", @"\u61507?\u61537?\u61557?\u61556?\u61545?\u61551?\u61550?\u61472?\u61472?");
// }
//}
// do positioning based on whether format has locations for section 'header'. If it's not centered, treat
// it's location more like a 'tab'.
@@ -343,7 +285,6 @@ namespace Volian.Print.Library
// follow through in fixing an Out of Window Handles bug, use new function to see if
// we can retrieve the font from a dictionary instead a doing a New and using another
// window handle B2017-117
//System.Drawing.Font font = new System.Drawing.Font(MyFont.Family, (float)MyFont.Size);
System.Drawing.Font font = VE_Font.GetWinSysFont(MyFont.Family, (float)MyFont.Size);
iTextSharp.text.Font iFont = Volian.Svg.Library.VolianPdf.GetFont(font);
float w = iFont.BaseFont.GetWidthPointKerned(txt, (float)MyFont.Size);
+3 -22
View File
@@ -1,32 +1,13 @@
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 vlnText : vlnPrintObject
{
//public float Width
//{
// get { return _CharsToTwips * Text.Length; }
//}
private string _Text;
public string Text
{
get { return _Text; }
set { _Text = value; }
}
private VE_Font _MyFont;
public VE_Font MyFont
{
get { return _MyFont; }
set { _MyFont = value; }
}
public vlnText(PdfContentByte cb, vlnParagraph myparent, string origText, string cleanText, float xoffset, float yoffset, VE_Font vFont)
public string Text { get; set; }
public VE_Font MyFont { get; set; }
public vlnText(PdfContentByte cb, vlnParagraph myparent, string origText, string cleanText, float xoffset, float yoffset, VE_Font vFont)
{
MyContentByte = cb;
MyParent = myparent;