RemoveMetadata Свойство (PdfDocumentCompressorCommand)
В этом разделе
Возвращает или задает значение, указывающее, должна ли команда удалять метаданные из PDF документа.
Синтаксис
Property Value
True - команда должна удалять метаданные; false - команда НЕ должна удалять метаданные.
Значение по умолчанию: false.
Пример
Вот пример, показывающий, как удалить метаданные, закладки, информацию о документе, встроенные файлы, встроенные миниатюры, интерактивную форму и дерево структуры PDF документа:
''' <summary>
''' Removes metadata, bookmarks, document information, embedded files, embedded thumbnails, interactive form and structure tree of the PDF document.
''' </summary>
''' <param name="inPdfFilename">The input PDF filename.</param>
''' <param name="outPdfFilename">The output PDF filename.</param>
Public Shared Sub RemoveObjects(inPdfFilename As String, outPdfFilename As String)
' create compressor with empty compression settings
Dim compressor As Vintasoft.Imaging.Pdf.Processing.PdfDocumentCompressorCommand = Vintasoft.Imaging.Pdf.Processing.PdfDocumentCompressorCommand.CreateEmptyCompressor()
' specify that compressor must remove metadata from PDF document
compressor.RemoveMetadata = True
' specify that compressor must remove bookmarks from PDF document
compressor.RemoveBookmarks = True
' specify that compressor must remove document information from PDF document
compressor.RemoveDocumentInformation = True
' specify that compressor must remove embedded files from PDF document
compressor.RemoveEmbeddedFiles = True
' specify that compressor must remove embedded thumbnails from PDF document
compressor.RemoveEmbeddedThumbnails = True
' specify that compressor must remove interactive form from PDF document
compressor.RemoveInteractiveForm = True
' specify that compressor must remove structure tree from PDF document
compressor.RemoveStructureTree = True
' compress PDF document
compressor.Compress(inPdfFilename, outPdfFilename)
End Sub
/// <summary>
/// Removes metadata, bookmarks, document information, embedded files, embedded thumbnails, interactive form and structure tree of the PDF document.
/// </summary>
/// <param name="inPdfFilename">The input PDF filename.</param>
/// <param name="outPdfFilename">The output PDF filename.</param>
public static void RemoveObjects(string inPdfFilename, string outPdfFilename)
{
// create compressor with empty compression settings
Vintasoft.Imaging.Pdf.Processing.PdfDocumentCompressorCommand compressor =
Vintasoft.Imaging.Pdf.Processing.PdfDocumentCompressorCommand.CreateEmptyCompressor();
// specify that compressor must remove metadata from PDF document
compressor.RemoveMetadata = true;
// specify that compressor must remove bookmarks from PDF document
compressor.RemoveBookmarks = true;
// specify that compressor must remove document information from PDF document
compressor.RemoveDocumentInformation = true;
// specify that compressor must remove embedded files from PDF document
compressor.RemoveEmbeddedFiles = true;
// specify that compressor must remove embedded thumbnails from PDF document
compressor.RemoveEmbeddedThumbnails = true;
// specify that compressor must remove interactive form from PDF document
compressor.RemoveInteractiveForm = true;
// specify that compressor must remove structure tree from PDF document
compressor.RemoveStructureTree = true;
// compress PDF document
compressor.Compress(inPdfFilename, outPdfFilename);
}
Требования
Целевые платформы: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5
Смотрите также