既存の PDF ファイルがスキャンされた画像であるか、iTextSharp と C# を使用してデータ ファイルから作成されているかを確認する方法はありますか?
2773 次
3 に答える
0
iTextSharp で作成した PDF にメタデータを追加できるかもしれません。
于 2012-11-16T23:32:40.903 に答える
-1
ドキュメント プロパティ/詳細設定/PDF プロデューサー
于 2012-11-16T23:28:23.520 に答える
-1
PdfWriter オブジェクトのウォッチ ウィンドウで適切な場所を検索した後、PDF プロデューサーを置き換えるためにこのメソッドを作成しました。デフォルトではアクセスできないため、PDF の「PDF クリエーター」が変更されます。
private static void ReplacePdfCreator(PdfWriter writer)
{
/*
Warning
*
This is not an option offered as is and i had to workaround it by using Reflection and change it
manually.
*
Alejandro
*/
Type writerType = writer.GetType();
PropertyInfo writerProperty =
writerType.GetProperties(BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance)
.FirstOrDefault(p => p.PropertyType == typeof(PdfDocument));
if (writerProperty != null)
{
PdfDocument pd = (PdfDocument)writerProperty.GetValue(writer);
Type pdType = pd.GetType();
FieldInfo infoProperty =
pdType.GetFields(BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance)
.FirstOrDefault(p => p.Name == "info");
if (infoProperty != null)
{
PdfDocument.PdfInfo pdfInfo = (PdfDocument.PdfInfo)infoProperty.GetValue(pd);
if (pdfInfo != null)
{
string creator = pdfInfo.GetAsString(new PdfName("Producer")).ToLowerInvariant();
if(creator.Contains("itextsharp"))
{
// created with itext sharp
}
else if(creator.Contains("adobe"))
{
// created with adobe something (distiller, photoshop, whatever)
}
else if(creator.Contains("pdfpro"))
{
// created with pdf pro
}
else if(add your own comparison here, for example a scanner manufacturer software like HP's one)
{
}
}
}
}
}
于 2013-08-16T11:23:08.947 に答える