pdflib-有没有一种方法可以旋转pdf页面

问题描述

旋转之前 这就是我用A4页面生成的。 before

旋转后 生成后,我想像这样旋转页面

请帮助我。 after

解决方法

完全有可能!

看看PDFLib Cookbook(学习的最大资源!),更具体地说,是rotate_pages的示例。

基本上,您可以将页面导入文档并以新的方向放置它。这将根据需要“旋转”页面。

食谱中的PHP示例代码:

/* Loop over all pages of the input document */
for ($pageno = 1; $pageno <= $endpage; $pageno++)
{
    $page = $p->open_pdi_page($indoc,$pageno,"");

    if ($page == 0)
        throw new Exception("Error: " . $p->get_errmsg());

    /* Page size may be adjusted by fit_pdi_page() */
    $p->begin_page_ext(0,"width=a4.width height=a4.height");

    /* Place the imported page on the output page. Adjust the page size
    * automatically to the size of the imported page. Orientate the
    * page to the west; similarly you can orientate it to the east or
    * south,if required.
    */
    $p->fit_pdi_page($page,"adjustpage orientate=west");

    $p->close_pdi_page($page);

    $p->end_page_ext("");
}