#!/usr/bin/env ruby # # Rpdf2txt -- PDF to Text Parser # Copyright (C) 2003 Andreas Schrafl, Hannes Wyss, Masaomi Hatakeyama # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # ywesee - intellectual capital connected, Winterthurerstrasse 52, CH-8006 Zürich, Switzerland # zdavatz@ywesee.com, mhatakeymama@ywesee.com # # TestParser-- Rpdf2txt -- 28.11.2002 -- aschrafl@ywesee.com $: << File.expand_path('../lib', File.dirname(__FILE__)) $: << File.dirname(__FILE__) $KCODE = "UTF8" require 'test/unit' require 'rpdf2txt/parser' require 'mock' module Rpdf2txt class Parser public :page_tree_root, :build_object, :build_trailer_dictionary, :rebuild_object_catalogue attr_accessor :src, :encrypt_id end class PdfObject attr_reader :attributes, :src # attr_accessor :oid end class TrailerDictionary attr_reader :attributes end class ReferenceArray < TreeNode attr_reader :references, :contents end class PdfArray < TreeNode attr_reader :references, :contents end class PageLeaf < TreeNode public :join_snippets attr_writer :resources end class CatalogNode < TreeNode attr_accessor :pages end end class FontDonorStub attr_reader :attributes def initialize(fonts) @fonts = fonts @attributes = {} end def font(font_name) @fonts[font_name] end end class TestParser < Test::Unit::TestCase class RootDonorStub def root_id end end def setup file = File.expand_path('./data/page_tree.pdf', File.dirname(__FILE__)) input = File.read(file) @parser = Rpdf2txt::Parser.new(input) end def test_object_catalogue cat= @parser.object_catalogue assert_equal(Hash, cat.class) assert_equal(16, cat.size) assert_equal(Rpdf2txt::CatalogNode, cat[1].class) assert_equal(Rpdf2txt::PageNode, cat[2].class) assert_equal(Rpdf2txt::PageLeaf, cat[3].class) assert_equal(Rpdf2txt::PageNode, cat[4].class) assert_equal(Rpdf2txt::PageNode, cat[5].class) assert_equal(Rpdf2txt::Stream, cat[6].class) assert_equal(Rpdf2txt::PageNode, cat[7].class) assert_equal(Rpdf2txt::PageNode, cat[8].class) assert_equal(Rpdf2txt::PageLeaf, cat[9].class) assert_equal(Rpdf2txt::PageLeaf, cat[10].class) assert_equal(Rpdf2txt::PageLeaf, cat[11].class) assert_equal(Rpdf2txt::PageLeaf, cat[12].class) assert_equal(Rpdf2txt::PageLeaf, cat[13].class) assert_equal(Rpdf2txt::PageLeaf, cat[14].class) assert_equal(Rpdf2txt::Stream, cat[15].class) assert_equal(Rpdf2txt::Font, cat[16].class) end def test_rebuild_object_catalogue file = File.expand_path('./data/encrypted_object_stream.pdf', File.dirname(__FILE__)) input = File.read(file) parser = Rpdf2txt::Parser.new(input) cat = parser.object_catalogue assert_equal(3, cat.length) assert_equal(cat[2545].class, Rpdf2txt::ObjStream) assert_equal(cat[3166].class, Rpdf2txt::TrailerDictionary) assert_equal(cat[2544].class, Rpdf2txt::PdfHash) parser.trailer_dictionary parser.rebuild_object_catalogue assert_equal(4, cat.length) assert_equal(cat[2530].class, Rpdf2txt::PdfHash) end def test_tree_root cat = @parser.object_catalogue assert_equal(cat[1],@parser.page_tree_root) end def test_page_tree tree = @parser.page_tree cat = @parser.object_catalogue assert_equal(cat[1],tree) firstlevel = tree.pages.kids assert_equal(cat[3],firstlevel[0]) assert_equal([cat[6]], firstlevel[0].contents) assert_equal(cat[4],firstlevel[1]) assert_equal(cat[5],firstlevel[2]) assert_raises(NoMethodError){firstlevel[0].kids} secondlevel = firstlevel[1].kids assert_equal(cat[13],secondlevel[0]) assert_equal([cat[6]], secondlevel[0].contents) assert_equal(cat[14],secondlevel[1]) assert_equal([cat[6]], secondlevel[1].contents) secondlevel = firstlevel[2].kids assert_equal(cat[7],secondlevel[0]) assert_equal(cat[8],secondlevel[1]) thirdlevel = secondlevel[0].kids assert_equal(cat[9],thirdlevel[0]) assert_equal([cat[6]], thirdlevel[0].contents) assert_equal(cat[10],thirdlevel[1]) assert_equal([cat[6]], thirdlevel[1].contents) thirdlevel = secondlevel[1].kids assert_equal(cat[11],thirdlevel[0]) assert_equal(cat[12],thirdlevel[1]) end def test_tree_each expected = [3,13,14,9,10,11,12] assert_equal(expected,@parser.page_tree.collect{ |node| node.oid }) end def test_contents expected = Array.new(6, [@parser.object_catalogue[6]]) expected.push([@parser.object_catalogue[6], @parser.object_catalogue[15]]) result = @parser.page_tree.collect { |node| node.contents } assert_equal(expected, result) end def test_font_token #test was added after we had a parse error in this line # /BaseFont /CKGGCC+TimesNewRoman,Italic #(,Italic was the problem) input = <<-EOS 48 0 obj << /Type /Font /Subtype /Type1 /FirstChar 1 /LastChar 41 /Widths [ 722 444 389 250 333 500 389 278 278 500 500 500 500 444 500 667 389 722 278 722 333 333 444 500 333 556 278 250 611 444 500 500 500 556 667 333 500 444 500 444 611 ] /Encoding 413 0 R /BaseFont /CKGGCC+TimesNewRoman,Italic /FontDescriptor 395 0 R /ToUnicode 414 0 R >> endobj EOS assert_instance_of(Rpdf2txt::Font, @parser.build_object(input)) end def test_resource input = "17 0 obj\n" input << "<< \n" input << "/ProcSet [ /PDF /Text ] \n" input << "/Font << /F2 304 0 R /F4 306 0 R /F6 275 0 R /F8 277 0 R >> \n" input << "/ExtGState << /GS1 318 0 R >> \n" input << ">> \n" input << "endobj\n" input << "1\n" assert_instance_of(Rpdf2txt::Resource, @parser.build_object(input)) end def test_reference_array input = <<-END 76 0 obj [ 535 0 R 78 0 R ] endobj END obj = @parser.build_object(input) assert_instance_of(Rpdf2txt::ReferenceArray, obj) assert_equal([535, 78], obj.references) end def test_array input = <<-END 65 0 obj \n[ \n278 \n0 \n355 \n0 \n0 \n889 \n0 \n191 \n333 \n333 \n0 \n584 \n278 \n333 \n278 \n278 \n556 \n556 \n556 \n556 \n556 \n556 \n556 \n556 \n556 \n556 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n667 \n667 \n722 \n722 \n667 \n611 \n778 \n722 \n278 \n500 \n667 \n556 \n833 \n722 \n778 \n667 \n778 \n722 \n667 \n611 \n722 \n667 \n944 \n667 \n667 \n611 \n0 \n0 \n0 \n0 \n0 \n0 \n556 \n556 \n500 \n556 \n556 \n278 \n556 \n556 \n222 \n222 \n500 \n222 \n833 \n556 \n556 \n556 \n556 \n333 \n500 \n278 \n556 \n500 \n722 \n500 \n500 \n500 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n278 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n556 \n0 \n0 \n0 \n556 \n0 \n0 \n0 \n556 \n556 \n556 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n0 \n556 \n0 \n556 \n0 \n0 \n0 \n0 \n0 \n556 \n] \nendobj \n END obj = @parser.build_object(input) assert_instance_of(Rpdf2txt::PdfArray, obj) assert_equal(221, obj.contents.size) end def test_array__no_trailing_whitespace input = <<-END 146 0 obj[278 0 0 0 0 0 0 0 0 0 0 0 0 333 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 722 722 722 0 0 0 0 722 0 0 0 0 833 0 0 667 0 0 667 611 0 0 0 0 0 611 0 0 0 0 0 0 556 611 556 611 556 333 611 611 278 0 556 278 889 611 611 611 0 389 556 333 611 0 0 0 556 500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 556]\rendobj END obj = @parser.build_object(input) assert_instance_of(Rpdf2txt::PdfArray, obj) assert_equal(197, obj.contents.size) end def test_no_array input = <<-END 185 0 obj\r[ \r/CalRGB << /WhitePoint [ 0.9505 1 1.089 ] /Gamma [ 2.22221 2.22221 2.22221 ] \r/Matrix [ 0.4124 0.2126 0.0193 0.3576 0.71519 0.1192 0.1805 0.0722 0.9505 ] >> \r\r]\rendobj\r END obj = nil assert_nothing_raised { obj = @parser.build_object(input) } assert_instance_of(Rpdf2txt::Unknown, obj) end def test_join_snippets__hex_chars input = <<-'EOS' BT /F0 11 Tf 1 0 0 -1 0 10.413 Tm (Paroxetin besitzt eine selektive Wirkung; in-vitro Studien haben gezeigt, dass es, im Gegensatz zu) Tj 0 -13.2 Td (trizyklischen Antidepressiva, eine geringe Affinität für ) Tj /F4 11 Tf 260.436 0 Td [ -2<012e>] TJ /F0 11 Tf 6.384 -2.2 Td (1) Tj 6.118 2.2 Td (-, ) Tj /F4 11 Tf 9.779 0 Td <012e> Tj /F0 11 Tf 6.356 -2.2 Td (2) Tj 6.118 2.2 Td (- und ) Tj /F4 11 Tf 28.127 0 Td <0215> Tj /F0 11 Tf 6.325 0 Td (-Adrenozeptoren sowie für) Tj -329.642 -15.4 Td (Dopamin \(D) Tj 58.685 -2.2 Td (2) Tj 6.118 2.2 Td (\)-, 5-HT) Tj 37.882 -2.2 Td (1) Tj 6.118 2.2 Td(-artige, 5-HT) Tj 61.735 -2.2 Td(2) Tj 6.118 2.2 Td( und Histamin \(H) Tj 81.915 -2.2 Td(1) Tj 6.118 2.2 Td(\)-Rezeptoren aufweist. Das Fehlen einer) Tj ET EOS txt = Rpdf2txt::Text.new(input, 'latin1', Matrix[[1, 0, 0], [0, 1, 0], [0, 39.866, 0]]) fontsrc0 = <<-'EOS' 6 0 obj << /Type /Font /Name /F0 /Subtype /TrueType /BaseFont /ArialMT /FirstChar 32 /LastChar 252 /Widths[ 278 0 0 0 0 889 0 191 333 333 0 0 278 333 278 278 556 556 556 556 556 556 556 556 556 556 278 278 584 0 584 0 0 667 667 722 722 667 611 778 722 278 500 667 556 833 722 778 667 778 722 667 611 722 667 944 667 667 611 278 0 278 0 0 0 556 556 500 556 556 278 556 556 222 222 500 222 833 556 556 556 556 333 500 278 556 500 722 500 500 500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 737 0 556 0 0 737 0 400 0 0 0 0 0 0 0 0 0 0 556 0 834 0 0 0 0 0 0 667 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 778 0 0 0 0 0 722 0 0 0 0 0 0 0 556 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 556 0 0 0 0 0 556 ] /Encoding /WinAnsiEncoding /FontDescriptor 83 0 R >> endobj EOS font0 = Rpdf2txt::Font.new(fontsrc0) fontsrc4 = <<-'EOS' 31 0 obj << /Type /Font /Name /F4 /Subtype /Type0 /BaseFont /CRASED+ArialMT /Encoding /Identity-H /DescendantFonts[ 87 0 R] /ToUnicode 88 0 R >> endobj EOS font4 = Rpdf2txt::Font.new(fontsrc4) cmap = Rpdf2txt::CMap.new('<< >>') cmap.map = { 302 => 945, 533 => 946, } font4.cmap = cmap fonts = { :f0 => font0, :f4 => font4, } txt.current_page = FontDonorStub.new(fonts) leaf = Rpdf2txt::PageLeaf.new expected = <<-EOS Paroxetin besitzt eine selektive Wirkung; in-vitro Studien haben gezeigt, dass es, im Gegensatz zu trizyklischen Antidepressiva, eine geringe Affinit\344t f\374r a1-, a2- und b-Adrenozeptoren sowie f\374r Dopamin (D2)-, 5-HT1-artige, 5-HT2 und Histamin (H1)-Rezeptoren aufweist. Das Fehlen einer EOS handler = Rpdf2txt::SimpleHandler.new leaf.join_snippets(txt.scan, handler) result = handler.out result << "\n" assert_equal(expected, result) end def test_join_snippets5 input = <<-EOS BT /TT1 1 Tf -0.00031 Tc -0.00211 Tw 10.02 0 0 10.02 70.86 736.40054 Tm [(Der Prozentsatz der mit Humira b)5(eha)5(nd)5(elt)-5(en Patiente)5(n)-1(, welche ACR20)5(-)-3(, ACR50)5(-)-3( und ACR7)5(0-)]TJ 0.0002 Tc -0.00259 Tw 0 -1.14371 TD [(Ansp)6(re)6(chrate)6(n erreichten, war )6(kon)6(s)-3(i)7(s)-3(ten)6(t)3( \374ber die )]TJ -0.00011 Tc -0.0023 Tw 22.3054 0 Td [(Stu)5(d)-1(ien 1, 2, 3 und 4. Die Erg)5(ebni)7(sse f\374r 4)5(0)-1( mg )]TJ 0.00011 Tc -0.0025 Tw -22.3054 -1.1497 Td [(Humi)7(ra alle )6(zwei Wochen )6(sind in Ta)5(bell)7(e)-1( 1 zu)5(samm)7(e)5(ngefa)5(sst. )]TJ /TT0 1 Tf 0 Tc 10.02 0 0 10.02 70.86 687.86049 Tm [(Tabelle 1: ACR-An)5(sp)5(re)5(ch)5(raten bei Placebo-ko)5(nt)]TJ 0.00011 Tc [(rollie)5(rten Pr\374fun)5(ge)5(n \\(in Pro)5(z)-3(ent )6(der Patiente)5(n)5(\\))]TJ /TT1 1 Tf 0 Tc 0 Tw 41.6647 0 Td ( )Tj /TT2 1 Tf -0.0013 Tc 10.02 0 0 10.02 70.86 663.14011 Tm (---------------------------------------------------- )Tj ET EOS txt = Rpdf2txt::Text.new(input, 'latin1') fontsrc0 = <<-EOS 5 0 obj <> endobj EOS font0 = Rpdf2txt::Font.new(fontsrc0) fontsrc1 = <<-EOS 5 0 obj <> endobj EOS font1 = Rpdf2txt::Font.new(fontsrc0) fontsrc2 = <<-EOS 4 0 obj <> endobj EOS font2 = Rpdf2txt::Font.new(fontsrc2) cmap = Rpdf2txt::CMap.new('<< >>') cmap.map = { 36 => 8805, } font2.cmap = cmap fonts = { :tt0 => font0, :tt1 => font1, :tt2 => font2, } txt.current_page = FontDonorStub.new(fonts) leaf = Rpdf2txt::PageLeaf.new expected = <<-EOS Der Prozentsatz der mit Humira behandelten Patienten, welche ACR20-, ACR50- und ACR70- Ansprechraten erreichten, war konsistent \374ber die Studien 1, 2, 3 und 4. Die Ergebnisse f\374r 40 mg Humira alle zwei Wochen sind in Tabelle 1 zusammengefasst. Tabelle 1: ACR-Ansprechraten bei Placebo-kontrollierten Pr\374fungen (in Prozent der Patienten) ---------------------------------------------------- EOS handler = Rpdf2txt::SimpleHandler.new leaf.join_snippets(txt.scan, handler) result = handler.out result << "\n" assert_equal(expected, result) end def test_join_snippets6 input = <<-EOS BT /TT0 1 Tf -0.0002 Tc -0.0022 Tw 10.02 0 0 10.02 70.86 627.92047 Tm [(In Studie 1 evaluierte m)7(an )6(271 Patiente)5(n)-1( mit einer m)7(\344)-1(ssige)5(n)-1( bis )6(sch)5(w)-3(eren a)5(k)-3(tiven rhe)5(u)-1(matoi)6(den )]TJ -0.00031 Tc -0.00211 Tw 0 -1.22749 TD [(Arthritis)-3(,)2( die )]TJ /TT2 1 Tf 0 Tc 0 Tw 5.5509 0 Td ($)Tj /TT0 1 Tf -0.00011 Tc -0.0023 Tw 0.54491 0 Td [(18 Ja)5(hre alt )6(waren, bei de)5(nen die Th)5(erapie mit mind)5(esten)5(s)-3( ein)5(e)-1(m)7(,)2( aber mit nicht mehr )]TJ 0 Tc -0.0024 Tw -6.09579 -1.14371 Td ET EOS txt = Rpdf2txt::Text.new(input, 'latin1') fontsrc0 = <<-EOS 5 0 obj <> endobj EOS font0 = Rpdf2txt::Font.new(fontsrc0) fontsrc2 = <<-EOS 3 0 obj <> endobj EOS font2 = Rpdf2txt::Font.new(fontsrc2) cmap = Rpdf2txt::CMap.new('<< >>') cmap.map = { 36 => 8805, } font2.cmap = cmap fonts = { :tt0 => font0, :tt2 => font2, } txt.current_page = FontDonorStub.new(fonts) leaf = Rpdf2txt::PageLeaf.new expected = "In Studie 1 evaluierte man 271 Patienten mit einer m\344ssigen bis schweren aktiven rheumatoiden \nArthritis, die \26318 Jahre alt waren, bei denen die Therapie mit mindestens einem, aber mit nicht mehr \n" handler = Rpdf2txt::SimpleHandler.new leaf.join_snippets(txt.scan, handler) result = handler.out result << "\n" assert_equal(expected, result) end def test_join_snippets7 input ="BT /F9 1 Tf 10 0 0 10 70.7953 393.3369 Tm -0.0336 Tw [(01)-1044.2(KŸnzle tisana per i nervi e per dormir)17.7(e, erbe medicinali smin)]TJ 33.3976 0 TD 0.0000 Tw (uzzate)Tj /F3 1 Tf -33.3976 -1.4174 TD -0.0306 Tw (* Parroco Erborista KŸnzle SA, , 6573 Magadino)Tj ET" fontsrc = <<-EOS 150 0 obj <> endobj EOS txt = Rpdf2txt::Text.new(input, 'latin1') font = Rpdf2txt::Font.new(fontsrc) cmap = Rpdf2txt::CMap.new('<< >>') font.cmap = cmap font.cmap.map = { 36 => 8805, } font_simple = font.dup font_simple.cmap = nil fonts = { :f9 => font_simple, :f3 => font } txt.current_page = FontDonorStub.new(fonts) leaf = Rpdf2txt::PageLeaf.new expected = "01 Künzle tisana per i nervi e per dormire, erbe medicinali sminuzzate * Parroco Erborista Künzle SA, , 6573 Magadino" handler = Rpdf2txt::SimpleHandler.new leaf.join_snippets(txt.scan, handler) result = handler.out assert_equal(expected, result) end def test_join_snippets8 input = <<-EOS BT /F6 1 Tf 12.5 0 0 12.5 62.4488 839.7822 Tm 0.000 0.000 0.000 1.000 k /GS3 gs -0.0001 Tc -0.0286 Tw [(Arzneimittel Statistik)-130.1(/)-130(MiscellanŽes)]TJ /F4 1 Tf 10 0 0 10 314.5196 35.7671 Tm 0.000 0.000 0.000 0.000 k /GS2 gs -0.0001 Tc 0.0000 Tw (1182)Tj /F2 1 Tf 7 0 0 7 63.4331 45.5374 Tm 0.000 0.000 0.000 1.000 k /GS3 gs -0.0306 Tw [(Swissmedic Jour)-17.9(nal)-1111.9(1)55.6(1)-55.6(/)-111.1(2004)]TJ /F9 1 Tf 10 0 0 10 113.0394 749.1141 Tm -0.0336 Tw [(01)-1044.2(Carsol CR 200)-306(mg, T)98.8(abletten)]TJ 0 -1.2835 TD [(02)-1044.2(Carsol CR 400)-306(mg, T)98.8(abletten)]TJ /F3 1 Tf 0 -1.4174 TD -0.0306 Tw (Ecosol AG, , 6312 Steinhausen)Tj 10 0 0 10 113.0394 701.7668 Tm -0.0002 Tc 0.0000 Tw [(Zul.-Nr)91.6(.: )]TJ /F9 1 Tf 3.8771 0 TD (56749)Tj /F3 1 Tf 8.8787 0 TD -0.0001 Tc [(V)36.8(erkaufskategorie: )]TJ /F9 1 Tf 9.1015 0 TD 0.0000 Tc (B)Tj /F3 1 Tf 3.6544 0 TD -0.0001 Tc -0.0306 Tw [(Index: 01.07.1.)-9563.5(18.11.2004)]TJ -25.5118 -2.2428 TD 0.0000 Tw [(Zusammensetzung:)-921.1(01)]TJ 8.3 0 0 8.3 226.4252 679.3388 Tm -0.0306 Tw [(CARBAMAZEPINUM 200)-278.1(mg, EXCIPIENS pro COMPRESSO.)]TJ 10 0 0 10 212.252 665.1652 Tm -0.0002 Tc 0.0000 Tw (02)Tj 8.3 0 0 8.3 226.4252 665.1652 Tm -0.0001 Tc -0.0306 Tw [(CARBAMAZEPINUM 400)-278.1(mg, EXCIPIENS pro COMPRESSO.)]TJ 10 0 0 10 113.0394 650.9915 Tm 0.0000 Tw /F9 1 Tf 11.5 0 0 11.5 113.0394 790.1339 Tm -0.0336 Tw [(Neuzulassungen /)-122.3(Nouvelles autorisations)]TJ /F4 1 Tf 10 0 0 10 113.0394 766.1339 Tm -0.0306 Tw [(HumanprŠparate)-111.2(/)-111.2(P)0.1(r)17.7(oduits ˆ usage humain)]TJ ET EOS txt = Rpdf2txt::Text.new(input, 'latin1') fontsrc2 = <<-EOS 13 0 obj <> endobj EOS font2 = Rpdf2txt::Font.new(fontsrc2) fontsrc3 = <<-EOS 16 0 obj <> endobj EOS font3 = Rpdf2txt::Font.new(fontsrc3) fontsrc4 = <<-EOS 15 0 obj <> endobj EOS font4 = Rpdf2txt::Font.new(fontsrc4) fontsrc6 = <<-EOS 36 0 obj <> endobj EOS font6 = Rpdf2txt::Font.new(fontsrc6) fontsrc9 = <<-EOS 150 0 obj <> endobj EOS font9 = Rpdf2txt::Font.new(fontsrc9) fonts = { :f2 => font2, :f3 => font3, :f4 => font4, :f6 => font6, :f9 => font9, } txt.current_page = FontDonorStub.new(fonts) leaf = Rpdf2txt::PageLeaf.new expected = <<-EOS Arzneimittel Statistik/Miscellan\351es Neuzulassungen /Nouvelles autorisations Humanpr\344parate/Produits \340 usage humain 01 Carsol CR 200 mg, Tabletten 02 Carsol CR 400 mg, Tabletten Ecosol AG, , 6312 Steinhausen Zul.-Nr.: 56749 Verkaufskategorie: B Index: 01.07.1. 18.11.2004 Zusammensetzung: 01 CARBAMAZEPINUM 200 mg, EXCIPIENS pro COMPRESSO. 02 CARBAMAZEPINUM 400 mg, EXCIPIENS pro COMPRESSO. Swissmedic Journal 11/2004 1182 EOS handler = Rpdf2txt::SimpleHandler.new leaf.join_snippets(txt.scan, handler) result = handler.out assert_equal(expected.strip, result) end def test_join_snippets9 input = <<-EOS BT /F3 1 Tf 10 0 0 10 113.0394 744.2866 Tm -0.0002 Tc 0.0000 Tw [(Zul.-Nr)91.6(.: )]TJ /F9 1 Tf 3.8771 0 TD (56120)Tj /F3 1 Tf 8.8787 0 TD -0.0001 Tc [(V)36.8(erkaufskategorie: )]TJ /F9 1 Tf 9.1015 0 TD 0.0000 Tc (B)Tj /F3 1 Tf 3.6544 0 TD -0.0001 Tc -0.0306 Tw [(Index: 02.07.1.)-9563.5(26.11.2004)]TJ -25.5118 -2.2428 TD 0.0000 Tw [(Zusammensetzung:)-921.1(01)]TJ 8.3 0 0 8.3 226.4252 721.8585 Tm 0.1192 Tw [(TREPROSTINILUM 1)-278.1(mg ut TREPROSTINILUM NA)73.7(TRICUM, NA)73.7(TRII CITRAS, A)]TJ 35.1847 0 TD (CIDUM HYDRO-)Tj -35.1847 -1.3661 TD -0.0304 Tw [(CHLORICUM DILUTUM, NA)73.7(TRII HYDROXIDUM, NA)73.7(TRII CHLORIDUM, CONSER)17.7(V)]TJ 35.7763 0 TD [(.: MET)54.7(ACRESO-)]TJ -35.7763 -1.3661 TD -0.0306 Tw [(LUM 3)-278.1(mg, EXCIPIENS ad SOLUTIONEM pro 1)-278.1(mL. )]TJ 10 0 0 10 212.252 685.0069 Tm -0.0002 Tc 0.0000 Tw (02)Tj 8.3 0 0 8.3 226.4252 685.0069 Tm -0.0001 Tc 0.0150 Tw [(TREPROSTINILUM 2.5)-278.1(mg ut TREPROSTINILUM NA)73.7(TRICUM, NA)73.7(TRII CITRAS,)]TJ 34.2741 0 TD [( ACIDUM HYDRO-)]TJ -34.2741 -1.3662 TD -0.0304 Tw [(CHLORICUM DILUTUM, NA)73.7(TRII HYDROXIDUM, NA)73.7(TRII CHLORIDUM, CONSER)17.7(V)]TJ 35.7763 0 TD [(.: MET)54.7(ACRESO-)]TJ -35.7763 -1.3662 TD -0.0306 Tw [(LUM 3)-278.1(mg, EXCIPIENS ad SOLUTIONEM pro 1)-278.1(mL. )]TJ 10 0 0 10 113.0394 648.1553 Tm [(Anwendung:)-5285.2(PrimŠre und sekundŠre pulmonale Hypertonie)]TJ 0 -1.4174 TD [(Packungen:)-4532.7(01)-305.6(001)-5591.4(1 x 20)-567(mL)-17319.8(B)]TJ 9.9213 -1.4174 TD [(02)-305.6(003)-5591.4(1 x 20)-567(mL)-17319.8(B)]TJ -9.9213 -1.4174 TD [(Bemerkung:)-5671.9(TREPROSTINILUM \\(ut natrii T)73.9(r)0(eprostinilum\\) = NAS \\(neue)]TJ 37.1235 0 TD [(r Wirkstof)17.7(f\\))]TJ -37.1235 -1.4174 TD [(GŸltig bis:)-6647.8(25. November 2009)]TJ ET EOS txt = Rpdf2txt::Text.new(input, 'latin1') fontsrc3 = <<-EOS 16 0 obj <> endobj EOS font3 = Rpdf2txt::Font.new(fontsrc3) fontsrc9 = <<-EOS 150 0 obj <> endobj EOS font9 = Rpdf2txt::Font.new(fontsrc9) fonts = { :f3 => font3, :f9 => font9, } txt.current_page = FontDonorStub.new(fonts) leaf = Rpdf2txt::PageLeaf.new expected = <<-EOS Zul.-Nr.: 56120 Verkaufskategorie: B Index: 02.07.1. 26.11.2004 Zusammensetzung: 01 TREPROSTINILUM 1 mg ut TREPROSTINILUM NATRICUM, NATRII CITRAS, ACIDUM HYDRO- CHLORICUM DILUTUM, NATRII HYDROXIDUM, NATRII CHLORIDUM, CONSERV.: METACRESO- LUM 3 mg, EXCIPIENS ad SOLUTIONEM pro 1 mL. 02 TREPROSTINILUM 2.5 mg ut TREPROSTINILUM NATRICUM, NATRII CITRAS, ACIDUM HYDRO- CHLORICUM DILUTUM, NATRII HYDROXIDUM, NATRII CHLORIDUM, CONSERV.: METACRESO- LUM 3 mg, EXCIPIENS ad SOLUTIONEM pro 1 mL. Anwendung: Prim\344re und sekund\344re pulmonale Hypertonie Packungen: 01 001 1 x 20 mL B 02 003 1 x 20 mL B Bemerkung: TREPROSTINILUM (ut natrii Treprostinilum) = NAS (neuer Wirkstoff) G\374ltig bis: 25. November 2009 EOS handler = Rpdf2txt::SimpleHandler.new leaf.join_snippets(txt.scan, handler) result = handler.out assert_equal(expected.strip, result, result) end def test_join_snippets10 input = <<-EOS BT /F9 1 Tf 10 0 0 10 113.0394 585.3986 Tm -0.0336 Tw [(01)-1044.2(Imigran, Injektionslšsung)]TJ /F3 1 Tf T* -0.0306 Tw [(GlaxoSmithKline AG, T)73.9(alstrasse 3Ð5, 3053 MŸnchenbuchsee)]TJ 10 0 0 10 113.0394 550.8859 Tm -0.0002 Tc 0.0000 Tw [(Zul.-Nr)91.6(.: )]TJ /F9 1 Tf 3.8771 0 TD (51684)Tj /F3 1 Tf 8.8787 0 TD -0.0001 Tc [(V)36.8(erkaufskategorie: )]TJ /F9 1 Tf 9.1015 0 TD 0.0000 Tc (B)Tj /F3 1 Tf 3.6544 0 TD -0.0001 Tc -0.0306 Tw [(Index: 02.05.1.)-9563.5(17.11.2004)]TJ -25.5118 -2.2428 TD 0.0000 Tw [(Zusammensetzung:)-921.1(01)]TJ 8.3 0 0 8.3 226.4252 528.4578 Tm -0.0582 Tw [(SUMA)73.7(TRIPT)54.7(ANUM 6)-278.1(mg ut SUMA)73.7(TRIPT)54.7(ANI SUCCINAS \\(1:1\\), NA)73.7(TRII CHLORI)]TJ 33.9231 0 TD (DUM, AQUA ad IN-)Tj -33.9231 -1.3662 TD -0.0306 Tw [(IECT)54.7(ABILIA q.s. ad SOLUTIONEM pro 0.5)-278.1(mL. )]TJ 10 0 0 10 113.0394 502.9452 Tm [(Anwendung:)-5285.2(Behandlung akuter MigrŠneanfŠlle)]TJ 0 -1.4174 TD [(* Packung:)-4896.3(01)-305.6(044)-3172.4(2 Patronen)-14173.3(B)]TJ T* [(Bemerkungen:)-4505.2(Ersetzt die Zulassungsbescheinigung vom 01.05.2002 )]TJ 35.9654 0 TD [(\\(V)36.8(erzicht Fertigspritze\\))]TJ -35.9654 -1.4174 TD [(GŸltig bis:)-6647.8(31. Dezember 2006)]TJ ET EOS txt = Rpdf2txt::Text.new(input, 'latin1') fontsrc3 = <<-EOS 16 0 obj <> endobj EOS font3 = Rpdf2txt::Font.new(fontsrc3) fontsrc9 = <<-EOS 150 0 obj <> endobj EOS font9 = Rpdf2txt::Font.new(fontsrc9) fonts = { :f3 => font3, :f9 => font9, } txt.current_page = FontDonorStub.new(fonts) leaf = Rpdf2txt::PageLeaf.new expected = <<-EOS 01 Imigran, Injektionsl\366sung GlaxoSmithKline AG, Talstrasse 3-5, 3053 M\374nchenbuchsee Zul.-Nr.: 51684 Verkaufskategorie: B Index: 02.05.1. 17.11.2004 Zusammensetzung: 01 SUMATRIPTANUM 6 mg ut SUMATRIPTANI SUCCINAS (1:1), NATRII CHLORIDUM, AQUA ad IN- IECTABILIA q.s. ad SOLUTIONEM pro 0.5 mL. Anwendung: Behandlung akuter Migr\344neanf\344lle * Packung: 01 044 2 Patronen B Bemerkungen: Ersetzt die Zulassungsbescheinigung vom 01.05.2002 (Verzicht Fertigspritze) G\374ltig bis: 31. Dezember 2006 EOS handler = Rpdf2txt::SimpleHandler.new leaf.join_snippets(txt.scan, handler) result = handler.out assert_equal(expected.strip, result) end def test_join_snippets11 stream = Rpdf2txt::Stream.new('', 'latin1') stream.decoded_stream = <<-'EOS' q 1 0 0 -1 70.866 841.89 cm 0 J 1 1 1 RG q -1.5 -1.5 m 455.043 -1.5 l 452.043 1.5 l 1.5 1.5 l W* n -0.5 0 m 454.043 0 l S Q q 455.043 -1.5 m 455.043 32.5 l 452.043 29.5 l 452.043 1.5 l W* n 453.543 -0.5 m 453.543 31.5 l S Q q 455.043 32.5 m -1.5 32.5 l 1.5 29.5 l 452.043 29.5 l W* n 454.043 31 m -0.5 31 l S Q q -1.5 32.5 m -1.5 -1.5 l 1.5 1.5 l 1.5 29.5 l W* n 0 31.5 m 0 -0.5 l S Q 1 0 0 1 0.5 31.5 cm 0 0 0 rg BT /F0 8 Tf 1 0 0 -1 232.336 7.573 Tm[(Fachinformation) -3( )] TJ ET 1 0 0 1 -0.5 -0.5 cm q 455.043 -1.5 m 455.043 12.1 l 452.043 9.1 l 452.043 1.5 l W* n 453.543 -0.5 m 453.543 11.1 l S Q q 455.043 12.1 m -1.5 12.1 l 1.5 9.1 l 452.043 9.1 l W* n 454.043 10.6 m -0.5 10.6 l S Q q -1.5 12.1 m -1.5 -1.5 l 1.5 1.5 l 1.5 9.1 l W* n 0 11.1 m 0 -0.5 l S Q 1 0 0 1 0 39.866 cm BT /F1 16 Tf 1 0 0 -1 0 15.147 Tm(Ciprofloxacin Sandoz® i.v.) Tj 0 0 0 RG ET 0 31.773 m 453.543 31.773 l S BT /F2 11 Tf 1 0 0 -1 407.099 44.213 Tm(SANDOZ) Tj ET 0 48.3 m 453.543 48.3 l S BT /F2 8 Tf 1 0 0 -1 0 70.173 Tm(AMZV 9.11.2001) Tj 0 -15.6 Td(Zusammensetzung) Tj /F3 8 Tf 0 -9.6 Td(Wirkstoff:) Tj /F0 8 Tf 33.332 0 Td( 1 Cyclopropyl-6-fluor-1,4-dihydro-4-oxo-7-\(1-piperazinyl\)-3-chinolincarbonsäure \(Ciprofloxacinum ut Ciprofloxacini) Tj -33.332 -9.6 Td(hydrochloridum\).) Tj /F3 8 Tf 0 -11.6 Td(Hilfsstoffe:) Tj /F0 8 Tf 37.344 0 Td( Acidum lacticum, Natrii chloridum, Aqua ad inject.) Tj /F2 8 Tf -37.344 -17.6 Td(Galenische Form und Wirkstoffmenge pro Einheit) Tj /F0 8 Tf 0 -9.6 Td(Lösung zur Infusion.) Tj 0 -11.6 Td(Ciprofloxacinum 200 mg/100 ml ut Ciprofloxacini hydrochloridum.) Tj 0 -11.6 Td(Ciprofloxacinum 400 mg/200 ml ut Ciprofloxacini hydrochloridum.) Tj /F2 8 Tf 0 -17.6 Td(Indikationen/Anwendungsmöglichkeiten) Tj /F0 8 Tf -0.311 Tw 0 -9.6 Td(Ciprofloxacin Sandoz i.v. eignet sich zur Behandlung von Infektionen, die durch Ciprofloxacin-empfindliche Erreger hervorgerufen) Tj 0 Tw 0 -9.6 Td(werden:) Tj 0 -11.6 Td(Infektionen der Atemwege.) Tj 0 -11.6 Td(Bei den im ambulanten Bereich häufigen Pneumokokken-Pneumonien ist Ciprofloxacin Sandoz i.v. nicht das Mittel der ersten) Tj 0 -9.6 Td(Wahl. Ciprofloxacin Sandoz i.v. kann aber bei Pneumonien, verursacht durch z.B. Klebsiella, Enterobacter, Proteus,) Tj 0 -9.6 Td(Pseudomonas, E. coli, Haemophilus, Branhamella, Legionella, Staphylococcus, angezeigt sein.) Tj -0.036 Tw 0 -11.6 Td(Bei akuten, durch P. aeruginosa verursachten Infektionsschüben bei Kindern und Jugendlichen \(5–17 Jahre\) mit Mukoviszidose.) Tj 0 Tw 0 -9.6 Td(Die Behandlung beträgt 10–14 Tage.) Tj 0 -11.6 Td(Hals-Nasen-Ohren-Infektionen. Insbesondere wenn sie durch gramnegative Keime einschliesslich Pseudomonas oder durch) Tj 0 -9.6 Td(Staphylococcus verursacht sind.) Tj 0 -11.6 Td(Mund-Zahn-Kiefer-Infektionen.) Tj 0 -11.6 Td(Infektionen der Nieren und/oder der ableitenden Harnwege.) Tj 0 -11.6 Td(Infektionen der Geschlechtsorgane, einschliesslich Gonorrhö und Adnexitis.) Tj -0.631 Tw 0 -11.6 Td(Bei einer begleiteten Infektion durch Chlamydien/Mykoplasmen \(nicht- resp. postgonorrhoische Urethritis\) ist Ciprofloxacin Sandoz) Tj 0 Tw 0 -9.6 Td(i.v. nicht das Mittel der 1. Wahl \(siehe «Spezielle Dosieranweisung»\). Eine begleitende Lues wird nicht beeinflusst.) Tj 0 -11.6 Td(Infektionen des Magen-Darm-Traktes.) Tj 0 -11.6 Td(Infektionen der Gallenwege.) Tj 0 -11.6 Td(Wund- und Weichteilinfektionen.) Tj 0 -11.6 Td(Infektionen der Knochen und Gelenke.) Tj 0 -11.6 Td(Infektionen in Gynäkologie und Geburtshilfe.) Tj 0 -11.6 Td(Sepsis.) Tj 0 -11.6 Td(Infektionen des Bauchfells \(Peritonitis\).) Tj 0 -11.6 Td(Infektionen der Augen.) Tj 0 -11.6 Td(Infektionen oder drohende Infektionsgefahr \(Prophylaxe\) bei Patienten mit geschwächter körpereigener Abwehr \(z.B. unter) Tj 0 -9.6 Td(Behandlung mit Immunsuppressiva bzw. im neutropenischen Zustand\).) Tj 0 -11.6 Td(Anwendung zur selektiven Darmdekontamination bei immunsuppressiv behandelten Patienten \(oral\).) Tj /F3 8 Tf 0 -11.6 Td(Bei Milzbrand:) Tj /F0 8 Tf 50.688 0 Td( Zur Postexpositionsprophylaxe und zur Behandlung des Milzbrandes nach Inhalation des Erregers Bacillus) Tj -50.688 -9.6 Td(anthracis. Die Wirksamkeit von Ciprofloxacin bei Milzbrand wurde tierexperimentell belegt \(siehe Kapitel «Eigenschaften/) Tj -0.67 Tw 0 -9.6 Td(Wirkungen»\). Bei Kindern, Heranwachsenden, Schwangeren und stillenden Frauen sollte nach Feststellung des Resistenzmusters) Tj 0 Tw 0 -9.6 Td(des beteiligten Bacillus anthracis-Stammes die Möglichkeit einer Umstellung der Therapie auf \(Amino-\) penicilline überprüft) Tj 0 -9.6 Td(werden.) Tj /F2 8 Tf 0 -17.6 Td(Dosierung/Anwendung) Tj /F3 8 Tf 0 -9.6 Td(Übliche Dosierung) Tj ET 1 0 0 1 0 551.4 cm 0.1 w q -1 1.835 m 454.543 1.835 l 452.443 3.935 l 1.1 3.935 l W* n 0 2.885 m 453.543 2.885 l S Q q 454.543 1.835 m 454.543 4.035 l 452.443 1.935 l 452.443 3.935 l W* n 453.493 2.835 m 453.493 3.035 l S Q q 454.543 4.035 m -1 4.035 l 1.1 1.935 l 452.443 1.935 l W* n 453.543 2.985 m 0 2.985 l S Q q -1 4.035 m -1 1.835 l 1.1 3.935 l 1.1 1.935 l W* n 0.05 3.035 m 0.05 2.835 l S Q 1 0 0 1 0 5.869 cm BT /F4 8 Tf 1 0 0 -1 0 6.929 Tm( Einzel-/Tagesdosen) Tj ET 1 0 0 1 0 9.6 cm BT /F4 8 Tf 1 0 0 -1 0 6.929 Tm( bei Erwachsenen ) Tj ET 1 0 0 1 0 9.6 cm q -1 1.835 m 454.543 1.835 l 452.443 3.935 l 1.1 3.935 l W* n 0 2.885 m 453.543 2.885 l S Q q 454.543 1.835 m 454.543 4.035 l 452.443 1.935 l 452.443 3.935 l W* n 453.493 2.835 m 453.493 3.035 l S Q q 454.543 4.035 m -1 4.035 l 1.1 1.935 l 452.443 1.935 l W* n 453.543 2.985 m 0 2.985 l S Q q -1 4.035 m -1 1.835 l 1.1 3.935 l 1.1 1.935 l W* n 0.05 3.035 m 0.05 2.835 l S Q 1 0 0 1 0 5.869 cm BT /F4 8 Tf 1 0 0 -1 0 6.929 Tm(Einfache Infektionen der 2× 200 mg ) Tj ET 1 0 0 1 0 9.6 cm BT /F4 8 Tf 1 0 0 -1 0 6.929 Tm(unteren und oberen Harnwege ) Tj ET 1 0 0 1 0 9.6 cm q -1 1.835 m 454.543 1.835 l 452.443 3.935 l 1.1 3.935 l W* n 0 2.885 m 453.543 2.885 l S Q q 454.543 1.835 m 454.543 4.035 l 452.443 1.935 l 452.443 3.935 l W* n 453.493 2.835 m 453.493 3.035 l S Q q 454.543 4.035 m -1 4.035 l 1.1 1.935 l 452.443 1.935 l W* n 453.543 2.985 m 0 2.985 l S Q q -1 4.035 m -1 1.835 l 1.1 3.935 l 1.1 1.935 l W* n 0.05 3.035 m 0.05 2.835 l S Q 1 0 0 1 0 5.869 cm BT /F4 8 Tf 1 0 0 -1 0 6.929 Tm(Schwere Infektionen der Harnwege 2× 200 mg bis ) Tj ET 1 0 0 1 0 9.6 cm BT /F4 8 Tf 1 0 0 -1 0 6.929 Tm( 2× 400 mg ) Tj ET 1 0 0 1 0 9.6 cm q -1 1.835 m 454.543 1.835 l 452.443 3.935 l 1.1 3.935 l W* n 0 2.885 m 453.543 2.885 l S Q q 454.543 1.835 m 454.543 4.035 l 452.443 1.935 l 452.443 3.935 l W* n 453.493 2.835 m 453.493 3.035 l S Q q 454.543 4.035 m -1 4.035 l 1.1 1.935 l 452.443 1.935 l W* n 453.543 2.985 m 0 2.985 l S Q q -1 4.035 m -1 1.835 l 1.1 3.935 l 1.1 1.935 l W* n 0.05 3.035 m 0.05 2.835 l S Q 1 0 0 1 0 5.869 cm BT /F4 8 Tf 1 0 0 -1 0 6.929 Tm(Infektionen der Atemwege 2× 200 mg bis ) Tj ET 1 0 0 1 0 9.6 cm BT /F4 8 Tf 1 0 0 -1 0 6.929 Tm(\(je nach Schweregrad und Keim\) 2× 400 mg ) Tj ET 1 0 0 1 0 9.6 cm q -1 1.835 m 454.543 1.835 l 452.443 3.935 l 1.1 3.935 l W* n 0 2.885 m 453.543 2.885 l S Q q 454.543 1.835 m 454.543 4.035 l 452.443 1.935 l 452.443 3.935 l W* n 453.493 2.835 m 453.493 3.035 l S Q q 454.543 4.035 m -1 4.035 l 1.1 1.935 l 452.443 1.935 l W* n 453.543 2.985 m 0 2.985 l S Q q -1 4.035 m -1 1.835 l 1.1 3.935 l 1.1 1.935 l W* n 0.05 3.035 m 0.05 2.835 l S Q 1 0 0 1 0 5.869 cm BT /F4 8 Tf 1 0 0 -1 0 6.929 Tm(Andere Infektionen 2× 400 mg ) Tj ET 1 0 0 1 0 9.6 cm BT /F4 8 Tf 1 0 0 -1 0 6.929 Tm(\(vergleiche Indikationen\) ) Tj ET 1 0 0 1 0 9.6 cm q -1 1.835 m 454.543 1.835 l 452.443 3.935 l 1.1 3.935 l W* n 0 2.885 m 453.543 2.885 l S Q q 454.543 1.835 m 454.543 4.035 l 452.443 1.935 l 452.443 3.935 l W* n 453.493 2.835 m 453.493 3.035 l S Q q 454.543 4.035 m -1 4.035 l 1.1 1.935 l 452.443 1.935 l W* n 453.543 2.985 m 0 2.985 l S Q q -1 4.035 m -1 1.835 l 1.1 3.935 l 1.1 1.935 l W* n 0.05 3.035 m 0.05 2.835 l S Q 1 0 0 1 0 -676.746 cm BT /F0 8 Tf 1 0 0 -1 0 690.189 Tm(Bei akuter, unkomplizierter Gonorrhö der Frau und des Mannes \(Urethritis\) und bei einer unkomplizierten Zystitis der Frau reicht) Tj 0 -9.6 Td(die einmalige Infusion von 200 mg.) Tj ET 1 0 0 1 0 714.331 cm 1 1 1 RG 1 w q -1.5 -1.5 m 455.043 -1.5 l 452.043 1.5 l 1.5 1.5 l W* n -0.5 0 m 454.043 0 l S Q q 455.043 -1.5 m 455.043 32.5 l 452.043 29.5 l 452.043 1.5 l W* n 453.543 -0.5 m 453.543 31.5 l S Q q -1.5 32.5 m -1.5 -1.5 l 1.5 1.5 l 1.5 29.5 l W* n 0 31.5 m 0 -0.5 l S Q 1 0 0 1 0 31 cm q -1.5 -1.5 m 305.043 -1.5 l 302.043 1.5 l 1.5 1.5 l W* n -0.5 0 m 304.043 0 l S Q q 305.043 -1.5 m 305.043 12.1 l 302.043 9.1 l 302.043 1.5 l W* n 303.543 -0.5 m 303.543 11.1 l S Q q 305.043 12.1 m -1.5 12.1 l 1.5 9.1 l 302.043 9.1 l W* n 304.043 10.6 m -0.5 10.6 l S Q q -1.5 12.1 m -1.5 -1.5 l 1.5 1.5 l 1.5 9.1 l W* n 0 11.1 m 0 -0.5 l S Q 1 0 0 1 304.043 0.5 cm BT /F0 8 Tf 1 0 0 -1 124.094 7.573 Tm(Seite 1) Tj ET 1 0 0 1 -304.043 -0.5 cm q 302.043 -1.5 m 455.043 -1.5 l 452.043 1.5 l 305.043 1.5 l W* n 303.043 0 m 454.043 0 l S Q q 455.043 -1.5 m 455.043 12.1 l 452.043 9.1 l 452.043 1.5 l W* n 453.543 -0.5 m 453.543 11.1 l S Q q 455.043 12.1 m 302.043 12.1 l 305.043 9.1 l 452.043 9.1 l W* n 454.043 10.6 m 303.043 10.6 l S Q 1 0 0 1 -70.866 -816.197 cm Q EOS fontsrc0 = <<-EOS 6 0 obj << /Type /Font /Name /F0 /Subtype /TrueType /BaseFont /ArialMT /FirstChar 32 /LastChar 252 /Widths[ 278 0 0 0 0 889 0 0 333 333 0 0 278 333 278 278 556 556 556 556 556 556 556 556 556 556 278 278 584 584 0 0 0 667 667 722 722 667 611 778 722 278 500 667 556 833 722 778 667 0 722 667 611 722 667 944 667 667 611 278 0 278 0 0 0 556 556 500 556 556 278 556 556 222 222 500 222 833 556 556 556 556 333 500 278 556 500 722 500 500 500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 556 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 737 0 556 0 0 737 0 400 0 333 0 0 576 0 0 0 0 0 556 0 0 0 0 0 0 0 0 667 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 584 0 0 0 0 722 0 0 0 0 0 0 0 556 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 556 0 0 0 0 0 556 ] /Encoding /WinAnsiEncoding /FontDescriptor 72 0 R >> endobj EOS font0 = Rpdf2txt::Font.new(fontsrc0) fontsrc1 = <<-EOS 7 0 obj << /Type /Font /Name /F1 /Subtype /TrueType /BaseFont /Arial-BoldMT /FirstChar 32 /LastChar 174 /Widths[ 278 0 0 0 0 0 0 0 0 0 0 0 0 0 278 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 722 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 667 0 0 0 0 0 0 0 0 0 0 0 0 0 556 0 556 611 0 333 0 0 278 0 0 278 0 611 611 611 0 389 0 0 0 556 0 556 0 500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 737 ] /Encoding /WinAnsiEncoding /FontDescriptor 73 0 R >> endobj EOS font1 = Rpdf2txt::Font.new(fontsrc1) fontsrc2 = <<-EOS 8 0 obj << /Type /Font /Name /F2 /Subtype /TrueType /BaseFont /Arial-BoldItalicMT /FirstChar 32 /LastChar 252 /Widths[ 278 0 0 0 0 0 0 0 0 0 0 0 0 0 278 278 556 556 556 0 0 0 0 0 0 556 0 0 0 0 0 0 0 722 722 0 722 667 611 778 722 278 0 722 0 833 722 778 667 0 0 667 0 722 667 944 0 0 611 0 0 0 0 0 0 556 611 556 611 556 333 611 611 278 0 556 278 889 611 611 611 0 389 556 333 611 556 778 0 0 500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 722 0 0 0 0 0 0 0 556 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 611 0 0 0 0 0 611 ] /Encoding /WinAnsiEncoding /FontDescriptor 74 0 R >> endobj EOS font2 = Rpdf2txt::Font.new(fontsrc2) fontsrc3 = <<-EOS 9 0 obj << /Type /Font /Name /F3 /Subtype /TrueType /BaseFont /Arial-ItalicMT /FirstChar 32 /LastChar 252 /Widths[ 278 0 0 0 0 0 0 0 333 333 0 0 0 333 0 278 556 556 0 0 556 0 0 0 0 556 278 0 584 584 584 0 0 667 667 722 722 667 0 778 722 0 500 667 556 833 722 0 667 0 722 667 0 722 0 944 0 0 0 0 0 0 0 0 0 556 556 500 556 556 278 556 556 222 0 500 222 833 556 556 556 0 333 500 278 556 500 722 500 500 500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 556 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 576 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 722 0 0 0 0 0 0 0 556 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 556 0 0 0 0 0 556 ] /Encoding /WinAnsiEncoding /FontDescriptor 75 0 R >> endobj EOS font3 = Rpdf2txt::Font.new(fontsrc3) fontsrc4 = <<-EOS 10 0 obj << /Type /Font /Name /F4 /Subtype /TrueType /BaseFont /CourierNewPSMT /FirstChar 32 /LastChar 252 /Widths[ 600 0 0 0 0 600 0 0 600 600 0 0 600 600 600 600 600 600 600 600 600 600 600 600 600 600 0 0 600 0 600 0 0 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 0 600 600 600 600 600 0 0 600 600 0 0 0 0 0 0 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 600 0 600 600 600 600 600 600 600 600 600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 600 0 0 0 0 0 0 0 0 0 0 0 0 600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 600 ] /Encoding /WinAnsiEncoding /FontDescriptor 76 0 R >> endobj EOS font4 = Rpdf2txt::Font.new(fontsrc4) fonts = { :f0 => font0, :f1 => font1, :f2 => font2, :f3 => font3, :f4 => font4, } text_state = Rpdf2txt::TextState.new('latin1') font_donor = FontDonorStub.new(fonts) text_snippets = stream.extract_text_objects(font_donor, text_state) expected = <<-EOS Fachinformation Ciprofloxacin Sandoz\256 i.v. SANDOZ AMZV 9.11.2001 Zusammensetzung Wirkstoff: 1 Cyclopropyl-6-fluor-1,4-dihydro-4-oxo-7-(1-piperazinyl)-3-chinolincarbons\344ure (Ciprofloxacinum ut Ciprofloxacini hydrochloridum). Hilfsstoffe: Acidum lacticum, Natrii chloridum, Aqua ad inject. Galenische Form und Wirkstoffmenge pro Einheit L\366sung zur Infusion. Ciprofloxacinum 200 mg/100 ml ut Ciprofloxacini hydrochloridum. Ciprofloxacinum 400 mg/200 ml ut Ciprofloxacini hydrochloridum. Indikationen/Anwendungsm\366glichkeiten Ciprofloxacin Sandoz i.v. eignet sich zur Behandlung von Infektionen, die durch Ciprofloxacin-empfindliche Erreger hervorgerufen werden: Infektionen der Atemwege. Bei den im ambulanten Bereich h\344ufigen Pneumokokken-Pneumonien ist Ciprofloxacin Sandoz i.v. nicht das Mittel der ersten Wahl. Ciprofloxacin Sandoz i.v. kann aber bei Pneumonien, verursacht durch z.B. Klebsiella, Enterobacter, Proteus, Pseudomonas, E. coli, Haemophilus, Branhamella, Legionella, Staphylococcus, angezeigt sein. Bei akuten, durch P. aeruginosa verursachten Infektionssch\374ben bei Kindern und Jugendlichen (5-17 Jahre) mit Mukoviszidose. Die Behandlung betr\344gt 10-14 Tage. Hals-Nasen-Ohren-Infektionen. Insbesondere wenn sie durch gramnegative Keime einschliesslich Pseudomonas oder durch Staphylococcus verursacht sind. Mund-Zahn-Kiefer-Infektionen. Infektionen der Nieren und/oder der ableitenden Harnwege. Infektionen der Geschlechtsorgane, einschliesslich Gonorrh\366 und Adnexitis. Bei einer begleiteten Infektion durch Chlamydien/Mykoplasmen (nicht- resp. postgonorrhoische Urethritis) ist Ciprofloxacin Sandoz i.v. nicht das Mittel der 1. Wahl (siehe \253Spezielle Dosieranweisung\273). Eine begleitende Lues wird nicht beeinflusst. Infektionen des Magen-Darm-Traktes. Infektionen der Gallenwege. Wund- und Weichteilinfektionen. Infektionen der Knochen und Gelenke. Infektionen in Gyn\344kologie und Geburtshilfe. Sepsis. Infektionen des Bauchfells (Peritonitis). Infektionen der Augen. Infektionen oder drohende Infektionsgefahr (Prophylaxe) bei Patienten mit geschw\344chter k\366rpereigener Abwehr (z.B. unter Behandlung mit Immunsuppressiva bzw. im neutropenischen Zustand). Anwendung zur selektiven Darmdekontamination bei immunsuppressiv behandelten Patienten (oral). Bei Milzbrand: Zur Postexpositionsprophylaxe und zur Behandlung des Milzbrandes nach Inhalation des Erregers Bacillus anthracis. Die Wirksamkeit von Ciprofloxacin bei Milzbrand wurde tierexperimentell belegt (siehe Kapitel \253Eigenschaften/ Wirkungen\273). Bei Kindern, Heranwachsenden, Schwangeren und stillenden Frauen sollte nach Feststellung des Resistenzmusters des beteiligten Bacillus anthracis-Stammes die M\366glichkeit einer Umstellung der Therapie auf (Amino-) penicilline \374berpr\374ft werden. Dosierung/Anwendung \334bliche Dosierung Einzel-/Tagesdosen bei Erwachsenen Einfache Infektionen der 2\327 200 mg unteren und oberen Harnwege Schwere Infektionen der Harnwege 2\327 200 mg bis 2\327 400 mg Infektionen der Atemwege 2\327 200 mg bis (je nach Schweregrad und Keim) 2\327 400 mg Andere Infektionen 2\327 400 mg (vergleiche Indikationen) Bei akuter, unkomplizierter Gonorrh\366 der Frau und des Mannes (Urethritis) und bei einer unkomplizierten Zystitis der Frau reicht die einmalige Infusion von 200 mg. Seite 1 EOS leaf = Rpdf2txt::PageLeaf.new handler = Rpdf2txt::SimpleHandler.new leaf.join_snippets(text_snippets, handler) result = handler.out assert_equal(expected.strip, result.strip) end def test_umlaut input = <<-EOS BT /TT9 1 Tf 0.0009 Tc -0.0033 Tw 10.02 0 0 10.02 70.86 279.2013 Tm (\\334bli)Tj 10.02 0 0 10.02 88.0754 279.2013 Tm (che Ta)Tj 10.02 0 0 10.02 118.6655 279.2013 Tm ET EOS fontsrc = <<-EOS 17 0 obj <> endobj EOS txt = Rpdf2txt::Text.new(input, 'latin1') font = Rpdf2txt::Font.new(fontsrc, 'latin1') fonts = { :tt9 => font } txt.current_page = FontDonorStub.new(fonts) leaf = Rpdf2txt::PageLeaf.new expected ="Übliche Ta" handler = Rpdf2txt::SimpleHandler.new leaf.join_snippets(txt.scan, handler) result = handler.out assert_equal(expected, result) end def test_trailer_dictionary input =' SDSdASDASd trailer << /Size 476 /Info 388 0 R /Encrypt 395 0 R /Root 394 0 R /Prev 203754 /ID[<8664e6986751f2a49dccc9a4b40a4f18v>] >> startxref adfadfadf trailer << /Size 500 /ID[<8664e6986751f2a49dccc9a4b40a4f18v>] >> startxref' @parser.src = input @parser.object_catalogue @parser.build_trailer_dictionary assert_equal("500", @parser.trailer_dictionary.attributes[:size]) assert_equal("388 0 R", @parser.trailer_dictionary.attributes[:info]) assert_equal(395, @parser.trailer_dictionary.encrypt_id) end def test_encrypt input =' SDSdASDASd trailer << /Size 476 /Info 388 0 R /Encrypt 395 0 R /Root 394 0 R /Prev 203754 /ID[<8664e6986751f2a49dccc9a4b40a4f18v>] >> startxref adfadfadf trailer << /Size 500 /ID[<8664e6986751f2a49dccc9a4b40a4f18v>] >> startxref' @parser.src = input @parser.object_catalogue @parser.trailer_dictionary assert_equal(395, @parser.encrypt_id) assert_equal("500", @parser.trailer_dictionary.attributes[:size]) end end