Add black border around images/pdfs

Makes viewing things with no border/white border much easier.
This commit is contained in:
2026-03-12 19:34:56 +09:00
parent 742ecb148a
commit 5dda88521d
+10
View File
@@ -628,6 +628,11 @@ class MainViewModel : BaseViewModel, IFontResolver, ICanCheckShutdown
var outputFileName = ReportTitle + ".pdf"; var outputFileName = ReportTitle + ".pdf";
var folderName = new DirectoryInfo(folderPath).Name; var folderName = new DirectoryInfo(folderPath).Name;
const int imageWidth = 425; const int imageWidth = 425;
var imageLineFormat = new MigraDoc.DocumentObjectModel.Shapes.LineFormat()
{
Color = Colors.Black,
Width = Unit.FromPoint(2),
};;
if (folderName.Contains('-')) if (folderName.Contains('-'))
{ {
// see if year/month format // see if year/month format
@@ -782,6 +787,7 @@ class MainViewModel : BaseViewModel, IFontResolver, ICanCheckShutdown
image.Height = 550; // make sure it will fit on one page image.Height = 550; // make sure it will fit on one page
} }
else else
image.LineFormat = imageLineFormat.Clone();
{ {
image.Width = imageWidth; // can't be too wide now...not sure why...maybe due to margins... image.Width = imageWidth; // can't be too wide now...not sure why...maybe due to margins...
} }
@@ -828,6 +834,7 @@ class MainViewModel : BaseViewModel, IFontResolver, ICanCheckShutdown
var image = paragraph.AddImage(convertedPdfImagePath); var image = paragraph.AddImage(convertedPdfImagePath);
image.Width = imageWidth; image.Width = imageWidth;
image.LockAspectRatio = true; image.LockAspectRatio = true;
image.LineFormat = imageLineFormat.Clone();
for (var j = 1; j < pgCount; j++) for (var j = 1; j < pgCount; j++)
{ {
section.AddPageBreak(); section.AddPageBreak();
@@ -837,6 +844,7 @@ class MainViewModel : BaseViewModel, IFontResolver, ICanCheckShutdown
image = paragraph.AddImage(convertedPdfImagePath); image = paragraph.AddImage(convertedPdfImagePath);
image.LockAspectRatio = true; image.LockAspectRatio = true;
image.Width = imageWidth; image.Width = imageWidth;
image.LineFormat = imageLineFormat.Clone();
} }
} }
} }
@@ -848,6 +856,7 @@ class MainViewModel : BaseViewModel, IFontResolver, ICanCheckShutdown
var image = paragraph.AddImage(filePath); var image = paragraph.AddImage(filePath);
image.LockAspectRatio = true; image.LockAspectRatio = true;
image.Width = imageWidth; // can't be too wide now...not sure why...maybe due to margins... image.Width = imageWidth; // can't be too wide now...not sure why...maybe due to margins...
image.LineFormat = imageLineFormat.Clone();
// render other PDF pages, if any // render other PDF pages, if any
// see: https://stackoverflow.com/a/65091204/3938401 // see: https://stackoverflow.com/a/65091204/3938401
var pdfFileToAdd = PdfReader.Open(filePath, PdfDocumentOpenMode.Import); var pdfFileToAdd = PdfReader.Open(filePath, PdfDocumentOpenMode.Import);
@@ -863,6 +872,7 @@ class MainViewModel : BaseViewModel, IFontResolver, ICanCheckShutdown
image = paragraph.AddImage(filePath + "#" + j); image = paragraph.AddImage(filePath + "#" + j);
image.LockAspectRatio = true; image.LockAspectRatio = true;
image.Width = imageWidth; image.Width = imageWidth;
image.LineFormat = imageLineFormat.Clone();
} }
} }
} }