Print documents at the HPI in Potsdam.
1.6K
Print your documents at the Hasso-Platter-Institute in Potsdam. Try it out This service provides a web interface to print documents.
The minimal viable product works as follows:
Mobile Print HPI <[email protected]>Hosting:
For supported file formats, please see the Conversions Section
If you think, this is a good idea, please feel free to contribute. Please open an issue if the pull request is not just a small fixing of a bug.
These commands are executed inside the repository directory.
sudo apt-get install python3 python3-pip.python3 -m pip install virtualenvvirtualenv -p python3 ENVENVsource ENV/bin/activatepip install -r requirements.txtpython3 -m printathpi.appIn case you want to run the server after setup, you need to activate the virtual environment and start the server.
source ENV/bin/activate
python3 -m printathpi.app
The server should be reachable at port 8001 under http://localhost:8001/
Different types of files can be converted. These are the installation instructions for those.
sudo apt-get install librsvg2-binsudo apt-get install inkscapesudo apt-get install ghostscript imagemagicksudo apt-get install unoconv libreofficeThe converter functions are in the convert.py file.
It is quite simple to write those: They take a file format like "svg" and the bytes of a
file as an input and return the bytes of the pdf file.
The server is hosted via Docker. It is deployed daily at night. You can develop the docker image. Please be aware that the documentation comes first, so features of the server MUST be documented here.
After you install Docker. Use this command to build the image:
docker build --tag niccokunzmann/printathpi .
And run the image using this command:
docker run --rm -p8001:8001 niccokunzmann/printathpi
Now, you can visit http://localhost:8001/.
The API of this print service allows you to print documents for HPI students directly from your website.
You can submit multiple files as the files[] attribute of a form.
For this you can add the following text to your HTML document.
<form enctype='multipart/form-data' method='POST' action='https://printathpi.quelltext.eu/print'>
<input type='file' name='files[]' multiple="multiple" />
<button type='submit'>Submit</button>
</form>
When the user presses the submit button, the document will be printed.
You can embed a js file to include the print functionlity into your website:
<script type="text/javascript" async="" src="https://printathpi.quelltext.eu/printathpi.js"></script>
Then, you can use the printAtHPI() function:
printAtHPI({"filename.PDF": "... pdf content ..."}, username, password, onPrint, onError);
{"filename.PDF": "... pdf content ..."}username and passwordnull to open the browser dialog.onPrintfunction onPrint(e) {
alert(e.target.responseText);
}
onErrorfunction onError(e) {
if (e.target.status == 401) {
alert("Wrong username or password.");
} else {
alert("Could not print.");
}
}
You can use the command line utility curl to print files without installing any driver. This counts for all files which can be converted.
curl -X POST \
-F 'files[]=@example_files/logo.svg' \
-u '[email protected]:JohannasPassword' \
https://printathpi.quelltext.eu/print
Content type
Image
Digest
Size
539.3 MB
Last updated
over 7 years ago
docker pull niccokunzmann/printathpi