|
|
|
@@ -2,6 +2,7 @@ using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
using iTextSharp.text.pdf;
|
|
|
|
|
using iTextSharp.text;
|
|
|
|
|
using Itenso.Rtf;
|
|
|
|
@@ -95,18 +96,18 @@ namespace Volian.Print.Library
|
|
|
|
|
if (MyItemInfo.HasChangeBar()) MyPageHelper.AddChangeBar(DoChangeBar(cb, MyItemInfo, MyPageHelper, XOffset, yLocation, MyPageHelper.MaxRNO, MyItemInfo.ActiveFormat), cbMess);
|
|
|
|
|
|
|
|
|
|
float retval = yLocation;
|
|
|
|
|
if (!MyItemInfo.IsStepSection) // Don't ouput the Step Section title
|
|
|
|
|
if (MyItemInfo.IsFigure)
|
|
|
|
|
{
|
|
|
|
|
retval = Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, Width, 100, PdfDebugText, yBottomMargin);
|
|
|
|
|
if (retval == 0) // problem occurred - paragraph was not able to be printed on page
|
|
|
|
|
{ // pagination logic needs to be fixed.
|
|
|
|
|
cb.PdfDocument.NewPage();
|
|
|
|
|
yPageStart = yTopMargin + YTop;
|
|
|
|
|
yLocation = yPageStart - YOffset;
|
|
|
|
|
//MyItemInfo.ItemID, YSize, yPageSize, yLocation
|
|
|
|
|
Console.WriteLine("-1,'Yes','Forced Pagination',{0},{1},,{3},'{4}'", MyItemInfo.ItemID, YSize, 0, yLocation, MyItemInfo.ShortPath);
|
|
|
|
|
retval = Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, Width, 100, PdfDebugText, yBottomMargin);
|
|
|
|
|
}
|
|
|
|
|
yLocation -= (SixLinesPerInch * MyPageHelper.YMultiplier);
|
|
|
|
|
if (ImageText != null)
|
|
|
|
|
retval = DrawFigure(cb, yBottomMargin, yLocation);
|
|
|
|
|
else
|
|
|
|
|
retval = DrawText(cb, ref yPageStart, yTopMargin, yBottomMargin, ref yLocation);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (!MyItemInfo.IsStepSection) // Don't ouput the Step Section title
|
|
|
|
|
{
|
|
|
|
|
retval = DrawText(cb, ref yPageStart, yTopMargin, yBottomMargin, ref yLocation);
|
|
|
|
|
}
|
|
|
|
|
//Height = yLocation - retval;
|
|
|
|
|
if (_PartsLeft != null && _PartsLeft.Count > 0) yPageStart = PartsLeft.ToPdf(cb, yPageStart, yTopMargin, yBottomMargin);
|
|
|
|
@@ -116,6 +117,41 @@ namespace Volian.Print.Library
|
|
|
|
|
|
|
|
|
|
return yPageStart;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private float DrawText(PdfContentByte cb, ref float yPageStart, float yTopMargin, float yBottomMargin, ref float yLocation)
|
|
|
|
|
{
|
|
|
|
|
float retval = yLocation;
|
|
|
|
|
retval = Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, Width, 100, PdfDebugText, yBottomMargin);
|
|
|
|
|
if (retval == 0) // problem occurred - paragraph was not able to be printed on page
|
|
|
|
|
{ // pagination logic needs to be fixed.
|
|
|
|
|
cb.PdfDocument.NewPage();
|
|
|
|
|
yPageStart = yTopMargin + YTop;
|
|
|
|
|
yLocation = yPageStart - YOffset;
|
|
|
|
|
//MyItemInfo.ItemID, YSize, yPageSize, yLocation
|
|
|
|
|
Console.WriteLine("-1,'Yes','Forced Pagination',{0},{1},,{3},'{4}'", MyItemInfo.ItemID, YSize, 0, yLocation, MyItemInfo.ShortPath);
|
|
|
|
|
retval = Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, Width, 100, PdfDebugText, yBottomMargin);
|
|
|
|
|
}
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private float DrawFigure(PdfContentByte cb, float yBottomMargin, float yLocation)
|
|
|
|
|
{
|
|
|
|
|
float retval = yLocation;
|
|
|
|
|
if (ImageText != null)
|
|
|
|
|
{
|
|
|
|
|
string[] vals = ImageText.Split("\n".ToCharArray());
|
|
|
|
|
ProcedureInfo proc = MyItemInfo.MyProcedure;
|
|
|
|
|
DocVersionInfo dvi = proc.ActiveParent as DocVersionInfo;
|
|
|
|
|
ROFstInfo rofst = dvi.DocVersionAssociations[0].MyROFst;
|
|
|
|
|
ROImageInfo roImage = ROImageInfo.GetByROFstID_FileName(rofst.ROFstID, vals[0]);
|
|
|
|
|
if (roImage != null)
|
|
|
|
|
{
|
|
|
|
|
iTextSharp.text.Image it_image = iTextSharp.text.Image.GetInstance(roImage.Content);
|
|
|
|
|
retval = Rtf2Pdf.FigureAt(cb, it_image, XOffset + _CharsToTwips, yLocation, Width * MyPageHelper.YMultiplier, Height * MyPageHelper.YMultiplier, PdfDebugText, yBottomMargin, !MyItemInfo.FormatStepData.Type.Contains("Borderless"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
private string PdfDebugText
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
@@ -312,30 +348,59 @@ namespace Volian.Print.Library
|
|
|
|
|
YOffset = yoff;
|
|
|
|
|
AddMacros(itemInfo, mytab);
|
|
|
|
|
if (mytab != null) mytab.YOffset = yoff;
|
|
|
|
|
Rtf = GetRtf(itemInfo);
|
|
|
|
|
if (itemInfo.IsTablePart)
|
|
|
|
|
if (itemInfo.IsFigure) // if a figure we've got to determine the size:
|
|
|
|
|
{
|
|
|
|
|
Width = GetTableWidth(cb, IParagraph);
|
|
|
|
|
vlnParagraph hls = MyParent;
|
|
|
|
|
bool aerTable = itemInfo.FormatStepData.Type.Contains("AER");
|
|
|
|
|
while (hls.MyParent != null)
|
|
|
|
|
if (itemInfo.MyContent.Text != null)
|
|
|
|
|
{
|
|
|
|
|
if (aerTable && hls.MyItemInfo.IsHigh) break;
|
|
|
|
|
hls = hls.MyParent;
|
|
|
|
|
ProcedureInfo proc = itemInfo.MyProcedure;
|
|
|
|
|
DocVersionInfo dvi = proc.ActiveParent as DocVersionInfo;
|
|
|
|
|
ROFstInfo rofst = dvi.DocVersionAssociations[0].MyROFst;
|
|
|
|
|
ROFSTLookup lookup = rofst.ROFSTLookup;
|
|
|
|
|
string linkInfoText = itemInfo.MyContent.Text.Replace(@"\v ", "");
|
|
|
|
|
Match m = Regex.Match(linkInfoText, @"(.*)[#]Link:([A-Za-z]*):(.*)");
|
|
|
|
|
string[] subs = m.Groups[3].Value.Split(" ".ToCharArray());
|
|
|
|
|
string roid = subs[1];
|
|
|
|
|
string val = lookup.GetRoValue(subs[1]);
|
|
|
|
|
if (val == null) val = lookup.GetRoValue(subs[1].Substring(0, 12));
|
|
|
|
|
if (val != null)
|
|
|
|
|
{
|
|
|
|
|
string[] vals = val.Split("\n".ToCharArray());
|
|
|
|
|
Width = Int32.Parse(vals[3], System.Globalization.NumberStyles.AllowHexSpecifier) * _CharsToTwips;
|
|
|
|
|
int lines = Int32.Parse(vals[2], System.Globalization.NumberStyles.AllowHexSpecifier);
|
|
|
|
|
Height = lines * SixLinesPerInch;
|
|
|
|
|
yoff += (Height + (2 * SixLinesPerInch));
|
|
|
|
|
string erMsg = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
ROImageInfo roImage = ROImageInfo.GetByROFstID_FileName(rofst.ROFstID, vals[0]);
|
|
|
|
|
if (roImage != null)
|
|
|
|
|
ImageText = val;
|
|
|
|
|
else
|
|
|
|
|
erMsg = string.Format("Image {0} does not exist.", vals[0]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
erMsg = string.Format("Image {0} does not exist, error = {1}.", vals[0], ex.Message);
|
|
|
|
|
}
|
|
|
|
|
if (erMsg != null) Rtf = GetRtf(erMsg, itemInfo.ActiveFormat.PlantFormat.FormatData.Font);
|
|
|
|
|
}
|
|
|
|
|
CalculateXOffset(itemInfo, maxRNO, formatInfo);
|
|
|
|
|
}
|
|
|
|
|
XOffset = hls.XOffset + hls.Width / 2 - Width / 2;
|
|
|
|
|
if (XOffset < (float)itemInfo.MyDocStyle.Layout.LeftMargin)
|
|
|
|
|
XOffsetBox = (float)itemInfo.MyDocStyle.Layout.LeftMargin;
|
|
|
|
|
}
|
|
|
|
|
if (!itemInfo.IsStepSection) // Don't add any lines for the Section Title
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
yoff += Height;
|
|
|
|
|
yoff += AdjustForBlankLines();
|
|
|
|
|
}
|
|
|
|
|
if (itemInfo.IsFigure)
|
|
|
|
|
{
|
|
|
|
|
// get image from ro.
|
|
|
|
|
string myro = itemInfo.MyContent.Text;
|
|
|
|
|
Rtf = GetRtf(itemInfo);
|
|
|
|
|
if (itemInfo.IsTablePart)
|
|
|
|
|
{
|
|
|
|
|
Width = GetTableWidth(cb, IParagraph);
|
|
|
|
|
CalculateXOffset(itemInfo, maxRNO, formatInfo);
|
|
|
|
|
}
|
|
|
|
|
if (!itemInfo.IsStepSection) // Don't add any lines for the Section Title
|
|
|
|
|
{
|
|
|
|
|
yoff += Height;
|
|
|
|
|
yoff += AdjustForBlankLines();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
float yOffRight = yoff;
|
|
|
|
|
float RnoOffset = ToInt(formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.ColRTable, maxRNO);
|
|
|
|
@@ -361,6 +426,23 @@ namespace Volian.Print.Library
|
|
|
|
|
}
|
|
|
|
|
YBottomMost = yoff;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void CalculateXOffset(ItemInfo itemInfo, int maxRNO, FormatInfo formatInfo)
|
|
|
|
|
{
|
|
|
|
|
bool aerFigure = itemInfo.FormatStepData.Type.Contains("AER");
|
|
|
|
|
vlnParagraph hls1 = MyParent;
|
|
|
|
|
while (hls1.MyParent != null && !hls1.MyItemInfo.IsHigh) hls1 = hls1.MyParent;
|
|
|
|
|
XOffset = hls1.XOffset + hls1.Width / 2 - Width / 2; // xoffset if AER column
|
|
|
|
|
if (!aerFigure)
|
|
|
|
|
{
|
|
|
|
|
// adjust for RNO
|
|
|
|
|
int colR = int.Parse(formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.ColRTable.Split(",".ToCharArray())[itemInfo.ColumnMode]);
|
|
|
|
|
XOffset += (colR * maxRNO) / 2;
|
|
|
|
|
XOffset -= (hls1.XOffset - (float)itemInfo.MyDocStyle.Layout.LeftMargin) / 2;
|
|
|
|
|
}
|
|
|
|
|
if (XOffset < (float)itemInfo.MyDocStyle.Layout.LeftMargin)
|
|
|
|
|
XOffsetBox = (float)itemInfo.MyDocStyle.Layout.LeftMargin;
|
|
|
|
|
}
|
|
|
|
|
private float AdjustForBlankLines()
|
|
|
|
|
{
|
|
|
|
|
int everyNLines = MyItemInfo.FormatStepData == null ? 1 : MyItemInfo.FormatStepData.StepLayoutData.EveryNLines ?? 1;
|
|
|
|
|