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

Add qrcodes to pdf #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
description='',
# Latest mysql-connector was weird behavior: https://stackoverflow.com/questions/73244027/character-set-utf8-unsupported-in-python-mysql-connector
install_requires=['reportlab>=3.6.8', 'Flask>=2.0.0', "mysql-connector-python<=8.0.29", "gunicorn==20.1.0",
"pyyaml>=6.0"],
"pyyaml>=6.0", "qrcode-7.4.2"],
scripts=['scripts/generate.py'],
include_package_data=True,
package_data={
Expand Down
7 changes: 7 additions & 0 deletions wlan_api/pdf/VoucherPrint.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import qrcode

from reportlab.lib.pagesizes import A5
from reportlab.platypus import SimpleDocTemplate, Paragraph, PageBreak, Image, ListFlowable, ListItem, Spacer, Table, TableStyle
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle, ListStyle
Expand Down Expand Up @@ -64,6 +66,10 @@ def _header_footer(canvas, doc):
canvas.restoreState()

def print_table(self, elements, voucher):
# Generate QR Code
img = qrcode.make(voucher)
img.save('assets/images/qrcode.jpg')
qrcode = Image('assets/images/qrcode.jpg')
table = Table([('Voucher Code', voucher)],
colWidths=55 * mm, rowHeights=10 * mm)
table.setStyle(TableStyle(
Expand Down Expand Up @@ -91,6 +97,7 @@ def print_vouchers(self):
elements = []

for i, voucher in enumerate(self.vouchers):

#qrcode = QRFlowable('http://redirect.wlan.tuerantuer.org/?voucher=' + voucher)
#elements.append(qrcode)

Expand Down
4 changes: 2 additions & 2 deletions wlan_api/server.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import os
import pathlib

import yaml
from flask import Flask, redirect

from wlan_api.vpg import vpg
import yaml
import pathlib


def create_app():
Expand Down
2 changes: 1 addition & 1 deletion wlan_api/vpg/templates/pdf/step.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ <h1>
</h1>
<div class="section">
<div>
Please upload the PDF to the Google Drive! The download starts after about 20 seconds.
Please upload the PDF to the Nextcloud! The download starts after about 20 seconds.
</div>

<form action="/vpg/pdf/generate" method="POST" enctype="multipart/form-data">
Expand Down