Make PDF files "personalized" just before they are sent to each user

Make PDF files "personalized" just before they are sent to each user

by Daniel Neis Araujo -
Number of replies: 3
Picture of Core developers Picture of Plugin developers Picture of Translators

Hello,


I've got this pretty interesting task of inserting some data on PDFs for users just before they got their files from Moodle.

Although the first use is not a very brilliant, it adds some personal user info to files to users are "discouraged" to share the contents of a course as they will share it with their email addres, phone number, and "idmsn", it can be used to more "noble" cases.

So i am sharing this in the hope you like =)

Here is the full commit at the moment:

https://github.com/moodle/moodle/compare/master...danielneis:4LINUX-pdf

Note that it uses composer to add two pdf libraries (pdfi works on top of fdpf), so you need to do "composer update" to get this working.

Also, it patches directly the "lib/filelib.php" just before it sends the Content-Length but after sending E-Tags. I would like to do that on the mod_resource_fileplugin but could not figure out a way to get a $file object from a temporary file created on a temporary directory, but I guess it is because I should use the file API to add the file instead of directly write to temporary directory.


As always, suggestions, improvements, doubts any any comments are welcome =)


Kind regards,

Daniel

Average of ratings: Useful (4)
In reply to Daniel Neis Araujo

Re: Make PDF files "personalized" just before they are sent to each user

by Matt Bury -
Picture of Plugin developers

Hi Daniel,

This sounds like a great idea, not just for discouraging sharing but also encouraging/tracking it too. It'd be nice to be able to set what personal information will be included, e.g. time and date downloaded, student ID number, department, and course. It'd be good to see who shares what with whom in the context of blended courses on university and college campuses, i.e. who disseminates the resources and how far they go.

Thanks for the hard work! smile

In reply to Daniel Neis Araujo

Re: Make PDF files "personalized" just before they are sent to each user

by Tomasz Muras -
Picture of Core developers Picture of Plugin developers Picture of Plugins guardians Picture of Translators

Nice idea and thanks for sharing.

You could make this check better:

if (strpos($filename, '.pdf') !== false) {

by using stripos to make it case insensitive.  Also you could handle non-PDF filenames named like : my.pdf.doc.


It would be nice to have "PDF manipulation" implemented as a plugin in Moodle - so it could be customized, there are likely several use cases here.

cheers,
Tomek

In reply to Tomasz Muras

Re: Make PDF files "personalized" just before they are sent to each user

by Alistair Spark -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Hi Daniel,


This is pretty cool. Would be great to see this available in core - especially for assessment where this could be used to prevent anonymity leaks through the metadata.


Thanks
Alistair