Rotate PDF around its center using PDFBox in java
PDDocument document = PDDocument.load(new File(input)); PDPage page = document.getDocumentCatalog().getPages().get(0); PDPageContentStream cs = new PDPageContentStream(document, page,PDPageContentStream.AppendMode.PREPEND, false, false); cs.transform(Matrix.getRotateInstance(Math.toRadians(45), 0, 0)); I am using the above code to rotate the PDF. For the above image, i am getting following output From that code, the content of the page has been moving out of the frame and the rotation is not happening around its center. But i want to get the output as Please suggest me some options. Thanks in