Skip to content

Commit

Permalink
Merge pull request #669 from bcgov/dev
Browse files Browse the repository at this point in the history
Document markup fixes
  • Loading branch information
divyav-aot authored Dec 21, 2023
2 parents 8e5798d + b48abab commit 40672a5
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 46 deletions.
86 changes: 43 additions & 43 deletions MCS.FOI.S3FileConversion/MCS.FOI.DocToPDF/DocFileProcessor.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

using Serilog;
using Syncfusion.DocIO.DLS;
using Syncfusion.DocIO.DLS;
using Syncfusion.DocIORenderer;
using Syncfusion.Pdf;

Expand Down Expand Up @@ -41,35 +41,35 @@ public DocFileProcessor(Stream SourceStream)
{
try
{
using (WordDocument wordDocument = new WordDocument(SourceStream, Syncfusion.DocIO.FormatType.Automatic))
{

wordDocument.RevisionOptions.CommentDisplayMode = CommentDisplayMode.ShowInBalloons;
wordDocument.RevisionOptions.CommentColor = RevisionColor.Blue;

using (DocIORenderer renderer = new DocIORenderer())
{
using PdfDocument pdfDocument = renderer.ConvertToPDF(wordDocument);
//Save the PDF file
//Close the instance of document objects
pdfDocument.Save(output);
pdfDocument.Close(true);
converted = true;

}

}
using (WordDocument wordDocument = new WordDocument(SourceStream, Syncfusion.DocIO.FormatType.Automatic))
{

wordDocument.RevisionOptions.CommentDisplayMode = CommentDisplayMode.ShowInBalloons;
wordDocument.RevisionOptions.CommentColor = RevisionColor.Blue;
wordDocument.RevisionOptions.ShowMarkup = RevisionType.Deletions | RevisionType.Insertions;

using (DocIORenderer renderer = new DocIORenderer())
{
using PdfDocument pdfDocument = renderer.ConvertToPDF(wordDocument);
//Save the PDF file
//Close the instance of document objects
pdfDocument.Save(output);
pdfDocument.Close(true);
converted = true;

}

}
}
catch (Exception e)
{
string errorMessage = $"Exception occured while coverting a document file, exception : {e.Message}";
message = $"Exception happened while accessing File, re-attempting count : {attempt} , Error Message : {e.Message} , Stack trace : {e.StackTrace}";
Log.Error(message);
Console.WriteLine(message);
if (attempt == FailureAttemptCount)
{
throw new Exception(errorMessage);
if (attempt == FailureAttemptCount)
{
throw new Exception(errorMessage);
}
Thread.Sleep(WaitTimeinMilliSeconds);
}
Expand All @@ -84,28 +84,28 @@ public DocFileProcessor(Stream SourceStream)
throw;
}
return (converted, output);
}

public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}

protected virtual void Dispose(bool disposing)
{
if (disposing)
{
if (this.SourceStream != null)
{
this.SourceStream.Close();
this.SourceStream.Dispose();
}

if (output != null) output.Dispose();
// free managed resources
}

public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}

protected virtual void Dispose(bool disposing)
{
if (disposing)
{
if (this.SourceStream != null)
{
this.SourceStream.Close();
this.SourceStream.Dispose();
}

if (output != null) output.Dispose();
// free managed resources
}

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
convert_to_pst
)

# font_path = '../utils/common/BCSans-Regular_2f.ttf'

def __getcredentialsbybcgovcode(bcgovcode):
_conn = getdbconnection()
s3cred = None
Expand Down Expand Up @@ -135,7 +133,6 @@ def add_annotations_as_text_to_pdf(source_document, bytes_stream):
for annot in annotations_on_page:
annot_text = __constructannotationtext(annot)
lines_needed = len(annot_text.split('\n'))
print(f'annot_text = {annot_text}')
if text_start_position == 50:
new_page_index += 1
updated_document.insert_page(new_page_index)
Expand Down
Binary file not shown.

0 comments on commit 40672a5

Please sign in to comment.