Showing posts with label pdf. Show all posts
Showing posts with label pdf. Show all posts

Thursday, September 17, 2009

php ile pdf işlemlerimi artık tcpdf ile yapıyorum

ÖĞRENDİM
TAVSİYE EDİYORUM

PHP ile pdf işlerim için bunca zamandır pdfb (fpdf+barcode) kullanıyordum ama artık daha iyi olduğunu düşündüğüm bir sınıf var : TCPDF

TCPDF'de de barkod özelliği eklenmiş.
Ayrıca örnekleri incelediğimde pdfb den eksik kalır yanı olmadığını gördüm.

Yapılabilecekler örnekleri ile şöyle sıralanmış :

  1. Simple PDF with default Header and Footer: [PHP] [PDF]
  2. Simple PDF without Header and Footer: [PHP] [PDF]
  3. Custom Header and Footer: [PHP] [PDF]
  4. Cell stretching: [PHP] [PDF]
  5. Multicell: [PHP] [PDF]
  6. WriteHTML and RTL support: [PHP] [PDF]
  7. Independent columns with WriteHTMLCell: [PHP] [PDF]
  8. External UTF-8 text file: [PHP] [PDF]
  9. Image: [PHP] [PDF]
  10. Multiple columns: [PHP] [PDF]
  11. Colored Tables: [PHP] [PDF]
  12. Graphic Functions: [PHP] [PDF]
  13. Graphic Transformations: [PHP] [PDF]
  14. Javascript and Forms: [PHP] [PDF]
  15. Bookmarks (Table of Content): [PHP] [PDF]
  16. Document Encryption: [PHP] [PDF]
  17. Independent columns with MultiCell: [PHP] [PDF]
  18. Persian and Arabic language on RTL document: [PHP] [PDF]
  19. Non unicode / Alternative config file: [PHP] [PDF]
  20. Multicell complex alignment: [PHP] [PDF]
  21. writeHTML alignment: [PHP] [PDF]
  22. CMYK colors: [PHP] [PDF]
  23. Page Groups: [PHP] [PDF]
  24. Object Visibility: [PHP] [PDF]
  25. Object Transparency: [PHP] [PDF]
  26. Text Clipping: [PHP] [PDF]
  27. Barcodes: [PHP] [PDF]
  28. Multiple page formats: [PHP] [PDF]
  29. Set PDF viewer display preferences: [PHP] [PDF]
  30. Colour gradients: [PHP] [PDF]
  31. Pie Chart Graphic: [PHP] [PDF]
  32. EPS/AI vectorial image: [PHP] [PDF]
  33. Mixed font types (TrueType Unicode, core, CID-0): [PHP] [PDF]
  34. Clipping masks: [PHP] [PDF]
  35. Line styles with cells and multicells: [PHP] [PDF]
  36. Text Annotations: [PHP] [PDF]
  37. Spot Colors: [PHP] [PDF]
  38. NON-embedded CID-0 CJK font: [PHP] [PDF]
  39. HTML Justification: [PHP] [PDF]
  40. Booklet (double-sided pages): [PHP] [PDF]
  41. File attachment: [PHP] [PDF]
  42. Image with Alpha Channel Transparency: [PHP] [PDF]
  43. Disk caching: [PHP] [PDF]
  44. Move and delete page: [PHP] [PDF]
  45. Table Of Content with Bookmarks: [PHP] [PDF]
  46. Text hyphenation: [PHP] [PDF]
  47. Transactions and UNDO: [PHP] [PDF]
  48. Table header and rowspan: [PHP] [PDF]
  49. TCPDF methods in HTML: [PHP] [PDF]
  50. Experimental 2D Barcode: [PHP] [PDF]
  51. Full page background: [PHP] [PDF]
  52. Digital Signature Certification: [PHP] [PDF]
  53. Javascript functions: [PHP] [PDF]
  54. XHTML Form: [PHP] [PDF]



Thursday, April 23, 2009

php ve pdf düzenleme, türkçe font sorunu, [fpdf, pdfb ve tcpdf kütüphaneleri]



fpdf (http://www.fpdf.org/) php ile pdf işleme konusunda birebir. harika bir class.
geçenlerde fdf  tabanı kullanarak (ve bir kaç ek kütüphane ile) geliştirilmiş pdfb (http://chir.ag/projects/pdfb/) paketine rastladım.barkod ekleyebiliyor ve pdf şablonlar oluştutup dinamik verilerle bu şablonlardan yeni pdf dosyalar oluşturabiliyorsunuz.

pdfb ile iki sorun çıktı karşıma

1. Hata : pdfb FPDF error: Unable to find xref table - Maybe a Problem with 'auto_detect_line_endings'

bu hatanın temel nedeni olarak pdfb nin eski fpdf sınıfı kullanması olabileceğini düşündüm. içindeki fdpdf sınıfını güncelledim. ancak hata devam etti. meğer hata pdf dosyasının oldukça yeni bir header türü içermesindenmiş. yani kısaca acrobat reader uyumluluğu eski değil, yeni pdf reader lara göre ouşturulmuş. pdf dosyamı tekrar oluşturdum fakat bu defa acrobat reader 6 uyumlu olarak sakladım. birinci sorunum çözüldü!

2. fpdf türkçe karater sorunu
bu sorunu hala çözemedim. kullandığım font dosyası (times.php) türkçe karakter içermiyor olabilir belki diye http://fpdf.fruit-lab.de/ adresinden tekrar oluşturdum fakat hala sorun devam etmekte.
--
ek
iki gün sonunda buldum. PDFB ve FPDF için utf8 karakter sorununu şu şekilde çözdüm (daha dar ifadeyle fpdf türkçe karakter sorunu).
1.http://fpdf.fruit-lab.de/ adresinden iso-8859-9 olarak TR kartakterleri de kapsayan bir fontu çevirdim.
2. Elde ettiğim "z" ve "php" dosyalarını yükledim.
3. pdf oluştururken bu fontu kullandım. şöyleki:
$pdf->AddFont('times','','times.php');
$pdf->SetFont("times", "", 10);

4. (Bu aşamada hala sorunlarım devam etti). pdf çıktısı üreten sayfayı utf8 olarak kaydettim
5. pdf de görünecek olan tüm string verilerimi iu fonksiyon le iso-8859-9 olarak kodladım.

function trsuz($str){
$str=mb_convert_encoding($str, "ISO-8859-9","UTF-8");
 return $str;
  }

 


Artık sorunum kalmadı. mysql den utf8 olarak aldığım string veriler sorunsuzca fpdf ile pdf dosyasında görünmekte :)

Yukarıda bahsi geçen font oluşturma işlemi ile uğraşmak istemezseniz yukarıdaki ben "times" için oluşturdum. Sadece indirip "pdfb\fpdf_fpdi\font" dizini içine açınız. http://sacrosancttayyar.googlepages.com/font.rar