Add Pdf.UpdateMetadata

This commit is contained in:
2023-03-07 23:21:21 +01:00
parent 6326917c95
commit 394f6332de
5 changed files with 16 additions and 5 deletions

View File

@ -7,9 +7,9 @@ using System.Threading.Tasks;
using System.Windows;
namespace WGneu {
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application {
public App() : base() {
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
}
}
}

View File

@ -6,6 +6,7 @@ using System.Linq;
using System.Reflection.Metadata.Ecma335;
using System.Text;
using System.Threading.Tasks;
using PdfSharp.Pdf.IO;
using PuppeteerSharp;
using PuppeteerSharp.Media;
using WGneu.Windows;
@ -47,6 +48,13 @@ namespace WGneu.Documents {
});
}
public static void UpdateMetadata(string path, string title, string author) {
using var doc = PdfReader.Open(path);
doc.Info.Title = title;
doc.Info.Author = author;
doc.Save(path);
}
public static void Display(string title, string path) {
var w = new DocumentViewerWindow(title, path);
w.Show();

View File

@ -11,10 +11,11 @@ using WGneu.Models;
namespace WGneu.Documents {
class Template {
private static readonly string ROOT = @"C:\Users\tom\Projects\wgneu\";
private static readonly string ROOT = @"C:\Users\lorenz\Desktop\";
public static async void Test() {
await Pdf.Convert(ROOT + "din-5008.html", ROOT + "test.pdf");
Pdf.UpdateMetadata(ROOT + "test.pdf", "Test Dokument", "Winzergenossenschaft für Matzen und Umgebung reg. Gen.m.b.H.");
Pdf.Display("Test-Dokument", ROOT + "test.pdf");
}

View File

@ -16,8 +16,10 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.3" />
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.1587.40" />
<PackageReference Include="ModernWpfUI" Version="0.9.6" />
<PackageReference Include="PdfSharp" Version="1.50.5147" />
<PackageReference Include="PuppeteerSharp" Version="9.0.2" />
<PackageReference Include="RazorLight" Version="2.3.1" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="7.0.0" />
</ItemGroup>
</Project>

View File

@ -7,7 +7,7 @@
xmlns:local="clr-namespace:WGneu.Windows"
mc:Ignorable="d"
Title="PDF Ansicht"
MinHeight="600" MinWidth="420" Height="970" Width="670">
MinHeight="600" MinWidth="420" Height="750" Width="525">
<Grid>
<wv2:WebView2 Name="WebView"/>
</Grid>