Is there any way to rotate a PDF file created using PdfDocument canvas in android

Is there any way to rotate a PDF file created using PdfDocument canvas in android or is there any way to rotate a pdf file before saving to phone on android ?

1 answer

  • answered 2018-09-17 06:03 Nabin Bhandari

    Yes there is a way. Use canvas.rotate(90); before drawing anything in the canvas of PDF document.

    canvas.save();
    // rotate with respect to center of the page.
    canvas.rotate(90, canvas.getWidth() / 2, canvas.getHeight() / 2);
    canvas.draw(/*whatever*/);
    canvas.restore();