function wiki_convert_wiki_to_pdf(&$textwiki, $pagenamewiki, $id, $course_id, $uid, $gid, $dfw, $version, $pagename, $font, $size)
{
    global $WS;
    $formateditor = "dfwiki";
    $size_textwiki = sizeOf($textwiki);
    $wikilinks->pagenumber = array();
    $wikilinks->pagename = array();
    $pdf = new wikitopdf('P', 'mm', 'A4', $font, $size, $wikilinks->pagenumber, $wikilinks->pagename, $id, $course_id);
    $pdf->SetTopMargin(25);
    $pdf->SetLeftMargin(30);
    $pdf->SetRightMargin(30);
    //add a wikilinks array
    //links of every wiki page with his pagename and his initial number of pages
    for ($i = 0; $i < $size_textwiki; $i++) {
        unset($texthtml);
        if ($textwiki[$i] != null) {
            //page text
            $texthtml = wiki_parse_text($textwiki[$i], $formateditor);
            $pdf->AddPage();
            //add texthtml to an array(for avoid another wiki_parse_text at the next 'for')
            $textos_wiki_html[$i] = $texthtml;
            //add the internal wiki link for the initial wiki page
            $wikilinks = $pdf->addLinkPage($pdf->PageNo(), $pagenamewiki[$i]);
            $pdf->SetFont($font, '', '');
            //modify title size to the choosen
            $pdf->SetFontSize($size * 2);
            $pdf->Write('', $pagenamewiki[$i]);
            $pdf->Ln($size * 1);
            //text size
            $pdf->SetFontSize($size);
            //parsing html in wikitopdf class
            $pdf->WriteHTML($texthtml);
        } else {
            $textos_wiki_html[$i] = null;
        }
        //save the number of pages of pdf
        $num_total_pags = $pdf->PageNo();
    }
    //Pdf with internal links calculated:
    $pdf->Close();
    //Create the new pdf to write in
    $pdf = new wikitopdf('P', 'mm', 'A4', $font, $size, $wikilinks->pagenumber, $wikilinks->pagename, $id, $course_id);
    $pdf->SetTopMargin(25);
    $pdf->SetLeftMargin(30);
    $pdf->SetRightMargin(30);
    //Define in the pdf created the pages that will have a wiki link
    for ($i = 1; $i <= $num_total_pags; $i++) {
        $pdf->AddPage();
        $pdf->SetLink($i);
        if (array_search($i, $wikilinks->pagenumber)) {
            $pdf->SetLink($i);
        }
    }
    $pdf->setPageZero();
    //add to every wikilink a link to the page that is referring and print the final pdf
    for ($i = 0; $i < $size_textwiki; $i++) {
        if ($textos_wiki_html[$i] != null) {
            //page text
            $texthtml = wiki_parse_text($textwiki[$i], $formateditor, $WS);
            $pdf->AddPage();
            $pdf->SetFont($font, '', '');
            //modify title size to the choosen
            $pdf->SetFontSize($size * 2);
            //write the title page
            $pdf->Write('', $pagenamewiki[$i]);
            $pdf->Ln($size * 1);
            //text size
            $pdf->SetFontSize($size);
            //parsing html in wikitopdf class
            $pdf->WriteHTML($textos_wiki_html[$i]);
        }
    }
    //name of the pdf file with the name of the first page
    $pdf->Output($pagenamewiki[0] . '.pdf', 'D');
}
function wiki_sintax_find_internal_links($text)
{
    global $WS;
    wiki_parser_reset_vars();
    wiki_parser_reset_logs();
    wiki_parser_reset_sintax();
    $res = wiki_parse_text($text, 'links');
    if (!isset($WS->parser_logs['internal'])) {
        $WS->parser_logs['internal'] = array();
    }
    if (!is_array($WS->parser_logs['internal'])) {
        $WS->parser_logs['internal'] = array();
    }
    return $WS->parser_logs['internal'];
}