Automated the google forms to pdf generation process. Using pdflatex command (external program).

Only the download automation has to be done. > look at FileSystemWatcher for automatically detecting downloads
This commit is contained in:
Douwe Ravers
2022-12-24 15:18:20 +01:00
parent bc576e433a
commit abf812c6e9
99 changed files with 2224 additions and 428 deletions

View File

@@ -0,0 +1,47 @@
using System.Linq;
namespace Proostenkrant.NET
{
internal static class ArticleGenerator
{
internal static string GenerateArticle(string[][] rows)
{
var text = string.Empty;
foreach (var row in rows)
{
var writers = row[1].Split(',').Select(w => w.Trim()).ToArray();
var title = row[2];
var date = row[3];
var mainText = row[4];
var imageName = row[5];
text += GenerateHeader(writers[0], title, date);
text += GenerateBody(writers, date, mainText, imageName);
text += "\n\n";
}
return text;
}
static string GenerateHeader(string writer, string title, string date)
{
var text = string.Empty;
text += "\\headline{" + title + "}\r\n";
text += "\\byline{" + date + "}{" + writer + "}\r\n";
return text;
}
static string GenerateBody(string[] writers, string date, string mainText, string imageName)
{
var text = string.Empty;
if (writers.Length == 2)
text += "\\showTwoWriters{Images/ProfilePictures/" + writers[0] + ".jpg}{" + writers[0] + "}{Images/ProfilePictures/" + writers[1] + ".jpg}{" + writers[1] + "}\r\n";
else
text += "\\showOneWriter{Images/ProfilePictures/" + writers[0] + ".jpg}{" + writers[0] + "}\r\n";
text += "\\par " + mainText + "\r\n";
text += "\\showInlineImage{Images/Articles/" + imageName + ".jpg}{" + imageName + "}\r\n";
return text;
}
}
}