Render pdf file with errors: Invaild Char etc.

Hello Guys,

   I write some codes to render a pdf file into a view page. For some
pfd file, they works fine, while others files got different errors. The
errors are like:

    Invalid char `\XXX' in expression, OR
    unexpexted tCONSTANT / tIDENTIFIER, expecting 'XX' ...

    Do you guys have any idea how to get ride of these errors?

    --> Here is my action:

def show_pdf
    respond_to do |format|
      format.pdf do
        render :file =>params[:pdfName]+'.pdf', :layout => false
     end
   end
  end

    --> Errors in Log file:

Processing Admin::TracksController#show_pdf (for 64.180.102.109 at
2010-09-22 16:31:44) [GET]
  Parameters: {"name"=>"test", "action"=>"show_pdf",
"controller"=>"admin/tracks"}
Rendering /test.pdf

ActionView::TemplateError (compile error
/home/app/rails/app/vendor/extensions/track/app/views/test.pdf:820:
Invalid char `\237' in expression
/home/app/rails/app/vendor/extensions/track/app/views/test.pdf:820:
Invalid char `\237' in expression
/home/app/rails/app/vendor/extensions/track/app/views/test.pdf:820:
Invalid char `\036' in expression
/home/app/rails/app/vendor/extensions/track/app/views/test.pdf:820:
Invalid char `\005' in expression
/home/app/rails/app/vendor/extensions/track/app/views/test.pdf:820:
Invalid char `\231' in expression
/home/app/rails/app/vendor/extensions/track/app/views/test.pdf:820:
Invalid char `\223' in expression
/home/app/rails/app/vendor/extensions/track/app/views/test.pdf:820:
syntax error, unexpected tIDENTIFIER, expecting kDO or '{' or '('
...:úŒ-ŸŸ;aR<Ë'ÄÓ‰÷ÛjX™“çRãk++jÑÊÕUuïYˆsÌÆu.¢˜°I"Ç'ЇuÜa...
                              ^
/home/app/rails/app/vendor/extensions/track/app/views/test.pdf:820:
Invalid char `\217' in expression
/home/app/rails/app/vendor/extensions/track/app/views/test.pdf:820:
Invalid char `\242' in expression
/home/app/rails/app/vendor/extensions/track/app/views/test.pdf:820:
Invalid char `\230' in expression
/home/app/rails/app/vendor/extensions/track/app/views/test.pdf:820:
Invalid char `\027' in expression
/home/app/rails/app/vendor/extensions/track/app/views/test.pdf:820:
Invalid char `\260' in expression
/home/app/rails/app/vendor/extensions/track/app/views/test.pdf:820:
syntax error, unexpected tSTRING_BEG, expecting kEND
...™“çRãk++jÑÊÕUuïYˆsÌÆu.¢˜°I"Ç'ЇuÜa±ÍrD·-µò´DÇç...
                              ^
/home/app/rails/app/vendor/extensions/track/app/views/test.pdf:822:
syntax error, unexpected tIDENTIFIER, expecting kEND
...夛¤IbÐØ<øâžyÒ§Ú‘snAÐ¥Ç63"Ä´ ׉A£5P¦…Ÿ=¹t¯Ø*'[åø¸M‘ÆVÞl¼...
                                ^
/home/app/rails/app/vendor/extensions/track/app/views/test.pdf:822:
Invalid char `\240' in expression) on line #820 of
vendor/extensions/track/app/views/test.pdf:
817:
3Ðåf$ÌÒtɆ‡7½%Ëe·ø@¦NU鞶»U¯¨’¼Ð“éµK:e¾N4aêý#þ9œcB$’6êš=žçCßp|1›Ì摘ÿ
818:
Lš2ïWÕ/.Ûurñ­^é=(«š<ý¯ÜûÉšaßݹÁP¶šß.®¬˜\SúêæÖwþÞ}¯Ë$q©ëëfþrÁ*—®8·ûß=žÄ;Çaå:‡û¦¶€N÷Ñ
€IcF¥ª„þ0a'žúl9?;DœfªÐQºU°
F4
³œhxH˜TTŽÍA}aD• ¶ãpnc4ïÍî[}äÚÃZkO!â8où²90Á™:¾caúñ*”‡me6aÔO¯þ±iìÌ™7¡
Ÿ˜€g-ŸÈW@ ÒÍRPX¨B—ºC†˜:b¹òá°„¥Â×јsó_p
:œÃt„Iýn¼6¼*kð¤€CÃÒ´’ˆ0`•jNƒw^žä0µ
819: ðŒ‚WA­€×ÄK!á‚påB,ÇG´ /›±|Z9ÐAÓpºSÿöUßµ˜‚î Ö¶|ôJ¦éis`
Lw†s0w*Ÿ]§÷0`-Î s£í6À9RÕ¬×frhÕl»à°µ»Û„mjµÖkŠ§á¥iœì^ã"
$…úä„.;9B!ÙÆý†áUÖacëižsfxCůá#2y¸-fªþKý…EEnN«Lk|yó®·O*|aêd>uñâAƒHU•¬)›6õ7P…6wLÑÔ¶½MŸÌát+òÇ•Î2ÙöaÇP½oºaßíu|·&Ùá­à…€]g
<{X‡
mÚ#Ò6ž¶&УxÎ+挢ù,[ÔpäÀÛÓînE£ÖµHýB
820: ÔDÑÈZI4N¤˜ãÆ͘’›‹Ò Ÿ¼¼ì@cðãÙ«íô—ÍèöÞÜ6 á¦p!Ë ¤_ÐèôgôdZñZ
o~×é8Ùqï]’A’,V k;+ˆí|e»
8ô^HòÒ¹’—eãëù s(Bæ~ã*£<%kÈÿí ÑÚóèR?;ýí¡Cßž:ú
Œ-ŸŸ;aR<Ë'ÄÓ‰÷ÛjX™“çRãk++jÑÊÕUuïYˆsÌÆu.¢˜°I"Ç'ЇuÜa±ÍrD·-µò´DÇç
¯Á&tã Ex+;R£ƒé„‹r§‹ò Ö±jÎGÛ·ì/[á€ZDÍFýÛם‚9Í›†üÅÓ –á
821: ¹ÿÑ]-@Q]gø?çܽû`—}°/\@–— à*+Âò°]
µ„Zƒ)ÍJ‹µtƒˆZ²Šu¨µ¶15Ç:ZëLXè:Qe­M«±36“é8ŽãÀÄÉÄZmѸ\úŸ{ïjÛ½ó͹{çü÷ÿþÇw‚Õä&bWúÏ
¡>˜¯£š´ñ÷¹£šáŒÂaÛ@ƐϘCtÀòÜæ$’ŸS’—ïöùd/rŸ¹Ôºxo‚ïïî_æYËu¼ê¶ENâ·«¥‹£•G¬Òʸo!MÚ‰P^¿¢’Sœž¿¶ñg¾²…ù‹ŠÕÕùºAîÔ¿(©ª_¤,îY¿áa^é¤.CûdzK˯ýÑòʪêšòß½»Î”žùæ+J=@‰f
”Ó’Ì:‡ur6…Åto=ÉicT€¥nK¼òR¼òª¼×›@adQsåJîrd)éåwd[a;:¾¿ÛÌÃó6nd®tÿb;cïÑœ‚Î+ñîO©u¡?çÂøj°(=3ÃbEßÙMçE}^Ôž3$ž³dÄ
822: ­CFzC¾>;ü._¡Z îaA¡ÿQU%$Tí<¯S‰ÇفPâ×$’̺$u¥g
ï8=J‰žù‹BUY›B¿øñ‰ç^öJÒ÷V,)©Ã€iùå`ñòºÝ?ÌÊÛ°­±:HiÃ
1„B½öIŸ~²ëñ¿³•çY»ÌfŒ_Yk1ÑfÔƒ9*‘$1}©2XlW´>¯¤h8oVYiZ•Íaž¨¹&†ìmÏîØ-I¾òúe˜×)ËWýtO¼›é6ÕkÛÔ\ô#Ê-²×cØ×<AhbdD)`±i“7ãW¥`Oã夛¤IbÐØ<øâžyÒ§Ú‘snAÐ¥Ç63"Ä´ ׉A£5P¦…Ÿ=¹t¯Ø*'[åø¸M‘ÆVÞl¼L‹†
823:
ÿ$©Òm’+Ý:Y"ü&9.ÕM•ëß–^þ´ÒÔ‘à^,²Æå‰Ð,QPºTîbdd¡rœïõ¸møšž˜!Ã5¢#c©ÐÏq3ê+3a°¼8[6Ï´¸,á•LÃíÂx¼r¼˜·a®Np¿CÉ©§Ý<sÒóhᎍÏíð”lûÆÞ}Òe«ë*¤G¥µ+¿"D"Ïׯy¦¡öÐÏã{èØÞÆç·L¹èƒ—›[6N¬£Í)°4˜f3#*í10jS¨W™Wlœ!ߪ&’×ñßì‹ó·6pö—T-/"áúÕ

    vendor/extensions/track/app/views/test.pdf:822:in `compile!'
    vendor/radiant/vendor/plugins/haml/rails/./lib/haml/helpers/action_view_mods.rb:14:in
`render'
    vendor/extensions/track/app/controllers/admin/tracks_controller.rb:39:in
`show_pdf'
    vendor/extensions/track/app/controllers/admin/tracks_controller.rb:35:in
`show_pdf'
    vendor/radiant/vendor/plugins/haml/rails/./lib/sass/plugin/rails.rb:19:in
`process'
    passenger (2.2.5)
lib/phusion_passenger/rack/request_handler.rb:95:in `process_request'
    passenger (2.2.5)
lib/phusion_passenger/abstract_request_handler.rb:207:in `main_loop'
    passenger (2.2.5)
lib/phusion_passenger/railz/application_spawner.rb:378:in
`start_request_handler'
    passenger (2.2.5)
lib/phusion_passenger/railz/application_spawner.rb:181:in
`spawn_application!'
    passenger (2.2.5) lib/phusion_passenger/utils.rb:183:in `safe_fork'
    passenger (2.2.5)
lib/phusion_passenger/railz/application_spawner.rb:153:in
`spawn_application!'
    passenger (2.2.5) lib/phusion_passenger/spawn_manager.rb:272:in
`spawn_rails_application'
    passenger (2.2.5)
lib/phusion_passenger/abstract_server_collection.rb:80:in `synchronize'
    passenger (2.2.5)
lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
    passenger (2.2.5) lib/phusion_passenger/spawn_manager.rb:255:in
`spawn_rails_application'
    passenger (2.2.5) lib/phusion_passenger/spawn_manager.rb:154:in
`spawn_application'
    passenger (2.2.5) lib/phusion_passenger/spawn_manager.rb:287:in
`handle_spawn_application'
    passenger (2.2.5) lib/phusion_passenger/abstract_server.rb:352:in
`__send__'
    passenger (2.2.5) lib/phusion_passenger/abstract_server.rb:352:in
`main_loop'
    passenger (2.2.5) lib/phusion_passenger/abstract_server.rb:196:in
`start_synchronously'

Rendering /home/app/rails/app/public/500.html (500 Internal Server
Error)