Skip to content

Commit

Permalink
Merge pull request #1048 from bcgov/dev
Browse files Browse the repository at this point in the history
FOIMOD-3248, FOIMOD-3267 , FOIMOD-3299
  • Loading branch information
aparna-aot authored Jul 10, 2024
2 parents 9873b3a + b51dc7f commit c33bfc2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
20 changes: 17 additions & 3 deletions MCS.FOI.S3FileConversion/MCS.FOI.MSGToPDF/MSGFileProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,22 @@ public MSGFileProcessor(Stream sourceStream)
}
}
var startAt = 0;
foreach (var inlineAttachment in inlineAttachments.OrderBy(m => m.GetType().GetProperty("RenderingPosition").GetValue(m, null)))
foreach (var inlineAttachment in inlineAttachments.OrderBy(m =>
{
int pos = (int) m.GetType().GetProperty("RenderingPosition").GetValue(m, null);
if (pos > -1)
{
return pos;
}
else
{
var _inlineAttachment = (Storage.Attachment)m;
Regex regex = new Regex(@"<img(.|\\n)*cid:" + _inlineAttachment.ContentId + "(.|\\n)*?>");
Match match = regex.Match(bodyreplaced, startAt);
return match.Index;
}
}))
{
if (rtfInline)
{
if (!inlineAttachment.GetType().FullName.ToLower().Contains("message"))
Expand Down Expand Up @@ -185,7 +199,7 @@ public MSGFileProcessor(Stream sourceStream)
else if (htmlInline)
{
var _inlineAttachment = (Storage.Attachment)inlineAttachment;
Regex regex = new Regex("<img(.|\\n)*cid:" + _inlineAttachment.ContentId + "(.|\\n)*?>");
Regex regex = new Regex(@"<img(.|\\n)*cid:" + _inlineAttachment.ContentId + "(.|\\n)*?>");
Match match = regex.Match(bodyreplaced, startAt);
if (match.Success)
{
Expand Down Expand Up @@ -218,7 +232,7 @@ public MSGFileProcessor(Stream sourceStream)
heightString = " height =\"" + height + "\"";
}
string imgReplacementString = "<img "+ widthString + heightString + " style =\"margin: 1px;\" src=\"data:" + _inlineAttachment.MimeType + ";base64," + Convert.ToBase64String(_inlineAttachment.Data) + "\"/>";
bodyreplaced = regex.Replace(bodyreplaced, imgReplacementString, 1, startAt);
bodyreplaced = regex.Replace(bodyreplaced, imgReplacementString, Int32.MaxValue, startAt);
startAt = match.Index + imgReplacementString.Length;
}
foreach (KeyValuePair<MemoryStream, Dictionary<string, string>> attachment in attachmentsObj)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ const useSaveRedlineForSignoff = (initDocInstance, initDocViewer) => {
totalPageCount += Object.keys(
pageMappings[doc.documentid]
).length;
if (!skipDocumentPages) {
if (!skipDocumentPages && !skipOnlyDuplicateDocument && !skipOnlyNRDocument) {
totalPageCountIncludeRemoved += doc.pagecount;
}
//}
Expand Down

0 comments on commit c33bfc2

Please sign in to comment.