B2016-277: don’t crash on bad data in text field for a figure
This commit is contained in:
parent
cc30214d31
commit
929d027394
@ -1246,18 +1246,26 @@ namespace Volian.Print.Library
|
|||||||
if (ImageText == "figure")
|
if (ImageText == "figure")
|
||||||
{
|
{
|
||||||
ImageConfig ic = new ImageConfig(MyItemInfo.MyContent.MyImage);
|
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;
|
// B2016-277: add a try catch in case of there being 'bad' data in the text field for an image/figure
|
||||||
MemoryStream ms = new MemoryStream(idata);
|
try
|
||||||
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;
|
byte[] idata = (ic != null && ic.Image_DataSize > 0) ? ROImageInfo.Decompress(MyItemInfo.MyContent.MyImage.Data, ic.Image_DataSize) : MyItemInfo.MyContent.MyImage.Data;
|
||||||
Height = ic.Image_Height;
|
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;
|
||||||
|
}
|
||||||
|
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"));
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
retval += SixLinesPerInch;
|
||||||
}
|
}
|
||||||
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
|
else
|
||||||
{
|
{
|
||||||
@ -3372,7 +3380,7 @@ namespace Volian.Print.Library
|
|||||||
{
|
{
|
||||||
int profileDepth2 = ProfileTimer.Push(">>>> Before vlnParagraph.Figure");
|
int profileDepth2 = ProfileTimer.Push(">>>> Before vlnParagraph.Figure");
|
||||||
string erMsg = null;
|
string erMsg = null;
|
||||||
if (itemInfo.MyContent.Text != null) // ro image
|
if (itemInfo.MyContent.Text != null) // ro image
|
||||||
{
|
{
|
||||||
ProcedureInfo proc = itemInfo.MyProcedure;
|
ProcedureInfo proc = itemInfo.MyProcedure;
|
||||||
DocVersionInfo dvi = proc.MyDocVersion;
|
DocVersionInfo dvi = proc.MyDocVersion;
|
||||||
@ -3467,20 +3475,28 @@ namespace Volian.Print.Library
|
|||||||
{
|
{
|
||||||
ImageText = "figure";
|
ImageText = "figure";
|
||||||
ImageConfig ic = new ImageConfig(MyItemInfo.MyContent.MyImage);
|
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;
|
// B2016-277: add a try catch in case of there being 'bad' data in the text field for an image/figure
|
||||||
MemoryStream ms = new MemoryStream(idata);
|
try
|
||||||
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;
|
byte[] idata = (ic != null && ic.Image_DataSize > 0) ? ROImageInfo.Decompress(MyItemInfo.MyContent.MyImage.Data, ic.Image_DataSize) : MyItemInfo.MyContent.MyImage.Data;
|
||||||
Height = ic.Image_Height;
|
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);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_MyLog.WarnFormat("Bad figure content data: item = {0}, {1}", MyItemInfo.ItemID, MyItemInfo.ShortPath);
|
||||||
}
|
}
|
||||||
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);
|
ProfileTimer.Pop(profileDepth2);
|
||||||
}
|
}
|
||||||
@ -5539,8 +5555,8 @@ namespace Volian.Print.Library
|
|||||||
{
|
{
|
||||||
// B2016-269: if caution/note & not boxed, with tab adjust width based on xoffset of tab
|
// B2016-269: if caution/note & not boxed, with tab adjust width based on xoffset of tab
|
||||||
// so text doesn't print out of right border. Commented out to check in another fix. Will be use
|
// so text doesn't print out of right border. Commented out to check in another fix. Will be use
|
||||||
//if (!MyItemInfo.MyParent.IsHigh && MyTab!=null && MyTab.YOffset==YOffset)
|
//if (!MyItemInfo.MyParent.IsHigh && MyTab != null && MyTab.YOffset == YOffset)
|
||||||
// Width = (float)formatInfo.MyStepSectionLayoutData.WidT - MyTab.XOffset - mycolT;
|
// Width = MyHighLevelParagraph.Width - MyTab.Width - (MyTab.XOffset - MyHighLevelParagraph.XOffset) - 6;
|
||||||
//else
|
//else
|
||||||
Width = (float)formatInfo.MyStepSectionLayoutData.WidT - 6 - mycolT;
|
Width = (float)formatInfo.MyStepSectionLayoutData.WidT - 6 - mycolT;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user