使用itextpdf,横向和纵向之间PDF的PageSize始终相同 [英] PageSize of PDF always the same between landscape and portrait with itextpdf

查看:1509
本文介绍了使用itextpdf,横向和纵向之间PDF的PageSize始终相同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个PDFReader,其中包含一些横向模式的页面和其他的纵向页面。

I have a PDFReader which contains some page in landscape mode and other in portrait.

我需要区分他们做一些处理...但是,如果我调用getOrientation或getPageSize,值总是相同的(页面大小为595,方向为0)。

I need to distinct them to do some treatment... However, if I call the getOrientation or getPageSize, the value is always the same (595 for pagesize and 0 for orientation).

为什么横向页面的值不同?

Why isn't the value different for a page in landscape ?

我试图找到其他方法来检索页面宽度/方向,但没有任何效果。

I've tryied to find other methods to retrieve page width / orientation but nothing worked.

这是我的代码:

for(int i = 0; i < pdfreader.getNumberOfPages(); i++)
{
    document = PdfStamper.getOverContent(i).getPdfDocument();

    document.getPageSize().getWidth; //this will always be the same
}

谢谢!

推荐答案

修正:

使用

PdfStamper.getImportedPage(pdfReader, pagenumber).getBoundingBox().getWidth()

而不是

stamper.getOverContent(i).getPdfDocument().getPageSize().getWidth();

这篇关于使用itextpdf,横向和纵向之间PDF的PageSize始终相同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆