在 Ruby 中删除 PDF 的元数据

Aspose.PDF - 删除元数据

要使用 Aspose.PDF Java for Ruby 从 Pdf 文档中删除元数据,只需调用 RemoveMetadata 模块。

Ruby 代码

# The path to the documents directory.

data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'

# Open a pdf document.

doc = Rjb::import('com.aspose.pdf.Document').new(data_dir + "input1.pdf")

if doc.getMetadata().contains("pdfaid:part")

В В В  doc.getMetadata().removeItem("pdfaid:part")

endВ В  В

if doc.getMetadata().contains("dc:format")

В В В  doc.getMetadata().removeItem("dc:format")

end

# save update document with new information

doc.save(data_dir + "Remove_Metadata.pdf")

puts "Removed metadata successfully, please check output file."

下载运行代码

下载 删除元数据 (Aspose.PDF) 来自以下任何提到的社交编码站点: