Skip to content

feat: gotenberg support for PDF block - #291

Draft
Kelketek wants to merge 1 commit into
openedx:mainfrom
open-craft:fox/gotenberg-support
Draft

feat: gotenberg support for PDF block#291
Kelketek wants to merge 1 commit into
openedx:mainfrom
open-craft:fox/gotenberg-support

Conversation

@Kelketek

@Kelketek Kelketek commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Description

This Pull Request adds support for conversion of documents to PDF via the Gotenberg service if it is available.

Supporting information

Testing instructions

  1. Follow the instructions in the frontend-app-authoring repository and use the linked version.
  2. Install the Tutor plugin for Gotenberg linked above.
  3. Clone this repository and switch to this branch. Add it to the mounts for Tutor via tutor mounts add /path/to/xblocks-core
  4. tutor images build openedx-dev
  5. Conversion to PDF should now be enabled. Go to a course and find PDF in the advanced components. Add it. Select an office document and verify the document is auto-converted and embedded.
  6. Upload a PDF to verify that still works fine.
  7. Go to a library and do the same-- upload an office document. Verify it's auto-converted and embedded.
  8. Do it again with a PDF to verify that still works fine.

@openedx-webhooks openedx-webhooks added open-source-contribution PR author is not from Axim or 2U core contributor PR author is a Core Contributor (who may or may not have write access to this repo). labels Aug 15, 2026
@openedx-webhooks

Copy link
Copy Markdown

Thanks for the pull request, @Kelketek!

This repository is currently maintained by @openedx/axim-engineering.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

🔘 Update the status of your PR

Your PR is currently marked as a draft. After completing the steps above, update its status by clicking "Ready for Review", or removing "WIP" from the title, as appropriate.


Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@github-project-automation github-project-automation Bot moved this to Needs Triage in Contributions Aug 15, 2026
@Kelketek
Kelketek force-pushed the fox/gotenberg-support branch from 5005fe8 to 098edae Compare August 19, 2026 16:09
@Kelketek
Kelketek marked this pull request as draft August 19, 2026 16:11
@Kelketek Kelketek changed the title wip: gotenberg support feat: gotenberg support for PDF block Aug 19, 2026
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Waiting on Author in Contributions Aug 19, 2026
@Kelketek
Kelketek force-pushed the fox/gotenberg-support branch 5 times, most recently from c0247f0 to 8ec0747 Compare August 28, 2026 00:06
Comment thread xblock_pdf/utils.py
from openedx_content import api as content_api

if not source_url.startswith("/"):
response = requests.get(source_url, timeout=(10, 120))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we check what URL the user sends (like scheme allowlist, the host or resolved IP and redirects)? Otherwise it could result in the same class of bug that this commit fixes in the edx-platform: openedx/openedx-platform@00b7c3ce41

Comment thread xblock_pdf/pdf.py
Checks if the current user has authoring permissions.
"""
user_service = self.runtime.service(self, "user")
permissions_service = self.runtime.service(self, "studio_user_permissions")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work in content library v2. Only django admins get user_is_staff as true so any other library authors will get blocked.

Comment thread xblock_pdf/utils.py
if not (conversion_url := get_conversion_url()): # pragma: no cover
return None

pdf_response = requests.post(conversion_url, files={"file": (source_filename, data)}, timeout=(2, 120))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Could be useful to put this in a try/except block and handle the error incase the Gotenberg container becomes unreachable for some reason.

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

Labels

core contributor PR author is a Core Contributor (who may or may not have write access to this repo). open-source-contribution PR author is not from Axim or 2U

Projects

Status: Waiting on Author

Development

Successfully merging this pull request may close these issues.

4 participants