aspose獲取文件紙張方向以及設置紙張方向

最近的需求是要打印pdf,然後 用aspose 轉換pdf 後,發現 打印的時候 橫板也打印成豎版了,所以我需要知道 文件是否是橫板。

找了很久 然後發現網上現在沒有 說如果獲取 aspose 文件方向的 ,自己 瞎幾把試出來了 ^^ 分享出來 給大家:

 

    @Test
    public void testAsposeConvertDocx2Pdf() throws  Exception{
        String filename = "C:\\User\\Desktop\\aspose測試模板測試12.pdf";
        String docNmae = "C:\\Users\\Desktop\\測試模板1.docx";
//        String docNmae = "C:\\Users\\Liz\\Desktop\\test.xls";
        File pdfFile = new File(filename);
        FileOutputStream os = new FileOutputStream(pdfFile);
        com.aspose.words.Document doc = new Document(docNmae);
//        SaveOptions saveOptions = SaveOptions.createSaveOptions(SaveFormat.PDF);
//        saveOptions.setPrettyFormat(true);
//        saveOptions.setUseAntiAliasing(true);
//        saveOptions.setUseHighQualityRendering(true);
        SectionCollection sections = doc.getSections();

        for(Section section:sections){
            int a =Orientation.LANDSCAPE;//橫向
            int b = Orientation.PORTRAIT;//豎向
            section.getPageSetup().getOrientation();
        }
        doc.save(os,SaveFormat.PDF);
    }

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章