Skip to content

fix: missing content in the pdf output for encrypted files - #181

Merged
Agrendalath merged 1 commit into
mainfrom
tecoholic/fix-pdf-overlay-lost-on-encryption
Nov 11, 2026
Merged

Agrendalath merged 1 commit into
mainfrom
tecoholic/fix-pdf-overlay-lost-on-encryption

Conversation

@tecoholic

@tecoholic tecoholic commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

In pypdf v7, the merged content streams are now serialized before encryption. So the overlay is no longer saved as an empty stream. This causes the output credentials to be just a copy of empty template without the actual name, course or verification URL.

Testing instructions

  1. Clone the repo and add it as a tutor mount in your "Ulmo" stack. (It should ideally work in Verawood or main as well) - tutor mounts add lms:/path/to-learning-credentials:/mnt/learning-credentials and tutor dev start -d
  2. Install the plugin tutor dev exec lms pip install -e /mnt/learning-credentials and tutor dev exec python manage.py lms migrate (be on the main branch)
  3. Create/reuse a course with just 1 or 2 graded problems, mark them home work and set the grading criteria to just that one item. (An example course is attached)
  4. Complete the course.
  5. Go to Django Admin > Learning Credentials > Credential Assets > Add a credential assert and upload the blank.pdf from the attachments with the Name Blank and slug blank
  6. Go to Learning Credentials > Credential Type and create a new one:
    • Name: PDF test credential
    • Retrieval func: learning_credentials.processors.retrieve_completions
    • Generation func: learning_credentials.generates.generate_pdf_credential
    • Custom Options:
    {
    "template": "blank",
    "text_elements": {
        "name": {
            "y": 469
        },
        "context": {
            "y": 386
        },
        "date": {
            "y": 59
        }
    }
    }
    
  7. Go to Learning Credentials > Credential Configurations and add a new one with the Test course key as the Learning Context Key and the credential type as the PDF test credential.
  8. Once created, click "Generate credentials"
  9. Go to the Learning Credentials > Credentials. There should be an entry for the test user who completed the course.
  10. Open the credential and click the "Url". It should open an empty PDF.
  11. Now switch to the PR branch and check if the LMS container reloaded.
  12. In the Django admin click "Reissue Credential". Open the regenerated credential and verify that the the contents like user's name, course name and date are present.
image

Merge checklist:
Check off if complete or not applicable:

  • Version bumped
  • Changelog record added
  • Documentation updated (not only docstrings)
  • Fixup commits are squashed away
  • Unit tests added/updated
  • Manual testing instructions provided
  • Noted any: Concerns, dependencies, migration issues, deadlines, tickets

Testing assets

In pypdf v7, the merged content streams are now serialized before encryption.
So the overlay is no longer saved as an empty stream. This causes the output
credentials to be just a copy of empty template without the actual name,
course or verification URL.
@Agrendalath
Agrendalath merged commit f6e8333 into main Nov 11, 2026
13 checks passed
@Agrendalath
Agrendalath deleted the tecoholic/fix-pdf-overlay-lost-on-encryption branch November 11, 2026 00:19
@tecoholic tecoholic self-assigned this Nov 11, 2026
@tecoholic tecoholic added the bug Something isn't working label Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants