PHP
PHP / MySql

Recherche
 
ManuelPHP.com

Constantes pré-définies
<<<
Exemples Voir aussi
>>>

8.13 Fonctions ClibPDF
8 Référence des fonctions
 Manuel PHP

Introduction
Pré-requis
Installation
Configuration à l'exécution
Constantes pré-définies
->Exemples
Voir aussi
cpdf_add_annotation
cpdf_add_outline
cpdf_arc
cpdf_begin_text
cpdf_circle
cpdf_clip
cpdf_close
cpdf_closepath_fill_stroke
cpdf_closepath_stroke
cpdf_closepath
cpdf_continue_text
cpdf_curveto
cpdf_end_text
cpdf_fill_stroke
cpdf_fill
cpdf_finalize_page
cpdf_finalize
cpdf_global_set_document_limits
cpdf_import_jpeg
cpdf_lineto
cpdf_moveto
cpdf_newpath
cpdf_open
cpdf_output_buffer
cpdf_page_init
cpdf_place_inline_image
cpdf_rect
cpdf_restore
cpdf_rlineto
cpdf_rmoveto
cpdf_rotate_text
cpdf_rotate
cpdf_save_to_file
cpdf_save
cpdf_scale
cpdf_set_action_url
cpdf_set_char_spacing
cpdf_set_creator
cpdf_set_current_page
cpdf_set_font_directories
cpdf_set_font_map_file
cpdf_set_font
cpdf_set_horiz_scaling
cpdf_set_keywords
cpdf_set_leading
cpdf_set_page_animation
cpdf_set_subject
cpdf_set_text_matrix
cpdf_set_text_pos
cpdf_set_text_rendering
cpdf_set_text_rise
cpdf_set_title
cpdf_set_viewer_preferences
cpdf_set_word_spacing
cpdf_setdash
cpdf_setflat
cpdf_setgray_fill
cpdf_setgray_stroke
cpdf_setgray
cpdf_setlinecap
cpdf_setlinejoin
cpdf_setlinewidth
cpdf_setmiterlimit
cpdf_setrgbcolor_fill
cpdf_setrgbcolor_stroke
cpdf_setrgbcolor
cpdf_show_xy
cpdf_show
cpdf_stringwidth
cpdf_stroke
cpdf_text
cpdf_translate

8.13.6 Exemples

Exemple simple ClibPDF

<?php
$cpdf
= cpdf_open(0);
cpdf_page_init($cpdf, 1, 0, 595, 842, 1.0);
cpdf_add_outline($cpdf, 0, 0, 0, 1, "Page 1");
cpdf_begin_text($cpdf);
cpdf_set_font($cpdf, "Times-Roman", 30, "WinAnsiEncoding");
cpdf_set_text_rendering($cpdf, 1);
cpdf_text($cpdf, "Times Roman outlined", 50, 50);
cpdf_end_text($cpdf);
cpdf_moveto($cpdf, 50, 50);
cpdf_lineto($cpdf, 740, 330);
cpdf_stroke($cpdf);
cpdf_finalize_page($cpdf, 1);
cpdf_finalize($cpdf);
Header("Content-type: application/pdf");
cpdf_output_buffer($cpdf);
cpdf_close($cpdf);
?>

La distribution pdflib contient un exemple plus complet, qui crée des séries de pages avec une horloge. Voici cet exemple converti en script PHP qui utilise l'extension ClibPDF :

Exemple pdfclock de la distribution pdflib 2.0

<?php
$radius
= 200;
$margin = 20;
$pagecount = 40;

$pdf = cpdf_open(0);
cpdf_set_creator($pdf, "pdf_clock.php");
cpdf_set_title($pdf, "Analog Clock");

while (
$pagecount-- > 0) {
  
cpdf_page_init($pdf, $pagecount+1, 0, 2 * ($radius + $margin), 2 * ($radius + $margin), 1.0);

  
cpdf_set_page_animation($pdf, 4, 0.5, 0, 0, 0);  /* wipe */

  
cpdf_translate($pdf, $radius + $margin, $radius + $margin);
  
cpdf_save($pdf);
  
cpdf_setrgbcolor($pdf, 0.0, 0.0, 1.0);

  
/* minute strokes */
  
cpdf_setlinewidth($pdf, 2.0);
  for (
$alpha = 0; $alpha < 360; $alpha += 6)
    {
    
cpdf_rotate($pdf, 6.0);
    
cpdf_moveto($pdf, $radius, 0.0);
    
cpdf_lineto($pdf, $radius-$margin/3, 0.0);
    
cpdf_stroke($pdf);
    }

  
cpdf_restore($pdf);
  
cpdf_save($pdf);

  
/* 5 minute strokes */
  
cpdf_setlinewidth($pdf, 3.0);
  for (
$alpha = 0; $alpha < 360; $alpha += 30)
  {
    
cpdf_rotate($pdf, 30.0);
    
cpdf_moveto($pdf, $radius, 0.0);
    
cpdf_lineto($pdf, $radius-$margin, 0.0);
    
cpdf_stroke($pdf);
  }

  
$ltime = getdate();

  
/* draw hour hand */
  
cpdf_save($pdf);
  
cpdf_rotate($pdf, -(($ltime['minutes']/60.0) + $ltime['hours'] - 3.0) * 30.0);
  
cpdf_moveto($pdf, -$radius/10, -$radius/20);
  
cpdf_lineto($pdf, $radius/2, 0.0);
  
cpdf_lineto($pdf, -$radius/10, $radius/20);
  
cpdf_closepath($pdf);
  
cpdf_fill($pdf);
  
cpdf_restore($pdf);

  
/* draw minute hand */
  
cpdf_save($pdf);
  
cpdf_rotate($pdf, -(($ltime['seconds']/60.0) + $ltime['minutes'] - 15.0) * 6.0);
  
cpdf_moveto($pdf, -$radius/10, -$radius/20);
  
cpdf_lineto($pdf, $radius * 0.8, 0.0);
  
cpdf_lineto($pdf, -$radius/10, $radius/20);
  
cpdf_closepath($pdf);
  
cpdf_fill($pdf);
  
cpdf_restore($pdf);

  
/* draw second hand */
  
cpdf_setrgbcolor($pdf, 1.0, 0.0, 0.0);
  
cpdf_setlinewidth($pdf, 2);
  
cpdf_save($pdf);
  
cpdf_rotate($pdf, -(($ltime['seconds'] - 15.0) * 6.0));
  
cpdf_moveto($pdf, -$radius/5, 0.0);
  
cpdf_lineto($pdf, $radius, 0.0);
  
cpdf_stroke($pdf);
  
cpdf_restore($pdf);

  
/* draw little circle at center */
  
cpdf_circle($pdf, 0, 0, $radius/30);
  
cpdf_fill($pdf);

  
cpdf_restore($pdf);

  
cpdf_finalize_page($pdf, $pagecount+1);
}

cpdf_finalize($pdf);
header("Content-type: application/pdf");
cpdf_output_buffer($pdf);
cpdf_close($pdf);
?>

<< Exemples >>
Constantes pré-définies Fonctions ClibPDF Voir aussi





Google

Services webmasters

Les manuels
 

ManuelPHP.com © 2003-2012 Tigersun - Crédits
Webmaster Site Internet - Télécharger des Logiciels - Programme TV - Entraide Informatique - Agence de Communication
2018-07-20