in reply to Re^2: PDF search problem
in thread PDF search problem

This script works for me on your testFile.txt. The line setting arial font caused an error, so I commented it out. Make sure you save the testFile.txt as utf8. Also, I didn't need the decode, just use the $content. Also, the $content line was sort of long, so I only used the last portion to observe the accents.
#!/usr/bin/perl use warnings; use strict; use PDF::Reuse; use utf8::all; prFile('test.pdf'); #reading UTF-8 data from file open FILE, "<testFile.txt" or die "$!\n";; my $content = ""; while (<FILE>) { $content .= $_; } print "$content\n"; prText(100, 500, $content ); prEnd(); close FILE;

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

Replies are listed 'Best First'.
Re^4: PDF search problem
by stolara (Initiate) on Jul 14, 2012 at 09:50 UTC

    Hi!

    Thanks you are right, but I im in a damonic trap:

    • if I use the default font, search in pdf works fine, but if there are special charactert in the pdf like hungarian ő,ű the pdf doesn't open at all!
    • if I change the font type with prTTFont('arial.ttf'); the pdf opens fine with the special characters but search in pdf doesn't work...

    Any other idea? :-)

      Any other idea? :-)

      I just googled for prTTFont PDF::Reuse to see what bugs were out there, and found this bit of advice which pointed to some code in the docs using TrueType_font . It might be worth a try, to get the font object first, then set it as the font.

      my $arial = prTTFont('/path/to/Arial.ttf'); prFontSize(20); prText(20, 700, 'Some text in Arial'); # # ... later ... # prPage(); prTTFont($arial); prFontSize(12); prText(20, 700, 'Some more text in Arial'); # # to pass a UTF8 string to prText # prText(20, 675, "T\x{113}n\x{101} koutou"); # T?n? Koutou

      I'm not really a human, but I play one on earth.
      Old Perl Programmer Haiku ................... flash japh

        Many thanks, but unfortunately it didn't work.