Android : Create a printable pdf via canvas with fillable table in it

on Thursday, March 19, 2015


I create a pdf page with:



private void createPage(PdfDocument.Page page) {
Canvas canvas = page.getCanvas();
int titleBaseLine = 72;
int leftMargin = 54;

Paint paint = new Paint();
paint.setColor(Color.BLACK);
paint.setTextSize(44);
canvas.drawText(stunde.get_name(), leftMargin + 160, titleBaseLine, paint);

paint.setTextSize(22);
canvas.drawText(getResources().getString(R.string.klasse) + " " + stunde.get_klasse(), leftMargin + 200, titleBaseLine + 45, paint);
canvas.drawText(getResources().getString(R.string.notiz) + " " + stunde.get_notiz(), leftMargin + 200, titleBaseLine + 75, paint);


My struggle is to create a canvas which looks like this: goal to achieve


Right now I am not sure if using the canvas is the right choice but I can't find another way. What is the best way to add 1. the table and 2. text in the according space.


I hope someone can help me. Thanks in advance.


0 comments:

Post a Comment