我正在嘗試將自定義屬性/元資料添加到 PDF 2.0 檔案(如這個customprop)。我使用過 PDFSharp、ITextSharp 和 PDFBox,但我不能。有沒有免費的包可以解決這個問題。
示例 pdf 2.0 的鏈接
uj5u.com熱心網友回復:
你試過 SpirePDF 嗎?您可以嘗試一個免費的 Nuget,使用該代碼段對我來說效果很好:
using Spire.Pdf;
namespace App
{
class Program
{
static void Main(string[] args)
{
PdfDocument doc = new PdfDocument();
doc.LoadFromFile(@"C:\Users\User\Downloads\output.pdf");
doc.DocumentInformation.SetCustomProperty("Name", "Test");
doc.DocumentInformation.SetCustomProperty("Company", "StackOverflow");
doc.SaveToFile(@"C:\Users\User\Downloads\result.pdf");
}
}
}
uj5u.com熱心網友回復:
您可以使用Docotic.Pdf 庫添加自定義元資料,如下所示:
// NOTE:
// When used in trial mode, the library imposes some restrictions.
// Please visit http://bitmiracle.com/pdf-library/trial-restrictions.aspx for more information.
BitMiracle.Docotic.LicenseManager.AddLicenseData("temporary or permanent license key here");
using (var pdf = new PdfDocument("Simple_pdf_2.0_file.pdf"))
{
pdf.Metadata.Custom.Properties.Add("CustomKey", "CustomValue");
pdf.Save("SetCustomXmpProperties.pdf");
}
這是更全面的示例:https : //github.com/BitMiracle/Docotic.Pdf.Samples/tree/master/Samples/Metadata/SetCustomXmpProperties
免責宣告:我是 Docotic.Pdf 庫的合著者。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/402422.html
標籤:
