public function append_comments($allcomments) {
        if (!$this->filename) {
            return false;
        }

        $this->SetFontSize(12 * $this->scale);
        $this->SetMargins(100 * $this->scale, 120 * $this->scale, -1, true);
        $this->SetAutoPageBreak(true, 100 * $this->scale);
        $this->setHeaderFont(array($this->get_export_font_name(), '', 24 * $this->scale, '', true));
        $this->setHeaderMargin(24 * $this->scale);
        $this->setHeaderData('', 0, '', get_string('commentindex', 'assignfeedback_editpdf'));

        // Add a new page to the document with an appropriate header.
        $this->setPrintHeader(true);
        $this->AddPage();

        // Add the comments.
        $commentlinks = array();
        foreach ($allcomments as $pageno => $comments) {
            foreach ($comments as $index => $comment) {
                // Create a link to the current location, which will be added to the marker.
                $commentlink = $this->AddLink();
                $this->SetLink($commentlink, -1);
                $commentlinks[$pageno][$index] = $commentlink;
                // Also create a link back to the marker, which will be added here.
                $markerlink = $this->AddLink();
                $this->SetLink($markerlink, $comment->y * $this->scale, $pageno + 1);
                $label = get_string('commentlabel', 'assignfeedback_editpdf', array('pnum' => $pageno + 1, 'cnum' => $index + 1));
                $this->Cell(50 * $this->scale, 0, $label, 0, 0, '', false, $markerlink);
                $this->MultiCell(0, 0, $comment->rawtext, 0, 'L');
                $this->Ln(12 * $this->scale);
            }
            // Add an extra line break between pages.
            $this->Ln(12 * $this->scale);
        }

        return $commentlinks;
    }