Embedded images
This commit is contained in:
@@ -386,7 +386,11 @@ namespace Volian.Print.Library
|
||||
h.Add(oldTypeName + " to " + cai.TypeName);
|
||||
else
|
||||
{
|
||||
string txt = ItemInfo.ConvertToDisplayText(cai.Text);
|
||||
string txt = null;
|
||||
if ((cai.Text==null || cai.Text=="") && (cai.Type == 20036 || cai.Type == 20037 || cai.Type == 20038 || cai.Type == 20039))
|
||||
txt = "Embedded Image";
|
||||
else
|
||||
txt = ItemInfo.ConvertToDisplayText(cai.Text);
|
||||
if (MyProc.MyDocVersion.MultiUnitCount > 1)
|
||||
{
|
||||
System.Xml.XmlNode nd;
|
||||
@@ -1509,7 +1513,11 @@ namespace Volian.Print.Library
|
||||
h.Add(oldTypeName + " to " + cai.TypeName);
|
||||
else
|
||||
{
|
||||
string txt = ItemInfo.ConvertToDisplayText(cai.Text);
|
||||
string txt = null;
|
||||
if ((cai.Text==null || cai.Text=="") && (cai.Type == 20036 || cai.Type == 20037 || cai.Type == 20038 || cai.Type == 20039))
|
||||
txt = "Embedded Image";
|
||||
else
|
||||
txt = ItemInfo.ConvertToDisplayText(cai.Text);
|
||||
// Add Parent/Child information if applicable
|
||||
// We were doing this for the Chronology report so I added the same logic here for the Summary report
|
||||
if (MyProc.MyDocVersion.MultiUnitCount > 1)
|
||||
|
@@ -1210,55 +1210,82 @@ namespace Volian.Print.Library
|
||||
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) roImage = rofst.GetROImageByFilename(vals[0],MyItemInfo);// need code to go and get an ROImaage if it exists
|
||||
if (roImage != null)
|
||||
if (ImageText == "figure")
|
||||
{
|
||||
ROImageConfig rc = new ROImageConfig(roImage);
|
||||
int size = Convert.ToInt32(rc.Image_Size);
|
||||
byte[] cnt = roImage.Content;
|
||||
byte[] dcnt = ROImageInfo.Decompress(cnt, size);
|
||||
iTextSharp.text.Image it_image=null;
|
||||
try
|
||||
ImageConfig ic = new ImageConfig(MyItemInfo.MyContent.MyImage);
|
||||
byte[] idata = (ic != null && ic.Image_DataSize > 0) ? ROImageInfo.Decompress(MyItemInfo.MyContent.MyImage.Data, ic.Image_DataSize) : MyItemInfo.MyContent.MyImage.Data;
|
||||
MemoryStream ms = new MemoryStream(idata);
|
||||
System.Drawing.Image img = System.Drawing.Image.FromStream(ms);
|
||||
Width = img.Width;
|
||||
Height = img.Height;
|
||||
if (ic != null && ic.Image_Height != 0)
|
||||
{
|
||||
it_image = iTextSharp.text.Image.GetInstance(dcnt);
|
||||
//iTextSharp.text.Image it_image = iTextSharp.text.Image.GetInstance(ROImageInfo.Decompress(roImage.Content, size));
|
||||
Width = ic.Image_Width;
|
||||
Height = ic.Image_Height;
|
||||
}
|
||||
catch
|
||||
iTextSharp.text.Image it_image = iTextSharp.text.Image.GetInstance(idata);
|
||||
retval = Rtf2Pdf.FigureAt(cb, it_image, XOffset + MyItemInfo.FormatStepData.Font.CharsToTwips, yLocation, Width * MyPageHelper.YMultiplier, Height * MyPageHelper.YMultiplier, DebugInfo, yBottomMargin, !MyItemInfo.FormatStepData.Type.Contains("Borderless"));
|
||||
}
|
||||
else
|
||||
{
|
||||
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) roImage = rofst.GetROImageByFilename(vals[0], MyItemInfo);// need code to go and get an ROImaage if it exists
|
||||
if (roImage != null)
|
||||
{
|
||||
MemoryStream ms = new MemoryStream(dcnt);
|
||||
System.Drawing.Bitmap bm = new System.Drawing.Bitmap(ms);
|
||||
using (MemoryStream ms2 = new MemoryStream())
|
||||
ROImageConfig rc = new ROImageConfig(roImage);
|
||||
int size = Convert.ToInt32(rc.Image_Size);
|
||||
byte[] cnt = roImage.Content;
|
||||
byte[] dcnt = ROImageInfo.Decompress(cnt, size);
|
||||
iTextSharp.text.Image it_image = null;
|
||||
try
|
||||
{
|
||||
bm.Save(ms2, System.Drawing.Imaging.ImageFormat.Png);
|
||||
ms2.Seek(0, SeekOrigin.Begin);
|
||||
byte[] newdcnt = new byte[ms2.Length];
|
||||
ms2.Read(newdcnt, 0, (int)ms2.Length);
|
||||
try
|
||||
it_image = iTextSharp.text.Image.GetInstance(dcnt);
|
||||
}
|
||||
catch
|
||||
{
|
||||
MemoryStream ms = new MemoryStream(dcnt);
|
||||
System.Drawing.Bitmap bm = new System.Drawing.Bitmap(ms);
|
||||
using (MemoryStream ms2 = new MemoryStream())
|
||||
{
|
||||
it_image = iTextSharp.text.Image.GetInstance(newdcnt);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_MyLog.Error(string.Format("{0}",roImage.FileName),ex);
|
||||
return yLocation;
|
||||
bm.Save(ms2, System.Drawing.Imaging.ImageFormat.Png);
|
||||
ms2.Seek(0, SeekOrigin.Begin);
|
||||
byte[] newdcnt = new byte[ms2.Length];
|
||||
ms2.Read(newdcnt, 0, (int)ms2.Length);
|
||||
try
|
||||
{
|
||||
it_image = iTextSharp.text.Image.GetInstance(newdcnt);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_MyLog.Error(string.Format("{0}", roImage.FileName), ex);
|
||||
return yLocation;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//iTextSharp.text.Image it_image = iTextSharp.text.Image.GetInstance(ROImageInfo.Decompress(roImage.Content, size));
|
||||
retval = Rtf2Pdf.FigureAt(cb, it_image, XOffset + MyItemInfo.FormatStepData.Font.CharsToTwips, yLocation, Width * MyPageHelper.YMultiplier, Height * MyPageHelper.YMultiplier, DebugInfo, yBottomMargin, !MyItemInfo.FormatStepData.Type.Contains("Borderless"));
|
||||
StepConfig sc = new StepConfig(MyItemInfo as StepInfo);
|
||||
if (sc != null && sc.Step_ImageWidth != 0)
|
||||
{
|
||||
Width = sc.Step_ImageWidth;
|
||||
Height = sc.Step_ImageHeight;
|
||||
}
|
||||
retval = Rtf2Pdf.FigureAt(cb, it_image, XOffset + MyItemInfo.FormatStepData.Font.CharsToTwips, yLocation, Width * MyPageHelper.YMultiplier, Height * MyPageHelper.YMultiplier, DebugInfo, yBottomMargin, !MyItemInfo.FormatStepData.Type.Contains("Borderless"));
|
||||
}
|
||||
}
|
||||
// The following code was added to fix B2016-219 (for VCS, the centerline drew through a figure). The 'top' value was taken from the code
|
||||
// that draws the vlnBoxes (Caution/Note, etc)
|
||||
// The adjustments, adjtop & adjbottom, were necessary to get the vertical centerline to meet up correctly with the top/bottom of the figure. These
|
||||
// numbers were determined by trial and error.
|
||||
|
||||
// The following code was added to fix B2016-219 (for VCS, the centerline drew through a figure). The 'top' value was taken from the code
|
||||
// that draws the vlnBoxes (Caution/Note, etc)
|
||||
// The adjustments, adjtop & adjbottom, were necessary to get the vertical centerline to meet up correctly with the top/bottom of the figure. These
|
||||
// numbers were determined by trial and error.
|
||||
// only add gap if centered, i.e. in 2 column mode & table is centered
|
||||
if (MyItemInfo.ColumnMode > 0 && (!MyItemInfo.FormatStepData.Type.Contains("AER") && !MyItemInfo.IsInRNO))
|
||||
{
|
||||
float top = CalculateYOffset(yPageStart, yTopMargin) - (7 * MyPageHelper.YMultiplier);
|
||||
float adjtop=0;
|
||||
float adjbottom=0;
|
||||
float adjtop = 0;
|
||||
float adjbottom = 0;
|
||||
if (MyPageHelper.YMultiplier == 1)
|
||||
adjtop = -3;
|
||||
else
|
||||
@@ -3303,10 +3330,9 @@ namespace Volian.Print.Library
|
||||
{
|
||||
int profileDepth2 = ProfileTimer.Push(">>>> Before vlnParagraph.Figure");
|
||||
string erMsg = null;
|
||||
if (itemInfo.MyContent.Text != null)
|
||||
if (itemInfo.MyContent.Text != null) // ro image
|
||||
{
|
||||
ProcedureInfo proc = itemInfo.MyProcedure;
|
||||
// DocVersionInfo dvi = proc.ActiveParent as DocVersionInfo;
|
||||
DocVersionInfo dvi = proc.MyDocVersion;
|
||||
ROFstInfo rofst = dvi.DocVersionAssociations[0].MyROFst;
|
||||
//rofst.docVer = dvi;
|
||||
@@ -3342,51 +3368,78 @@ namespace Volian.Print.Library
|
||||
}
|
||||
}
|
||||
GC.Collect(); // memory garbage collection (Regex memory bug)
|
||||
if (val != null && val != "?")
|
||||
if (val != null && val != "?")
|
||||
{
|
||||
string[] vals = val.Split("\n".ToCharArray());
|
||||
Width = Int32.Parse(vals[3], System.Globalization.NumberStyles.AllowHexSpecifier) * MyItemInfo.FormatStepData.Font.CharsToTwips;
|
||||
int lines = Int32.Parse(vals[2], System.Globalization.NumberStyles.AllowHexSpecifier);
|
||||
// Check that the Height of figure isn't too big to fit on the page, if it is
|
||||
// set the Height to the printable part of page - Height of the HLS and an extra line
|
||||
// for between HLS & figure.
|
||||
float h1 = lines * SixLinesPerInch;
|
||||
float h2 = RoughSizeOfPage - MyParent.Height - SixLinesPerInch;
|
||||
Height = Math.Min(h1, h2);
|
||||
if (h1 > h2)
|
||||
{
|
||||
string[] vals = val.Split("\n".ToCharArray());
|
||||
Width = Int32.Parse(vals[3], System.Globalization.NumberStyles.AllowHexSpecifier) * MyItemInfo.FormatStepData.Font.CharsToTwips;
|
||||
int lines = Int32.Parse(vals[2], System.Globalization.NumberStyles.AllowHexSpecifier);
|
||||
// Check that the Height of figure isn't too big to fit on the page, if it is
|
||||
// set the Height to the printable part of page - Height of the HLS and an extra line
|
||||
// for between HLS & figure.
|
||||
float h1 = lines * SixLinesPerInch;
|
||||
float h2 = RoughSizeOfPage - MyParent.Height - SixLinesPerInch;
|
||||
Height = Math.Min(h1, h2);
|
||||
if (h1 > h2)
|
||||
Width *= (h2 / h1);
|
||||
}
|
||||
StepConfig sc = new StepConfig(MyItemInfo as StepInfo);
|
||||
if (sc != null && sc.Step_ImageWidth != 0)
|
||||
{
|
||||
Width = sc.Step_ImageWidth;
|
||||
Height = sc.Step_ImageHeight;
|
||||
}
|
||||
yoff = AdjustLocIfLongerRNO(itemInfo, yoff, yoffRightParent);
|
||||
if (dropCheckoff)
|
||||
yForCheckoff += Height - SixLinesPerInch; // place checkoff on last row of text
|
||||
bool noborder = MyItemInfo.FormatStepData.Type.ToUpper().Contains("BORDERLESS");
|
||||
yoff += (Height + ((noborder ? 1 : 2) * SixLinesPerInch)); // RHM 20120925 - Eliminate extra space after Figure }
|
||||
try
|
||||
{
|
||||
ROImageInfo roImage = ROImageInfo.GetByROFstID_FileName(rofst.ROFstID, vals[0]);
|
||||
if (roImage != null)
|
||||
ImageText = val;
|
||||
else
|
||||
{
|
||||
Width *= (h2 / h1);
|
||||
}
|
||||
//yForCheckoff = yoff + Height - SixLinesPerInch;
|
||||
yoff = AdjustLocIfLongerRNO(itemInfo, yoff, yoffRightParent);
|
||||
if (dropCheckoff)
|
||||
yForCheckoff += Height - SixLinesPerInch; // place checkoff on last row of text
|
||||
bool noborder = MyItemInfo.FormatStepData.Type.ToUpper().Contains("BORDERLESS");
|
||||
yoff += (Height + ((noborder ? 1 : 2) * SixLinesPerInch)); // RHM 20120925 - Eliminate extra space after Figure }
|
||||
|
||||
try
|
||||
{
|
||||
ROImageInfo roImage = ROImageInfo.GetByROFstID_FileName(rofst.ROFstID, vals[0]);
|
||||
if (roImage != null)
|
||||
ImageText = val;
|
||||
roImage = rofst.GetROImageByFilename(vals[0], MyItemInfo);// need code to go and get an ROImaage if it exists
|
||||
if (roImage == null)
|
||||
erMsg = string.Format("Image {0} does not exist.", vals[0]);
|
||||
else
|
||||
{
|
||||
roImage = rofst.GetROImageByFilename(vals[0], MyItemInfo);// need code to go and get an ROImaage if it exists
|
||||
if (roImage == null)
|
||||
erMsg = string.Format("Image {0} does not exist.", vals[0]);
|
||||
else
|
||||
ImageText = val;
|
||||
}
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
erMsg = string.Format("Image {0} does not exist, error = {1}.", vals[0], ex.Message);
|
||||
ImageText = val;
|
||||
}
|
||||
}
|
||||
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);
|
||||
CalculateXOffsetGridOrFigure(itemInfo, maxRNO, formatInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
// figure
|
||||
ImageText = "figure";
|
||||
}
|
||||
if (ImageText == null && erMsg == null)
|
||||
{
|
||||
ImageText = "figure";
|
||||
ImageConfig ic = new ImageConfig(MyItemInfo.MyContent.MyImage);
|
||||
byte[] idata = (ic != null && ic.Image_DataSize > 0) ? ROImageInfo.Decompress(MyItemInfo.MyContent.MyImage.Data, ic.Image_DataSize) : MyItemInfo.MyContent.MyImage.Data;
|
||||
MemoryStream ms = new MemoryStream(idata);
|
||||
System.Drawing.Image img = System.Drawing.Image.FromStream(ms);
|
||||
Width = img.Width;
|
||||
Height = img.Height;
|
||||
if (ic != null && ic.Image_Height != 0)
|
||||
{
|
||||
Width = ic.Image_Width;
|
||||
Height = ic.Image_Height;
|
||||
}
|
||||
yoff = AdjustLocIfLongerRNO(itemInfo, yoff, yoffRightParent);
|
||||
bool noborder = MyItemInfo.FormatStepData.Type.ToUpper().Contains("BORDERLESS");
|
||||
yoff += (Height + ((noborder ? 2 : 3) * SixLinesPerInch));
|
||||
CalculateXOffsetGridOrFigure(itemInfo, maxRNO, formatInfo);
|
||||
}
|
||||
ProfileTimer.Pop(profileDepth2);
|
||||
}
|
||||
else
|
||||
@@ -5230,7 +5283,7 @@ namespace Volian.Print.Library
|
||||
//}
|
||||
else // if no left justify, right align the tab
|
||||
{
|
||||
// The following fixes F2016-033: Print the Verification Point at left margin.
|
||||
// The following fixes F2016-033: Print the Verification Point at left margin.
|
||||
if (itemInfo.ActiveFormat.Name.ToUpper().StartsWith("VCB") && (itemInfo.FormatStepData.ColOverride ?? 0) > 0)
|
||||
{
|
||||
XOffset = (float)itemInfo.FormatStepData.ColOverride;
|
||||
@@ -5379,12 +5432,12 @@ namespace Volian.Print.Library
|
||||
}
|
||||
if (!itemInfo.ActiveFormat.Name.ToUpper().StartsWith("VCB")) // Don't do the following if in a vcb format (part of fix F2016-039)
|
||||
{
|
||||
if (!HasCheckOffHeading(itemInfo, formatInfo) && CheckOffAdj < 0)
|
||||
CheckOffAdj += (float)(9 * 7.2); // 9 is the size of the SIGNOFF adjustment
|
||||
else if (!FmtHasAdj && HasCheckOffHeading(itemInfo, formatInfo))
|
||||
// For Robinson, tried using font's CharsToTwips but it made it too narrow, so used hardcoded 6:
|
||||
CheckOffAdj = -((float)9 * 6);
|
||||
}
|
||||
if (!HasCheckOffHeading(itemInfo, formatInfo) && CheckOffAdj < 0)
|
||||
CheckOffAdj += (float)(9 * 7.2); // 9 is the size of the SIGNOFF adjustment
|
||||
else if (!FmtHasAdj && HasCheckOffHeading(itemInfo, formatInfo))
|
||||
// For Robinson, tried using font's CharsToTwips but it made it too narrow, so used hardcoded 6:
|
||||
CheckOffAdj = -((float)9 * 6);
|
||||
}
|
||||
}
|
||||
float adjwidth = CheckOffAdj;
|
||||
CheckOffWidth = -CheckOffAdj;
|
||||
@@ -5392,7 +5445,7 @@ namespace Volian.Print.Library
|
||||
Width = ToInt(formatInfo.MyStepSectionLayoutData.WidSTablePrint, maxRNO);
|
||||
Width += _WidthAdjust;
|
||||
Width += adjwidth;
|
||||
|
||||
|
||||
// if AlignHLSTabWithSect is set, we moved the starting x location of the HLS, and following steps
|
||||
// to be under section header. Adjust the width accordingly, or the text may go out of the margin.
|
||||
if (myTab == null && itemInfo.FormatStepData.AlignNullTabWSectHead && itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvert)
|
||||
@@ -5509,8 +5562,8 @@ namespace Volian.Print.Library
|
||||
if (((itemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_SameXOffSubsections) == E_DocStructStyle.DSS_SameXOffSubsections))
|
||||
{
|
||||
// don't adjust the width if there already was an adjustment for checkoffs - for VCB only (F2016-039)
|
||||
if (!(itemInfo.ActiveFormat.Name.ToUpper().StartsWith("VCB") && coadj))
|
||||
adjwidth = MyTab != null ? -MyTab.Width : 0;
|
||||
if (!(itemInfo.ActiveFormat.Name.ToUpper().StartsWith("VCB")&&coadj))
|
||||
adjwidth = MyTab != null ? -MyTab.Width : 0;
|
||||
}
|
||||
else if (sd.UseMetaSections)
|
||||
{
|
||||
|
Reference in New Issue
Block a user