Apache PdfBox 仅旋转裁剪框而不旋转文本

Apache PdfBox Rotate Crop Box Only Not Text

我正在尝试从文本转为 pdf,但只有其中一页旋转了 90 度。主要原因是我的一些文本文档有点太大,需要横向显示才能正常显示。我已经尝试了一些东西,但似乎一切都在旋转文本。有没有一种简单的方法可以将 pdf 旋转为横向但保持文本旋转相同?

        OutputStream outputStream = response.getOutputStream();
        PDFMergerUtility pdfMergerUtility = new PDFMergerUtility();
        Map<String, Documents> documents = getDocuments(user, documentReports);

        try (PDDocument documentToPrint = new PDDocument()){
            for(Document doc : documentReports){
                TextToPDF textToPDF = new TextToPDF();
                textToPDF.setFont(PDType1Font.COURIER);
                textToPDF.setFontSize(8);

                Document documentReport = documents.get(doc.getId());
                try(PDDocument pdDocument = textToPDF.createPDFFromText(new InputStreamReader(new ByteArrayInputStream(documentReport.getReportText().getBytes())))) {
                    pdfMergerUtility.appendDocument(documentToPrint, pdDocument);
                }
            }
            pdfMergerUtility.mergeDocuments(MemoryUsageSetting.setupMainMemoryOnly());
            LocalDateTime localUtcTime = Java8TimeUtil.getCurrentUtcTime();
            documentToPrint.getDocumentInformation().setTitle(localUtcTime.toString());
            response.setHeader("Content-Disposition", "inline; filename=" + localUtcTime + ".pdf");
            response.setContentType("application/pdf");
            documentToPrint.save(outputStream);
        }

所以这可能并不适合所有人,但我是根据我的具体要求想出来的。 TextToPDF 在从文本创建 pdf 之前有一个名为 setLandscape 的方法。 textToPDF.setLandscape(真);