为什么此 PDF 元数据无效?

Why is this PDF metadata not valid?

我需要帮助了解如何使此文档合规。 任何其他建议都会很棒。

我一直在挖掘各种示例、教程和官方文档;我想我已经接近解决方案了。

"hello world" 文本出现在 MediaBox 中,但无法访问元数据。

规则看起来很清楚,但是 pdfinfo 或文件 > 属性不会出现标题之类的东西。

%PDF-1.1
¥±˫

% Metadata (referenced by trailer /Info)
0 0 obj
  /Title        (simple 80x25 text PDF)
  /Subject      (test PDF)
  /Producer     (simple.80x25.text.PDF.py)
  /Creator      (gvim)
  /Keywords     (PDF test)
  /CreationDate (D:2018021300000-05'00')
endobj

% Content (referenced by trailer /Root)
1 0 obj
  <<
    /Type /Catalog /Pages 2 0 R
  >>
endobj

% Text display box (referenced by 1 0 obj)
2 0 obj
  << /Type /Pages /Kids [3 0 R] /Count 1 /MediaBox [0 0 480 300] >>
endobj

% Text font (referenced by 2 0 obj)
3 0 obj
  << /Type /Page /Parent 2 0 R /Resources
    << /Font
      << /F1
        << /Type /Font /Subtype /Type1 /BaseFont /Courier >>
      >>
    >>
    /Contents 4 0 R
  >>
endobj

% Text to be displayed in the box (referenced by 3 0 obj)
4 0 obj
  << /Length 5 0 R >>
stream
  BT
    /F1 10 Tf 12 TL 0 290 Td
    (hello world) Tj
  ET
endstream
endobj

% Main (collect resources for reference from entrypoint)
trailer
  << /Root 1 0 R /Info 0 0 R /Size 6 >>

startxref 0
%%EOF

从 1 开始获取文档信息并将键放入字典对象中,您的示例缺少 << 和 >>:

% Metadata (referenced by trailer /Info)

1 0 obj
<<
  /Title        (simple 80x25 text PDF)
  /Subject      (test PDF)
  /Producer     (simple.80x25.text.PDF.py)
  /Creator      (gvim)
  /Keywords     (PDF test)
  /CreationDate (D:2018021300000-05'00')
>>
endobj