Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Printable PDF version of an article #534

Open
arvindpdmn opened this issue May 26, 2021 · 3 comments
Open

Printable PDF version of an article #534

arvindpdmn opened this issue May 26, 2021 · 3 comments
Assignees

Comments

@arvindpdmn
Copy link

arvindpdmn commented May 26, 2021

As in title. Inspired by this feature in Wikipedia.

@arvindpdmn arvindpdmn self-assigned this May 26, 2021
@arvindpdmn arvindpdmn added this to the V0.38 milestone Jun 6, 2021
@arvindpdmn
Copy link
Author

@arvindpdmn arvindpdmn removed this from the V0.38 milestone Jun 10, 2021
@arvindpdmn arvindpdmn added this to the V0.49 milestone Feb 16, 2024
@arvindpdmn
Copy link
Author

arvindpdmn commented Jun 20, 2024

  • TOC should become bookmarks
  • Hide menus
  • Links in text should appear with URL hidden
  • Remove abbreviations tooltips (can we have tooltip instead?)
  • Citation should link to correct reference item (can we have tooltip as well?)
  • Include images without border
  • Export in default theme
  • Show licensing logo at the end
  • Show See Also before Cite As

Limitations:

  • Animated GIF, embedded audio/video can't be exported
  • Do users really want to export one article? Maybe they want to export multiple articles after filtered by tag? What's the compute load on the server?

@arvindpdmn arvindpdmn removed this from the V0.49 milestone Jun 20, 2024
@arvindpdmn
Copy link
Author

arvindpdmn commented Jun 20, 2024

Some trial code:

    $text = $content->getBody();
    $text = str_replace("/images/", "images/", $text);
    $text = preg_replace('/src="(.*?)" data-fullsrc="(.*?)"/', 'src="\2" data-fullsrc="\2"', $text);
    $text = preg_replace('/<body class=/', '<body style="margin-left:80px" class=', $text);
    $text = preg_replace('/<div class="article-middle/', '<div style="margin-left:80px" class="article-middle', $text);
    $text = preg_replace('/<figure class=/', '<figure style="border:0px" class=', $text);
    $mpdf = new Mpdf([
        'mode' => 'utf-8',
        'format' => 'A4-P',
        'orientation' => 'P'
    ]);
    //$mpdf->showImageErrors = true;
    $mpdf->WriteHTML($text);
    $mpdf->Output('download.pdf', 'F');

Tried dompdf package but mpdf seems to be better:

    $dompdf = new Dompdf();
    $dompdf->loadHtml($text);
    $dompdf->setPaper('A4', 'portrait');
    $dompdf->render();
    file_put_contents("download.pdf", $dompdf->output());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant