SlideCombine/MetadataModel.cs
yuuko e2c894f229 实现完整的元数据格式支持
- 添加MetadataModel.cs支持完整的元数据字段
- 更新FileMerger.cs从TXT文件读取元数据,从bkmk文件读取目录
- 支持所有元数据字段:title, Other titles, Volume, ISBN, creator等
- 修正书签连接符为14个短横线(---------------)
- 添加UTF-8/GBK编码自动检测
- 更新ContentFormatter.cs支持元数据文档合并

现在程序能够:
1. 从TXT文件读取完整的元数据信息
2. 从FreePic2Pdf_bkmk.txt文件提取书签目录
3. 按照需求格式合并输出完整内容

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-24 15:51:08 +08:00

134 lines
3.9 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
namespace SlideCombine
{
public class DocumentMetadata
{
public string Title { get; set; }
public string OtherTitles { get; set; }
public string Volume { get; set; }
public string ISBN { get; set; }
public string Creator { get; set; }
public string Contributor { get; set; }
public string IssuedDate { get; set; }
public string Publisher { get; set; }
public string Place { get; set; }
public string ClassificationNumber { get; set; }
public string Page { get; set; }
public List<BookmarkItem> TableOfContents { get; set; }
public string Subject { get; set; }
public string Date { get; set; }
public string Spatial { get; set; }
public string OtherISBN { get; set; }
public string OtherTime { get; set; }
public string Url { get; set; }
public DocumentMetadata()
{
TableOfContents = new List<BookmarkItem>();
}
public string ToFormattedString()
{
var result = new System.Text.StringBuilder();
// Title行
result.AppendLine($"title:{Title}");
// Other titles行如果有
if (!string.IsNullOrEmpty(OtherTitles))
{
result.AppendLine($"Other titles:{OtherTitles}");
}
// Volume行
result.AppendLine($"Volume:{Volume}");
// ISBN行
if (!string.IsNullOrEmpty(ISBN))
{
result.AppendLine($"ISBN:{ISBN}");
}
// Creator行
if (!string.IsNullOrEmpty(Creator))
{
result.AppendLine($"creator:{Creator}");
}
// Contributor行
if (!string.IsNullOrEmpty(Contributor))
{
result.AppendLine($"contributor:{Contributor}");
}
// IssuedDate行
result.AppendLine($"issuedDate:{IssuedDate}");
// Publisher行
result.AppendLine($"publisher:{Publisher}");
// Place行
result.AppendLine($"place:{Place}");
// Classification number行
result.AppendLine($"Classification number:{ClassificationNumber}");
// Page行
result.AppendLine($"page:{Page}");
// Table of contents
result.AppendLine("tableOfContents:");
foreach (var bookmark in TableOfContents)
{
if (!string.IsNullOrEmpty(bookmark.Title))
{
result.Append(bookmark.Title.Trim());
if (!string.IsNullOrEmpty(bookmark.Page))
{
// 注意使用14个短横线与需求示例一致
result.Append("---------------");
result.Append(bookmark.Page);
}
result.AppendLine("<br/>");
}
}
// Subject行
result.AppendLine($"subject:{Subject}");
// Date行
if (!string.IsNullOrEmpty(Date))
{
result.AppendLine($"date:{Date}");
}
// Spatial行
if (!string.IsNullOrEmpty(Spatial))
{
result.AppendLine($"spatial:{Spatial}");
}
// Other ISBN行
if (!string.IsNullOrEmpty(OtherISBN))
{
result.AppendLine($"Other ISBN:{OtherISBN}");
}
// Other time行
if (!string.IsNullOrEmpty(OtherTime))
{
result.AppendLine($"Other time:{OtherTime}");
}
// URL行
if (!string.IsNullOrEmpty(Url))
{
result.AppendLine($"url:{Url}");
}
return result.ToString();
}
}
}