-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_annotation_save.cs
More file actions
68 lines (60 loc) · 2.34 KB
/
Copy pathtest_annotation_save.cs
File metadata and controls
68 lines (60 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using Caelum.Models;
using Caelum.Services;
using System;
using System.Collections.Generic;
using System.IO;
namespace TestAnnotationSave
{
class Program
{
static async Task Main(string[] args)
{
try
{
// Create a test PDF
string tempDir = Path.Combine(Path.GetTempPath(), "CaelumTest");
Directory.CreateDirectory(tempDir);
string filePath = Path.Combine(tempDir, "test.pdf");
// Create a blank PDF
await PdfService.CreateBlankPdfAsync(filePath);
Console.WriteLine("Created test PDF file");
// Create annotations to save
var annotations = new Dictionary<int, PageAnnotation>();
var pageAnnots = new PageAnnotation();
// Add a text annotation
pageAnnots.Texts.Add(new TextAnnotation
{
Text = "Test annotation",
X = 100,
Y = 100,
FontSize = 12,
R = 0,
G = 0,
B = 0
});
annotations[0] = pageAnnots;
Console.WriteLine("Created test annotations");
// Save annotations - this should not throw an exception
var service = new PdfService();
await service.SaveAnnotationsToPdfAsync(filePath, annotations);
Console.WriteLine("Successfully saved annotations!");
// Verify the file exists and has content
if (File.Exists(filePath))
{
var fileInfo = new FileInfo(filePath);
Console.WriteLine($"PDF file saved successfully. Size: {fileInfo.Length} bytes");
}
else
{
Console.WriteLine("ERROR: PDF file was not saved");
}
Console.WriteLine("Test completed successfully!");
}
catch (Exception ex)
{
Console.WriteLine($"ERROR: {ex.GetType().Name}: {ex.Message}");
Console.WriteLine(ex.StackTrace);
}
}
}
}