PHPのPDFlibで画像の回転をする方法です。 fit_image関数のオプションで 'rotate=45' とrotateの角度を指定します。 詳細は、PDFlib/PDI/PPSリファレンスのp.125の「表7.4 PDF_fit_image()・PDF_fit_pdi_pageのオプション」を参照してください。
<?php // /path/to/を画像ファイルのあるパスに置き換えてください // PDFlibではURLからの画像読み込みは不可 $img_file = '/path/to/sample.png'; define('PATH_CMaps', '/usr/local/pdflib7/resource/cmap'); try { $p = new PDFlib(); $p->set_parameter("SearchPath", PATH_CMaps); $p->set_parameter("errorpolicy", "return"); $p->begin_document('', ''); $p->set_info("Creator", "Opentype Co.Ltd."); $p->set_info("Title", "Rotate image"); $img = $p->load_image('auto', $img_file, ''); if ($img == 0) { echo $p->get_errmsg(); exit; } $p->begin_page_ext(0, 0, "width=a4.width height=a4.height"); $p->fit_image($img, 200, 700, 'rotate=45'); $p->close_image($img); $p->end_page_ext(''); $p->end_document(''); $buf = $p->get_buffer(); $len = strlen($buf); header("Content-type: application/pdf"); header("Content-Length: $len"); header("Content-Disposition: inline; filename=img_read.pdf"); print $buf; } catch (PDFlibException $e) { die("PDFlib exception occurred in hello sample:\n" . "[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " . $e->get_errmsg() . "\n"); } catch (Exception $e) { die($e); } $p = 0;
このPDFを見る
codeなにがし::PDFlibで画像の回転をするには