C#でPDFを読み込んでどうなってるか見てみた

 微妙に諦めきれないので、pdfを読み込ませてPdfDocmentクラスの中で字がどうなってるか見てみた。

f:id:pongeponge:20130416134303p:plain

Foxit J-Reader Plusでタイプライタを使い文字を書いて保存。

アノテーションの字が違うのは、保存したあとで気づいた(本当はannotation)。

これをC#で読み込んで、デバッグモードでPdfDocumentに何が入ってるか見てみる。

 

 いろんなメンバがある。

最初はdocument.Pages.PagesArray.Elements.Itemsかと思って、出力コンソールに書き出してみたらこうなった。

4 0 R

うん、意味不明。

なのでさっさとあきらめる。

次に目を付けたのはdocument.Internal.AllObjects。

23個も配列になってるから何かあるだろうと思って、同じように出力コンソールに書き出してみた。

<< /CreationDate D:20130416115220+09'00' /Creator PDFsharp 1.3.1684-g (www.pdfsharp.com) /ModDate D:20130416142909+09'00' /Producer PDFsharp 1.3.1684-g (www.pdfsharp.com) /Title Created with PDFsharp >>
<< /AcroForm 12 0 R /Pages 3 0 R /Type /Catalog >>
<< /Count 1 /Kids [ 4 0 R ] /Type /Pages >>
<< /Annots [ 5 0 R 16 0 R ] /Group << /CS /DeviceRGB /I False /K False /S /Transparency >> /MediaBox [ 0 0 595 842 ] /Parent 3 0 R /Type /Page >>
<< /AP << /N 7 0 R >> /CA 1 /Contents þÿ0B0n0f0ü0W00<< /BaseFont /Helvetica /Encoding /WinAnsiEncoding /Subtype /Type1 /Type /Font >>
<< /BBox [ -169.285 -74.677 169.285 0 ] /Filter /FlateDecode /Length 198 /Matrix [ 1 0 0 1 0 0 ] /Resources << /Font 8 0 R >> >>
<< /Helvetica_00 6 0 R /Time 10 0 R /Times 18 0 R >>
<< /BaseFont /MS-PGothic /CIDSystemInfo << /Ordering Japan1 /Registry Adobe /Supplement 5 >> /FontDescriptor 11 0 R /Subtype /CIDFontType2 /Type /Font /W [ 231 [ 305 219 500 500 500 500 594 203 305 305 500 500 203 500 203 500 500 500 500 500 500 500 500 500 500 500 203 203 500 500 500 453 668 633 637 664 648 566 551 680 641 246 543 598 539 742 641 707 617 707 625 602 590 641 633 742 602 590 566 336 504 336 414 305 414 477 496 500 496 500 305 461 500 211 219 461 211 734 500 508 496 496 348 461 352 500 477 648 461 477 457 234 234 234 ] 326 326 500 327 [ 441 441 441 441 441 547 523 445 480 469 516 523 504 438 500 641 617 566 625 598 637 563 652 539 621 523 664 590 637 645 555 527 602 602 602 461 645 598 578 648 492 637 516 547 613 641 605 453 660 508 609 664 641 520 559 512 656 566 559 590 563 250 230 ] 631 631 414 ] >>
<< /BaseFont /MS-PGothic /DescendantFonts [ 9 0 R ] /Encoding /90ms-RKSJ-H /Subtype /Type0 /Type /Font >>
<< /Ascent 859 /CapHeight 500 /Descent -137 /Flags 32 /FontBBox [ -121 -137 996 859 ] /FontName /MS-PGothic /ItalicAngle 0 /StemV 0 /Type /FontDescriptor >>
<< /DA /MS-M 0 Tf 0 g /DR << /Font << /Helv 6 0 R /MS-M 14 0 R /Time 10 0 R /Times 18 0 R >> >> >>
<< /BaseFont /MS-Mincho /CIDSystemInfo << /Ordering Japan1 /Registry Adobe /Supplement 5 >> /FontDescriptor 15 0 R /Subtype /CIDFontType2 /Type /Font /W [ 231 324 500 326 326 1000 327 389 500 631 631 500 ] >>
<< /BaseFont /MS-Mincho /DescendantFonts [ 13 0 R ] /Encoding /90ms-RKSJ-H /Subtype /Type0 /Type /Font >>
<< /Ascent 859 /CapHeight 500 /Descent -137 /Flags 35 /FontBBox [ -82 -137 996 859 ] /FontName /MS-Mincho /ItalicAngle 0 /StemV 80 /Type /FontDescriptor >>
<< /F 28 /M D:20130416115306+09'00' /NM ae4b69ab-c7e6-4f48-86e3-d6de21df1d61 /Open False /P 4 0 R /Parent 5 0 R /Rect [ 474.798 710.473 654.798 830.473 ] /Subtype /Popup /Type /Annot >>
<< /BaseFont /MS-PGothic /CIDSystemInfo << /Ordering Japan1 /Registry Adobe /Supplement 5 >> /FontDescriptor 19 0 R /Subtype /CIDFontType2 /Type /Font /W [ 231 [ 305 219 500 500 500 500 594 203 305 305 500 500 203 500 203 500 500 500 500 500 500 500 500 500 500 500 203 203 500 500 500 453 668 633 637 664 648 566 551 680 641 246 543 598 539 742 641 707 617 707 625 602 590 641 633 742 602 590 566 336 504 336 414 305 414 477 496 500 496 500 305 461 500 211 219 461 211 734 500 508 496 496 348 461 352 500 477 648 461 477 457 234 234 234 ] 326 326 500 327 [ 441 441 441 441 441 547 523 445 480 469 516 523 504 438 500 641 617 566 625 598 637 563 652 539 621 523 664 590 637 645 555 527 602 602 602 461 645 598 578 648 492 637 516 547 613 641 605 453 660 508 609 664 641 520 559 512 656 566 559 590 563 250 230 ] 631 631 414 ] >>
<< /BaseFont /MS-PGothic /DescendantFonts [ 17 0 R ] /Encoding /90ms-RKSJ-H /Subtype /Type0 /Type /Font >>
<< /Ascent 859 /CapHeight 500 /Descent -137 /Flags 32 /FontBBox [ -121 -137 996 859 ] /FontName /MS-PGothic /ItalicAngle 0 /StemV 0 /Type /FontDescriptor >>

なんじゃこりゃ、と思ったけどよく見るとフォント情報やらが入ってる。

見やすいように赤文字にした。

あと、多分Font/Wに続く3桁の数字の羅列が文字の情報だと思う。

本当かどうかは全然わからないけど。

 

とりあえずobjectどうこうしたらいいんだろうか?