B2016-277: don’t crash on bad data in text field for a figure
This commit is contained in:
parent
cc30214d31
commit
929d027394
@ -1246,6 +1246,9 @@ namespace Volian.Print.Library
|
|||||||
if (ImageText == "figure")
|
if (ImageText == "figure")
|
||||||
{
|
{
|
||||||
ImageConfig ic = new ImageConfig(MyItemInfo.MyContent.MyImage);
|
ImageConfig ic = new ImageConfig(MyItemInfo.MyContent.MyImage);
|
||||||
|
// B2016-277: add a try catch in case of there being 'bad' data in the text field for an image/figure
|
||||||
|
try
|
||||||
|
{
|
||||||
byte[] idata = (ic != null && ic.Image_DataSize > 0) ? ROImageInfo.Decompress(MyItemInfo.MyContent.MyImage.Data, ic.Image_DataSize) : MyItemInfo.MyContent.MyImage.Data;
|
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);
|
MemoryStream ms = new MemoryStream(idata);
|
||||||
System.Drawing.Image img = System.Drawing.Image.FromStream(ms);
|
System.Drawing.Image img = System.Drawing.Image.FromStream(ms);
|
||||||
@ -1259,6 +1262,11 @@ namespace Volian.Print.Library
|
|||||||
iTextSharp.text.Image it_image = iTextSharp.text.Image.GetInstance(idata);
|
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"));
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string[] vals = ImageText.Split("\n".ToCharArray());
|
string[] vals = ImageText.Split("\n".ToCharArray());
|
||||||
@ -3467,6 +3475,9 @@ namespace Volian.Print.Library
|
|||||||
{
|
{
|
||||||
ImageText = "figure";
|
ImageText = "figure";
|
||||||
ImageConfig ic = new ImageConfig(MyItemInfo.MyContent.MyImage);
|
ImageConfig ic = new ImageConfig(MyItemInfo.MyContent.MyImage);
|
||||||
|
// B2016-277: add a try catch in case of there being 'bad' data in the text field for an image/figure
|
||||||
|
try
|
||||||
|
{
|
||||||
byte[] idata = (ic != null && ic.Image_DataSize > 0) ? ROImageInfo.Decompress(MyItemInfo.MyContent.MyImage.Data, ic.Image_DataSize) : MyItemInfo.MyContent.MyImage.Data;
|
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);
|
MemoryStream ms = new MemoryStream(idata);
|
||||||
System.Drawing.Image img = System.Drawing.Image.FromStream(ms);
|
System.Drawing.Image img = System.Drawing.Image.FromStream(ms);
|
||||||
@ -3482,6 +3493,11 @@ namespace Volian.Print.Library
|
|||||||
yoff += (Height + ((noborder ? 2 : 3) * SixLinesPerInch));
|
yoff += (Height + ((noborder ? 2 : 3) * SixLinesPerInch));
|
||||||
CalculateXOffsetGridOrFigure(itemInfo, maxRNO, formatInfo);
|
CalculateXOffsetGridOrFigure(itemInfo, maxRNO, formatInfo);
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_MyLog.WarnFormat("Bad figure content data: item = {0}, {1}", MyItemInfo.ItemID, MyItemInfo.ShortPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
ProfileTimer.Pop(profileDepth2);
|
ProfileTimer.Pop(profileDepth2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -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