Print Library, Svg Library, Utils Library, XYPlots
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user