Compare commits

..

7 Commits

Author SHA1 Message Date
tomse
02fca61e80 possible fix bug that magazines only can output to jpg once 2025-08-24 15:40:31 +02:00
tomse
5d8f97e1b8 FIXME - improved pictureviewer should release file locks - now it doesn't show 2025-08-23 17:20:41 +02:00
tomse
626197a22b fixed hardcoded version info + code cleanup 2025-08-23 16:22:44 +02:00
tomse
65a0be77d2 Added "new" project 2025-08-23 16:15:35 +02:00
tomse
edf0f51cfe improved picture cleaning 2025-08-23 16:11:49 +02:00
tomse
ef6c017950 load/save project file 2025-08-23 16:07:41 +02:00
tomse
2993807605 improved input dir handling 2025-08-23 15:15:13 +02:00
23 changed files with 573 additions and 1454 deletions

2
.gitignore vendored
View File

@@ -4,3 +4,5 @@ PDFWorkflowManager/PDFWorkflowManager/bin
PDFWorkflowManager/Setup/Debug
PDFWorkflowManager/Setup/Release
/PDFWorkflowManager/.vs
/PDFWorkflowManager/_.vs
/PDFWorkflowManager/Setup/obj

View File

@@ -1,23 +0,0 @@
{
"Version": 1,
"WorkspaceRootPath": "D:\\Gitea\\RCEU_PDFWorkflowManager\\PDFWorkflowManager\\",
"Documents": [],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": -1,
"Children": [
{
"$type": "Bookmark",
"Name": "ST:0:0:{56df62a4-05a3-4e5b-aa1a-99371ccfb997}"
}
]
}
]
}
]
}

View File

@@ -1,34 +1,56 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.33214.272
# Visual Studio Version 17
VisualStudioVersion = 17.14.36414.22
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PDF Workflow Manager", "PDFWorkflowManager\PDF Workflow Manager.csproj", "{1957F2AD-ACB5-4938-B2BA-3D2C365BBAF6}"
EndProject
Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "Setup", "Setup\Setup.vdproj", "{E4C5F971-3D5B-4645-98E7-2737AE92E82A}"
Project("{B7DD6F7E-DEF8-4E67-B5B7-07EF123DB6F0}") = "Setup", "Setup\Setup.wixproj", "{47F764FC-DE98-4529-9644-412B7636AD30}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM64 = Debug|ARM64
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|ARM64 = Release|ARM64
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1957F2AD-ACB5-4938-B2BA-3D2C365BBAF6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1957F2AD-ACB5-4938-B2BA-3D2C365BBAF6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1957F2AD-ACB5-4938-B2BA-3D2C365BBAF6}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{1957F2AD-ACB5-4938-B2BA-3D2C365BBAF6}.Debug|ARM64.Build.0 = Debug|Any CPU
{1957F2AD-ACB5-4938-B2BA-3D2C365BBAF6}.Debug|x64.ActiveCfg = Debug|x64
{1957F2AD-ACB5-4938-B2BA-3D2C365BBAF6}.Debug|x64.Build.0 = Debug|x64
{1957F2AD-ACB5-4938-B2BA-3D2C365BBAF6}.Debug|x86.ActiveCfg = Debug|Any CPU
{1957F2AD-ACB5-4938-B2BA-3D2C365BBAF6}.Debug|x86.Build.0 = Debug|Any CPU
{1957F2AD-ACB5-4938-B2BA-3D2C365BBAF6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1957F2AD-ACB5-4938-B2BA-3D2C365BBAF6}.Release|Any CPU.Build.0 = Release|Any CPU
{1957F2AD-ACB5-4938-B2BA-3D2C365BBAF6}.Release|ARM64.ActiveCfg = Release|Any CPU
{1957F2AD-ACB5-4938-B2BA-3D2C365BBAF6}.Release|ARM64.Build.0 = Release|Any CPU
{1957F2AD-ACB5-4938-B2BA-3D2C365BBAF6}.Release|x64.ActiveCfg = Release|x64
{1957F2AD-ACB5-4938-B2BA-3D2C365BBAF6}.Release|x64.Build.0 = Release|x64
{E4C5F971-3D5B-4645-98E7-2737AE92E82A}.Debug|Any CPU.ActiveCfg = Debug
{E4C5F971-3D5B-4645-98E7-2737AE92E82A}.Debug|x64.ActiveCfg = Debug
{E4C5F971-3D5B-4645-98E7-2737AE92E82A}.Debug|x64.Build.0 = Debug
{E4C5F971-3D5B-4645-98E7-2737AE92E82A}.Release|Any CPU.ActiveCfg = Release
{E4C5F971-3D5B-4645-98E7-2737AE92E82A}.Release|x64.ActiveCfg = Release
{E4C5F971-3D5B-4645-98E7-2737AE92E82A}.Release|x64.Build.0 = Release
{1957F2AD-ACB5-4938-B2BA-3D2C365BBAF6}.Release|x86.ActiveCfg = Release|Any CPU
{1957F2AD-ACB5-4938-B2BA-3D2C365BBAF6}.Release|x86.Build.0 = Release|Any CPU
{47F764FC-DE98-4529-9644-412B7636AD30}.Debug|Any CPU.ActiveCfg = Debug|x64
{47F764FC-DE98-4529-9644-412B7636AD30}.Debug|Any CPU.Build.0 = Debug|x64
{47F764FC-DE98-4529-9644-412B7636AD30}.Debug|ARM64.ActiveCfg = Debug|ARM64
{47F764FC-DE98-4529-9644-412B7636AD30}.Debug|ARM64.Build.0 = Debug|ARM64
{47F764FC-DE98-4529-9644-412B7636AD30}.Debug|x64.ActiveCfg = Debug|x64
{47F764FC-DE98-4529-9644-412B7636AD30}.Debug|x64.Build.0 = Debug|x64
{47F764FC-DE98-4529-9644-412B7636AD30}.Debug|x86.ActiveCfg = Debug|x86
{47F764FC-DE98-4529-9644-412B7636AD30}.Debug|x86.Build.0 = Debug|x86
{47F764FC-DE98-4529-9644-412B7636AD30}.Release|Any CPU.ActiveCfg = Release|x64
{47F764FC-DE98-4529-9644-412B7636AD30}.Release|Any CPU.Build.0 = Release|x64
{47F764FC-DE98-4529-9644-412B7636AD30}.Release|ARM64.ActiveCfg = Release|ARM64
{47F764FC-DE98-4529-9644-412B7636AD30}.Release|ARM64.Build.0 = Release|ARM64
{47F764FC-DE98-4529-9644-412B7636AD30}.Release|x64.ActiveCfg = Release|x64
{47F764FC-DE98-4529-9644-412B7636AD30}.Release|x64.Build.0 = Release|x64
{47F764FC-DE98-4529-9644-412B7636AD30}.Release|x86.ActiveCfg = Release|x86
{47F764FC-DE98-4529-9644-412B7636AD30}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,55 @@
using ImageMagick;
using System.Drawing;
using System.Drawing.Imaging;
namespace PDFWorkflowManager
{
public static class ImageService
{
public static void ConvertToJpeg(string sourceFileName, string destinationFileName, int compressionLevel, int dpi = 300)
{
using (Image sourceImage = Image.FromFile(sourceFileName))
{
float scaleFactor = dpi / sourceImage.HorizontalResolution;
int newWidth = (int)(sourceImage.Width * scaleFactor);
int newHeight = (int)(sourceImage.Height * scaleFactor);
using (var newImage = new Bitmap(newWidth, newHeight))
{
newImage.SetResolution(dpi, dpi);
using (Graphics graphics = Graphics.FromImage(newImage))
{
graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
graphics.DrawImage(sourceImage, 0, 0, newWidth, newHeight);
}
EncoderParameters encoderParameters = new EncoderParameters(1);
encoderParameters.Param[0] = new EncoderParameter(Encoder.Quality, compressionLevel);
ImageCodecInfo jpegCodec = GetEncoderInfo(ImageFormat.Jpeg);
newImage.Save(destinationFileName, jpegCodec, encoderParameters);
}
}
}
public static ImageCodecInfo GetEncoderInfo(ImageFormat format)
{
foreach (ImageCodecInfo codec in ImageCodecInfo.GetImageDecoders())
{
if (codec.FormatID == format.Guid)
return codec;
}
return null;
}
public static void CreateThumbnail(string fileName, string outputPath)
{
using (var image = new MagickImage(fileName))
{
var size = new MagickGeometry(240, 340) { IgnoreAspectRatio = false };
image.Resize(size);
image.Write(outputPath);
}
}
}
}

View File

@@ -0,0 +1,39 @@
using System.Collections.Generic;
namespace PDFWorkflowManager
{
public static class LanguageService
{
public static readonly Dictionary<string, string> LanguageCodes = new Dictionary<string, string>
{
{"Afrikaans","af"}, {"Amharic","am"}, {"Arabic","ar"}, {"Assamese","as"}, {"Azerbaijani","az"},
{"Belarusian","be"}, {"Bengali","bn"}, {"Bokmal","nb"}, {"Bulgarian","bg"}, {"Catalan","ca"},
{"Chinese(Simplified)","zh-CN"}, {"Chinese(Traditional)","zh-TW"}, {"Croatian","hr"}, {"Czech","cs"},
{"Danish","da"}, {"Dutch","nl"}, {"English","en"}, {"Estonian","et"}, {"Finnish","fi"},
{"French","fr"}, {"German","de"}, {"Greek","el"}, {"Gujarati","gu"}, {"Hebrew","he"},
{"Hindi","hi"}, {"Hungarian","hu"}, {"Icelandic","is"}, {"Indonesian","id"}, {"Italian","it"},
{"Japanese","ja"}, {"Kannada","kn"}, {"Korean","ko"}, {"Latvian","lv"}, {"Lithuanian","lt"},
{"Malayalam","ml"}, {"Marathi","mr"}, {"Nepali","ne"}, {"Norwegian","no"}, {"Oriya","or"},
{"Polish","pl"}, {"Portuguese","pt"}, {"Punjabi","pa"}, {"Romanian","ro"}, {"Russian","ru"},
{"Slovak","sk"}, {"Slovenian","sl"}, {"Spanish","es"}, {"Swahili","sw"}, {"Swedish","sv"},
{"Tamil","ta"}, {"Telugu","te"}, {"Thai","th"}, {"Tibetan","bo"}, {"Turkish","tr"},
{"Ukrainian","uk"}, {"Urdu","ur"}, {"Vietnamese","vi"}
};
public static readonly Dictionary<string, string> TrainLanguage = new Dictionary<string, string>
{
{"Afrikaans","afr"}, {"Amharic","amh"}, {"Arabic","ara"}, {"Assamese","asm"}, {"Azerbaijani","aze"},
{"Belarusian","bel"}, {"Bengali","ben"}, {"Bokmal","nb"}, {"Bulgarian","bul"}, {"Catalan","ca"},
{"Chinese(Simplified)","chi_sim"}, {"Chinese(Traditional)","chi_tra"}, {"Croatian","chr"}, {"Czech","ces"},
{"Danish","dan"}, {"Dutch","nld"}, {"English","eng"}, {"Estonian","est"}, {"Finnish","fin"},
{"French","fra"}, {"German","deu"}, {"Greek","ell"}, {"Gujarati","guj"}, {"Hebrew","heb"},
{"Hindi","hin"}, {"Hungarian","hun"}, {"Icelandic","isl"}, {"Indonesian","ind"}, {"Italian","ita"},
{"Japanese","jpn"}, {"Kannada","kan"}, {"Korean","kor"}, {"Latvian","lav"}, {"Lithuanian","lit"},
{"Malayalam","mal"}, {"Marathi","mar"}, {"Nepali","nep"}, {"Norwegian","nor"}, {"Oriya","ori"},
{"Polish","pol"}, {"Portuguese","por"}, {"Punjabi","pan"}, {"Romanian","ron"}, {"Russian","rus"},
{"Slovak","slk"}, {"Slovenian","slv"}, {"Spanish","spa"}, {"Swahili","swa"}, {"Swedish","swe"},
{"Tamil","tam"}, {"Telugu","tel"}, {"Thai","tha"}, {"Tibetan","bod"}, {"Turkish","tur"},
{"Ukrainian","ukr"}, {"Urdu","urd"}, {"Vietnamese","vie"}
};
}
}

View File

@@ -1,11 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace PDFWorkflowManager

View File

@@ -1,5 +1,4 @@

namespace PDFWorkflowManager
namespace PDFWorkflowManager
{
partial class MainForm
{
@@ -32,6 +31,11 @@ namespace PDFWorkflowManager
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.newToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.loadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.quitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.settingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@@ -95,6 +99,7 @@ namespace PDFWorkflowManager
this.tabPage2 = new System.Windows.Forms.TabPage();
this.pictureBox2 = new System.Windows.Forms.PictureBox();
this.groupExport = new System.Windows.Forms.GroupBox();
this.chkMagazines = new System.Windows.Forms.CheckBox();
this.panelBanner = new System.Windows.Forms.Panel();
this.btnMakePDF = new System.Windows.Forms.Button();
this.cmbBanner = new System.Windows.Forms.ComboBox();
@@ -119,7 +124,6 @@ namespace PDFWorkflowManager
this.btnDisposePics = new System.Windows.Forms.Button();
this.btnDeleteTemp = new System.Windows.Forms.Button();
this.btnDeleteCacheWork = new System.Windows.Forms.Button();
this.chkMagazines = new System.Windows.Forms.CheckBox();
this.menuStrip1.SuspendLayout();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
@@ -156,15 +160,51 @@ namespace PDFWorkflowManager
// fileToolStripMenuItem
//
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.newToolStripMenuItem,
this.toolStripSeparator1,
this.loadToolStripMenuItem,
this.saveToolStripMenuItem,
this.toolStripSeparator2,
this.quitToolStripMenuItem});
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
this.fileToolStripMenuItem.Text = "&File";
//
// newToolStripMenuItem
//
this.newToolStripMenuItem.Name = "newToolStripMenuItem";
this.newToolStripMenuItem.Size = new System.Drawing.Size(109, 22);
this.newToolStripMenuItem.Text = "&New";
this.newToolStripMenuItem.Click += new System.EventHandler(this.newToolStripMenuItem_Click);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(106, 6);
//
// loadToolStripMenuItem
//
this.loadToolStripMenuItem.Name = "loadToolStripMenuItem";
this.loadToolStripMenuItem.Size = new System.Drawing.Size(109, 22);
this.loadToolStripMenuItem.Text = "&Load...";
this.loadToolStripMenuItem.Click += new System.EventHandler(this.loadToolStripMenuItem_Click);
//
// saveToolStripMenuItem
//
this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
this.saveToolStripMenuItem.Size = new System.Drawing.Size(109, 22);
this.saveToolStripMenuItem.Text = "&Save...";
this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click);
//
// toolStripSeparator2
//
this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(106, 6);
//
// quitToolStripMenuItem
//
this.quitToolStripMenuItem.Name = "quitToolStripMenuItem";
this.quitToolStripMenuItem.Size = new System.Drawing.Size(97, 22);
this.quitToolStripMenuItem.Size = new System.Drawing.Size(109, 22);
this.quitToolStripMenuItem.Text = "&Quit";
this.quitToolStripMenuItem.Click += new System.EventHandler(this.quitToolStripMenuItem_Click);
//
@@ -779,6 +819,16 @@ namespace PDFWorkflowManager
this.groupExport.TabStop = false;
this.groupExport.Text = "Exporting";
//
// chkMagazines
//
this.chkMagazines.AutoSize = true;
this.chkMagazines.Location = new System.Drawing.Point(7, 22);
this.chkMagazines.Name = "chkMagazines";
this.chkMagazines.Size = new System.Drawing.Size(72, 17);
this.chkMagazines.TabIndex = 56;
this.chkMagazines.Text = "Magazine";
this.chkMagazines.UseVisualStyleBackColor = true;
//
// panelBanner
//
this.panelBanner.Controls.Add(this.btnMakePDF);
@@ -944,6 +994,7 @@ namespace PDFWorkflowManager
this.txtProjectDir.Name = "txtProjectDir";
this.txtProjectDir.Size = new System.Drawing.Size(280, 20);
this.txtProjectDir.TabIndex = 50;
this.txtProjectDir.Leave += new System.EventHandler(this.txtProjectDir_Leave);
//
// watcherOut
//
@@ -1030,16 +1081,6 @@ namespace PDFWorkflowManager
this.btnDeleteCacheWork.UseVisualStyleBackColor = true;
this.btnDeleteCacheWork.Click += new System.EventHandler(this.btnDeleteCacheWork_Click);
//
// chkMagazines
//
this.chkMagazines.AutoSize = true;
this.chkMagazines.Location = new System.Drawing.Point(7, 22);
this.chkMagazines.Name = "chkMagazines";
this.chkMagazines.Size = new System.Drawing.Size(72, 17);
this.chkMagazines.TabIndex = 56;
this.chkMagazines.Text = "Magazine";
this.chkMagazines.UseVisualStyleBackColor = true;
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -1187,6 +1228,11 @@ namespace PDFWorkflowManager
private System.Windows.Forms.Button btnDeleteTemp;
private System.Windows.Forms.Button btnDeleteCacheWork;
private System.Windows.Forms.CheckBox chkMagazines;
private System.Windows.Forms.ToolStripMenuItem loadToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
private System.Windows.Forms.ToolStripMenuItem newToolStripMenuItem;
}
}

View File

@@ -7,6 +7,7 @@ using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Security.Cryptography;
using System.Threading;
using System.Threading.Tasks;
@@ -240,7 +241,7 @@ namespace PDFWorkflowManager
btnMakePDF.Enabled = true;
//public string txtPostProcessor.text = "";
}
}
private void btnProjectDir_Click(object sender, EventArgs e)
@@ -267,12 +268,28 @@ namespace PDFWorkflowManager
{
pictureBox1.Image.Dispose();
pictureBox1.Image = null;
pictureBox1.Invalidate();
}
else
{
pictureBox1.Image = null;
pictureBox1.Invalidate();
}
if (pictureBox2.Image != null)
{
pictureBox2.Image.Dispose();
pictureBox2.Image = null;
pictureBox2.Invalidate();
}
else
{
pictureBox2.Image = null;
pictureBox2.Invalidate();
}
GC.Collect();
GC.WaitForPendingFinalizers();
}
catch
{ }
@@ -280,6 +297,15 @@ namespace PDFWorkflowManager
checkSimplex.Enabled = true;
}
check_input_dir();
}
// Check input dir for origs dir and files
private void check_input_dir()
{
Cursor.Current = Cursors.WaitCursor;
if (!Directory.Exists(Path.Combine(txtProjectDir.Text, Properties.Settings.Default.OrigsDir)))
{
@@ -294,22 +320,21 @@ namespace PDFWorkflowManager
return;
}
if (Directory.Exists(Path.Combine(txtProjectDir.Text, origsDir)) && !Directory.Exists(Path.Combine(txtProjectDir.Text, Properties.Settings.Default.WorkDir)))
if (Directory.Exists(Path.Combine(txtProjectDir.Text, Properties.Settings.Default.OrigsDir)) && !Directory.Exists(Path.Combine(txtProjectDir.Text, Properties.Settings.Default.WorkDir)))
{
// Replace the selected code block with this version
try
{
string[] strOrigFiles = Directory.GetFiles(Path.Combine(txtProjectDir.Text, Properties.Settings.Default.OrigsDir), "*.tif*");
if (File.Exists(strOrigFiles[0]))
{
byte[] imageBytes = File.ReadAllBytes(strOrigFiles[0]);
using (MemoryStream memoryStream = new MemoryStream(imageBytes))
using (var memoryStream = new MemoryStream(File.ReadAllBytes(strOrigFiles[0])))
using (var bitmap = new Bitmap(memoryStream))
{
using (Bitmap bitmap = new Bitmap(memoryStream))
{
pictureBox1.Image = new Bitmap(bitmap);
}
// Create a copy of the bitmap to ensure the file is released
pictureBox1.Image = new Bitmap(bitmap);
}
// At this point, the file is fully released
}
}
catch
@@ -322,43 +347,49 @@ namespace PDFWorkflowManager
btnCopyPathWorkDir.Enabled = true;
btnConvertToPDF.Enabled = true;
// Replace the selected code block with this version
try
{
string[] strWorkFiles = Directory.GetFiles(Path.Combine(txtProjectDir.Text, Properties.Settings.Default.WorkDir), "*.tif");
byte[] imageBytes = File.ReadAllBytes(strWorkFiles[0]);
using (MemoryStream memoryStream = new MemoryStream(imageBytes))
if (strWorkFiles.Length > 0)
{
using (Bitmap bitmap = new Bitmap(memoryStream))
using (var memoryStream = new MemoryStream(File.ReadAllBytes(strWorkFiles[0])))
using (var bitmap = new Bitmap(memoryStream))
{
pictureBox1.Image = new Bitmap(bitmap);
}
// Release file handle so tempCopyPath is writeable
GC.Collect();
GC.WaitForPendingFinalizers();
}
}
catch
{
}
if (Directory.Exists(Path.Combine(txtProjectDir.Text, Properties.Settings.Default.WorkOutDir)))
{
try
{
string[] strOutFiles = Directory.GetFiles(Path.Combine(txtProjectDir.Text, Properties.Settings.Default.WorkOutDir), "*.tif");
byte[] imageBytes = File.ReadAllBytes(strOutFiles[0]);
using (MemoryStream memoryStream = new MemoryStream(imageBytes))
if (strOutFiles.Length > 0)
{
using (Bitmap bitmap = new Bitmap(memoryStream))
string tempCopyPath = Path.Combine(tempDir, "preview_out.tif");
File.Copy(strOutFiles[0], tempCopyPath, true);
using (var memoryStream = new MemoryStream(File.ReadAllBytes(tempCopyPath)))
using (var bitmap = new Bitmap(memoryStream))
{
pictureBox2.Image = new Bitmap(bitmap);
}
// Release file handle so tempCopyPath is writeable
GC.Collect();
GC.WaitForPendingFinalizers();
File.Delete(tempCopyPath);
}
}
catch
{
}
}
}
@@ -410,6 +441,8 @@ namespace PDFWorkflowManager
catch
{
}
Cursor.Current = Cursors.Default;
}
@@ -675,7 +708,7 @@ namespace PDFWorkflowManager
toolStripProgressBar1.Value = 0;
toolStripStatusLabel1.Text = "Converting files to pdf.";
Task convertpdf = Task.Run(() =>
Task convertpdf = Task.Run(() =>
{
Parallel.ForEach(strFiles, inputFile =>
{
@@ -866,9 +899,11 @@ namespace PDFWorkflowManager
btnMakePDF.Enabled = true;
toolStripStatusLabel1.Text = "Converting files to pdf. Done!";
strExtension = "tif"; // reset to tiff extension
}
catch
{
strExtension = "tif"; // reset to tiff extension
MessageBox.Show("No supported files in Work\\out directory!", "No supported files found!", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
@@ -929,7 +964,7 @@ namespace PDFWorkflowManager
// TODO make this configurable
startInfo.FileName = Properties.Settings.Default.PDFtk;
startInfo.Arguments = "\"" + Path.Combine(outputDir, "*.pdf") + "\" " + bannerPage + " cat output " + "\"" + tempFile + "\"";
startInfo.Arguments = "\"" + Path.Combine(outputDir, "*.pdf") + "\" " + bannerPage + " cat output " + "\"" + tempFile + "\"";
using (var process = Process.Start(startInfo))
{
process.WaitForExit();
@@ -1005,7 +1040,7 @@ namespace PDFWorkflowManager
string dateTimeNow = DateTime.Now.ToString("yyyyMMddHHmmss");
string pdfMetaData = $"[ /Title ({txtTitle.Text})\r\n";
pdfMetaData += $" /Author ("+ txtPDFAuthor.Text + ")\r\n";
pdfMetaData += $" /Author (" + txtPDFAuthor.Text + ")\r\n";
pdfMetaData += $" /Subject ({txtType.Text})\r\n";
pdfMetaData += $" /Keywords ({txtPDFKeywords.Text})\r\n";
pdfMetaData += $" /ModDate (D:{dateTimeNow})\r\n";
@@ -1029,7 +1064,7 @@ namespace PDFWorkflowManager
string[] origFiles = Directory.GetFiles(origsDir, "*.tif");
int count = origFiles.Length;
var startOrig = new FileInfo(origFiles[0]);
var endOrig = new FileInfo(origFiles[count-1]);
var endOrig = new FileInfo(origFiles[count - 1]);
string startTimeFile = startOrig.LastWriteTime.ToString();
string endTimeFile = endOrig.LastWriteTime.ToString();
@@ -1072,15 +1107,22 @@ namespace PDFWorkflowManager
fileName += title;
var selectedItem = (dynamic)cmbLanguage.SelectedItem;
var selectedValue = selectedItem.Value;
if (selectedValue != "eng")
if (selectedItem != null)
{
fileName += "_(" + languageCodes[cmbLanguage.Text] + ")" + $"[{cmbResolution.SelectedItem}dpi][ocr]";
var selectedValue = selectedItem.Value;
if (selectedValue != "eng")
{
fileName += "_(" + languageCodes[cmbLanguage.Text] + ")" + $"[{cmbResolution.SelectedItem}dpi][ocr]";
}
else
{
fileName += $"_[{cmbResolution.SelectedItem}dpi][ocr]";
}
}
else
{
fileName += $"_[{cmbResolution.SelectedItem}dpi][ocr]";
cmbLanguage.SelectedIndex = cmbLanguage.FindStringExact("English");
}
txtFileName.Text = fileName;
@@ -1132,10 +1174,10 @@ namespace PDFWorkflowManager
string strOcrText = "";
//if (Directory.GetFiles(workOutDir, "*.tif").Length == txtFiles.Length)
//{
foreach (string ocrFile in txtFiles)
{
strOcrText += File.ReadAllText(ocrFile) + "\r\n\r\n\r\n";
}
foreach (string ocrFile in txtFiles)
{
strOcrText += File.ReadAllText(ocrFile) + "\r\n\r\n\r\n";
}
//}
File.WriteAllText(Path.Combine(txtProjectDir.Text, txtFileName.Text + ".ocr.txt"), strOcrText);
}
@@ -1166,6 +1208,8 @@ namespace PDFWorkflowManager
bannerPage = "";
}
private void radioSortNormal_CheckedChanged(object sender, EventArgs e)
{
//sortNormal = true;
@@ -1294,13 +1338,22 @@ namespace PDFWorkflowManager
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("PDF Workflow Manager v0.9.3 \r\n\r\nCopyright (c) 2023-2024 https://retro-commodore.eu", "Version", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
var assembly = Assembly.GetExecutingAssembly();
var version = assembly.GetName().Version.ToString();
private void button1_Click(object sender, EventArgs e)
{
//GalleryForm sf = new GalleryForm(workOutDir);
//sf.ShowDialog();
var copyrightAttr = assembly
.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false)
.OfType<AssemblyCopyrightAttribute>()
.FirstOrDefault();
var copyright = copyrightAttr?.Copyright ?? "Copyright info not found";
MessageBox.Show(
$"PDF Workflow Manager v{version}\r\n\r\n{copyright}",
"Version",
MessageBoxButtons.OK,
MessageBoxIcon.Information
);
}
@@ -1352,5 +1405,188 @@ namespace PDFWorkflowManager
}
}
}
private void txtProjectDir_Leave(object sender, EventArgs e)
{
// Use OrigsDir from settings instead of txtOrigsDir
if (Directory.Exists(Path.Combine(txtProjectDir.Text, Properties.Settings.Default.OrigsDir)))
{
check_input_dir();
}
}
private void loadToolStripMenuItem_Click(object sender, EventArgs e)
{
using (OpenFileDialog openFileDialog = new OpenFileDialog())
{
openFileDialog.Filter = "PDF Project Files (*.pdfproj)|*.pdfproj|All Files (*.*)|*.*";
openFileDialog.Title = "Open PDF Project File";
openFileDialog.Multiselect = false;
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
string selectedFile = openFileDialog.FileName;
var lines = File.ReadAllLines(selectedFile);
var dict = new Dictionary<string, string>();
foreach (var line in lines)
{
var parts = line.Split(new[] { '=' }, 2);
if (parts.Length == 2)
dict[parts[0]] = parts[1];
}
txtFileName.Text = dict.ContainsKey("FileName") ? dict["FileName"] : "";
txtTitle.Text = dict.ContainsKey("Title") ? dict["Title"] : "";
cmbLanguage.SelectedIndex = cmbLanguage.FindStringExact(dict.ContainsKey("Language") ? dict["Language"] : "");
txtLanguages.Text = dict.ContainsKey("Languages") ? dict["Languages"] : "";
txtType.Text = dict.ContainsKey("Type") ? dict["Type"] : "";
txtPublisher.Text = dict.ContainsKey("Publisher") ? dict["Publisher"] : "";
txtAuthor.Text = dict.ContainsKey("Author") ? dict["Author"] : "";
txtISBN.Text = dict.ContainsKey("ISBN") ? dict["ISBN"] : "";
txtDate.Text = dict.ContainsKey("Date") ? dict["Date"] : "";
txtPageCount.Text = dict.ContainsKey("PageCount") ? dict["PageCount"] : "";
cmbResolution.SelectedIndex = cmbResolution.FindStringExact(dict.ContainsKey("Resolution") ? dict["Resolution"] : "");
checkPhotocopy.Checked = dict.ContainsKey("Photocopy") ? dict["Photocopy"] == "True" : false;
checkReplace.Checked = dict.ContainsKey("Replace") ? dict["Replace"] == "True" : false;
txtPartnumber.Text = dict.ContainsKey("Partnumber") ? dict["Partnumber"] : "";
if (int.TryParse(dict.ContainsKey("Quality") ? dict["Quality"] : "4", out int quality))
trackBar1.Value = Math.Max(trackBar1.Minimum, Math.Min(trackBar1.Maximum, quality));
txtContributor.Text = dict.ContainsKey("Contributor") ? dict["Contributor"] : "";
txtContributorURL.Text = dict.ContainsKey("ContributorURL") ? dict["ContributorURL"] : "";
txtPostProcessor.Text = dict.ContainsKey("PostProcessor") ? dict["PostProcessor"] : "";
txtTimeSpent.Text = dict.ContainsKey("TimeSpent") ? dict["TimeSpent"] : "";
txtPDFAuthor.Text = dict.ContainsKey("PDFMetaAuthor") ? dict["PDFMetaAuthor"] : "";
txtPDFKeywords.Text = dict.ContainsKey("PDFKeywords") ? dict["PDFKeywords"] : "";
cmbBanner.SelectedIndex = cmbBanner.FindStringExact(dict.ContainsKey("Banner") ? dict["Banner"] : "");
chkMagazines.Checked = dict.ContainsKey("Magazine") ? dict["Magazine"] == "True" : false;
checkSimplex.Checked = dict.ContainsKey("Simplex") ? dict["Simplex"] == "True" : false;
txtProjectDir.Text = dict.ContainsKey("ProjectDir") ? dict["ProjectDir"] : "";
MessageBox.Show("Loaded file: " + selectedFile, "File Loaded", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
{
using (SaveFileDialog saveFileDialog = new SaveFileDialog())
{
saveFileDialog.Filter = "PDF Project Files (*.pdfproj)|*.pdfproj|All Files (*.*)|*.*";
saveFileDialog.Title = "Save PDF Project File";
saveFileDialog.DefaultExt = "pdfproj";
saveFileDialog.AddExtension = true;
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
string selectedFile = saveFileDialog.FileName;
// Collect all form data
var lines = new List<string>
{
"FileName=" + txtFileName.Text,
"Title=" + txtTitle.Text,
"Language=" + cmbLanguage.Text,
"Languages=" + txtLanguages.Text,
"Type=" + txtType.Text,
"Publisher=" + txtPublisher.Text,
"Author=" + txtAuthor.Text,
"ISBN=" + txtISBN.Text,
"Date=" + txtDate.Text,
"PageCount=" + txtPageCount.Text,
"Resolution=" + cmbResolution.Text,
"Photocopy=" + checkPhotocopy.Checked,
"Replace=" + checkReplace.Checked,
"Partnumber=" + txtPartnumber.Text,
"Quality=" + trackBar1.Value,
"Contributor=" + txtContributor.Text,
"ContributorURL=" + txtContributorURL.Text,
"PostProcessor=" + txtPostProcessor.Text,
"TimeSpent=" + txtTimeSpent.Text,
"PDFMetaAuthor=" + txtPDFAuthor.Text,
"PDFKeywords=" + txtPDFKeywords.Text,
"Banner=" + cmbBanner.Text,
"Magazine=" + chkMagazines.Checked,
"Simplex=" + checkSimplex.Checked,
"ProjectDir=" + txtProjectDir.Text
};
File.WriteAllLines(selectedFile, lines);
MessageBox.Show("Saved file: " + selectedFile, "File Saved", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
private void newToolStripMenuItem_Click(object sender, EventArgs e)
{
// Reset all input fields to default values
txtFileName.Text = "";
txtTitle.Text = "";
cmbLanguage.SelectedIndex = cmbLanguage.FindStringExact("English");
txtLanguages.Text = "";
txtType.Text = "";
txtPublisher.Text = "";
txtAuthor.Text = "";
txtISBN.Text = "";
txtDate.Text = "";
txtPageCount.Text = "";
cmbResolution.SelectedIndex = cmbResolution.FindStringExact("600");
checkPhotocopy.Checked = false;
checkReplace.Checked = false;
txtPartnumber.Text = "";
trackBar1.Value = 4;
txtContributor.Text = "";
txtContributorURL.Text = "";
txtPostProcessor.Text = strPostProcessor;
txtTimeSpent.Text = "";
txtPDFAuthor.Text = Properties.Settings.Default.PDFMetaAuthor;
txtPDFKeywords.Text = "";
cmbBanner.SelectedIndex = Properties.Settings.Default.Banner;
chkMagazines.Checked = false;
checkSimplex.Checked = false;
txtProjectDir.Text = "";
// Clear up pictures
try
{
if (pictureBox1.Image != null)
{
pictureBox1.Image.Dispose();
pictureBox1.Image = null;
}
if (pictureBox2.Image != null)
{
pictureBox2.Image.Dispose();
pictureBox2.Image = null;
}
}
catch
{ }
// Optionally reset status bar and progress bar
toolStripStatusLabel1.Text = "";
toolStripProgressBar1.Value = 0;
}
private void HandleWorkOutDirFileEvent()
{
try
{
string[] strOutFiles = Directory.GetFiles(workOutDir, "*.tif");
if (strOutFiles.Length > 0)
{
using (var memoryStream = new MemoryStream(File.ReadAllBytes(strOutFiles[0])))
using (var bitmap = new Bitmap(memoryStream))
{
pictureBox2.Image = new Bitmap(bitmap);
}
// Release file handle so file is writeable
GC.Collect();
GC.WaitForPendingFinalizers();
}
}
catch
{
// Optionally log or handle error
}
}
}
}

View File

@@ -0,0 +1,34 @@
using System;
using System.IO;
using System.Security.Cryptography;
namespace PDFWorkflowManager
{
public static class MetadataService
{
public static void WriteMetadata(string filePath, string contents)
{
File.WriteAllText(filePath, contents);
}
public static string GetMD5(string file)
{
using (var md5 = MD5.Create())
using (var stream = File.OpenRead(file))
{
var hash = md5.ComputeHash(stream);
return BitConverter.ToString(hash).Replace("-", "").ToLower();
}
}
public static string GetSHA1(string file)
{
using (var sha1 = SHA1.Create())
using (var stream = File.OpenRead(file))
{
var hash = sha1.ComputeHash(stream);
return BitConverter.ToString(hash).Replace("-", "").ToLower();
}
}
}
}

View File

@@ -104,6 +104,8 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ImageService.cs" />
<Compile Include="LanguageService.cs" />
<Compile Include="LanguagesForm.cs">
<SubType>Form</SubType>
</Compile>
@@ -116,6 +118,8 @@
<Compile Include="MainForm.Designer.cs">
<DependentUpon>MainForm.cs</DependentUpon>
</Compile>
<Compile Include="MetadataService.cs" />
<Compile Include="PdfService.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SettingsForm.cs">
@@ -150,6 +154,7 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="packages.config" />
<None Include="PDFWorkflowManager.csproj" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>

View File

@@ -0,0 +1,39 @@
using System.Diagnostics;
namespace PDFWorkflowManager
{
public static class PdfService
{
public static void MergePdfs(string pdfToolkitPath, string inputPattern, string bannerPage, string outputFile)
{
var startInfo = new ProcessStartInfo
{
FileName = pdfToolkitPath,
Arguments = $"\"{inputPattern}\" {bannerPage} cat output \"{outputFile}\"",
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true
};
using (var process = Process.Start(startInfo))
{
process.WaitForExit();
}
}
public static void UpdatePdfMetadata(string ghostScriptPath, string tempFile, string metadataFile, string outputFile)
{
var startInfo = new ProcessStartInfo
{
FileName = ghostScriptPath,
Arguments = $"-dBATCH -dNOPAUSE -dAutoRotatePages=/None -sDEVICE=pdfwrite -sOutputFile=\"{outputFile}\" \"{tempFile}\" \"{metadataFile}\"",
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true
};
using (var process = Process.Start(startInfo))
{
process.WaitForExit(120000);
}
}
}
}

View File

@@ -9,7 +9,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Retro Commodore")]
[assembly: AssemblyProduct("PDF Workflow Manager")]
[assembly: AssemblyCopyright("Copyright © 2023-2024 https://retro-commodore.eu")]
[assembly: AssemblyCopyright("Copyright © 2023-2025 https://retro-commodore.eu")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.9.3")]
[assembly: AssemblyFileVersion("0.9.3")]
[assembly: AssemblyVersion("0.9.4")]
[assembly: AssemblyFileVersion("0.9.4")]

View File

@@ -0,0 +1,13 @@
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:bal="http://wixtoolset.org/schemas/v4/wxs/bal">
<Bundle Id="TODO_Manufacturer.Setup" Name="Setup" Manufacturer="TODO Manufacturer" Version="1.0.0.0">
<BootstrapperApplication>
<bal:WixStandardBootstrapperApplication LicenseUrl="https://www.example.com/license" Theme="hyperlinkLicense" />
</BootstrapperApplication>
<Chain>
<!-- TODO: Define the list of chained packages. -->
<!-- <MsiPackage SourceFile="path\to\your.msi" /> -->
</Chain>
</Bundle>
</Wix>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,9 @@
<Project Sdk="WixToolset.Sdk/6.0.1">
<PropertyGroup>
<OutputType>Bundle</OutputType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="WixToolset.BootstrapperApplications.wixext" Version="6.0.1" />
</ItemGroup>
</Project>