0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【PDF文法・仕様】Highlight AnnotationのRectとQuadPoints

Posted at

PDFのHighlight Annotationのうち、RectQuadPointsについてリバースエンジニアリングを試みます。

材料

OS

Microsoft Windows 11 Home
Version 10.0.26100 Build 26100

Chrome

Version 133.0.6943.142 (Official Build) (64-bit)

Adobe Acrobat

Continuous Release | 2024.005.20421 | 64 bit

使用するPDFサンプル

Highlight Annotationを使用したミニマルサンプル(不完全データ)

test.pdf
%PDF-1.7

1 0 obj  % entry point
<<
  /Type /Catalog
  /Pages 2 0 R
>>
endobj

2 0 obj
<<
  /Type /Pages
  /MediaBox [ 0 0 200 400 ]
  /Count 1
  /Kids [ 3 0 R ]
>>
endobj

3 0 obj
<<
  /Type /Page
  /Parent 2 0 R
  /Resources <<
    /Font <<
      /F1 4 0 R 
    >>
  >>
  /Contents 5 0 R
  /Annots [6 0 R]
>>
endobj

4 0 obj
<<
  /Type /Font
  /Subtype /Type1
  /BaseFont /Times-Roman
>>
endobj

5 0 obj  % page content
<<
  /Length 44
>>
stream
BT
70 50 TD
/F1 12 Tf
(Hello, world!) Tj
ET
endstream
endobj

6 0 obj
<<
  /Type /Annot 
  /Rect [0 0 100 100 ] 
  /Subtype /Highlight 
  /QuadPoints [69.9398 58.8418 96.5932 58.8418 69.9398 47.3526 96.5932 47.3526 ] 
  /M (D:20190101153417)  
  /Contents (aaa)  
  /F 4 
  /C [1 1 0 ] 
  /CA 1 
  /Border [0 0 1 ] 
  /P 3 0 R 
>>
endobj

xref
trailer
<<
  /Size 6
  /Root 1 0 R
>>

startxref

%%EOF

これに対して、pdftkを使用して、完璧にします。(クロスリファレンス他)

pdftk使用コマンドライン

pdftk test.pdf output test_out.pdf

この状態でのChromeの見え方はこう。
image.png

Acrobatでの見え方はこう。
image.png

Rect

Rectをいじったところ、結論としてはハイライトの変更はない。Chromeにおいて、カーソルオーバーしたときのコメント表示の位置が変動した。

一方、AcrobatのコメントはRectではなくカーソル位置に依存(大きさは不変)
image.png

Chromeでの挙動

/Rect [0 0 100 100 ] 

image.png

/Rect [50 0 100 100 ] 

image.png

/Rect [0 50 100 100 ] 

image.png

/Rect [0 0 50 100 ] 

image.png

/Rect [0 0 100 50 ] 

image.png

image.png

/Rect [1 1 100 100 ] 

image.png

...法則性が分からないですな。

QuadPoint

QuadPointsの順番は、仕様書と異なって、下記が実態になっている
image.png

参考: https://stackoverflow.com/questions/9855814/pdf-spec-vs-acrobat-creation-quadpoints

台形

/QuadPoints [0 58.8418 96.5932 58.8418 69.9398 47.3526 96.5932 47.3526 ] 

Chrome
image.png

Acrobat
image.png

伸ばす

/QuadPoints [0 58.8418 96.5932 58.8418 0 47.3526 96.5932 47.3526 ] 

Chrome
image.png

Acrobat
image.png

蝶つがい

 /QuadPoints [69.9398 0 96.5932 58.8418 69.9398 47.3526 96.5932 47.3526 ] 

Chrome
image.png

Acrobat
image.png

うらがえs

/QuadPoints [69.9398 0 96.5932 0 69.9398 47.3526 96.5932 47.3526 ]

Chrome
image.png

Acrobat
image.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?