سؤال

Is there any class in tcpdf that make Page Display -> Enable Scrolling default options (When i open it in adobe reader), please help, i lost half of day on this. I found this class, but not what I need.

// set pdf viewer preferences
$pdf->setViewerPreferences($preferences);
هل كانت مفيدة؟

المحلول

I was looking for the same answer and your question actually put me on the right track.

From inspecting the TCPDF class, ended up finding the answer in the TCPDF_STATIC class, in the static method TCPDF_STATIC::getPageLayoutMode().

The correct function to use would be TCPDF::SetDisplayMode($zoom, $layout, $mode). For your purpose I'd suggest:

$pdf->SetDisplayMode('default','OneColumn');
OR
$pdf->SetDisplayMode('default','continuous'); // continuous not documented, although should work.

Possible values for those parameters are as follows (from the method's PHPdoc):

  • $zoom
    The zoom to use. It can be one of the following string values or a number indicating the zooming factor to use.
    • fullpage: displays the entire page on screen
    • fullwidth: uses maximum width of window
    • real: uses real size (equivalent to 100% zoom)
    • default: uses viewer default mode
  • $layout
    The page layout. Possible values are:
    • SinglePage Display one page at a time
    • OneColumn Display the pages in one column
    • TwoColumnLeft Display the pages in two columns, with odd-numbered pages on the left
    • TwoColumnRight Display the pages in two columns, with odd-numbered pages on the right
    • TwoPageLeft (PDF 1.5) Display the pages two at a time, with odd-numbered pages on the left
    • TwoPageRight (PDF 1.5) Display the pages two at a time, with odd-numbered pages on the right
  • $mode
    A name object specifying how the document should be displayed when opened:
    • UseNone Neither document outline nor thumbnail images visible
    • UseOutlines Document outline visible
    • UseThumbs Thumbnail images visible
    • FullScreen Full-screen mode, with no menu bar, window controls, or any other window visible
    • UseOC (PDF 1.5) Optional content group panel visible
    • UseAttachments (PDF 1.6) Attachments panel visible
    public function SetDisplayMode($zoom, $layout='SinglePage', $mode='UseNone') {
        if (($zoom == 'fullpage') OR ($zoom == 'fullwidth') OR ($zoom == 'real') OR ($zoom == 'default') OR (!is_string($zoom))) {
            $this->ZoomMode = $zoom;
        } else {
            $this->Error('Incorrect zoom display mode: '.$zoom);
        }
        $this->LayoutMode = TCPDF_STATIC::getPageLayoutMode($layout);
        $this->PageMode = TCPDF_STATIC::getPageMode($mode);
    }
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top