本文整理汇总了Java中org.apache.pdfbox.pdmodel.graphics.xobject.PDXObjectImage.getWidth方法的典型用法代码示例。如果您正苦于以下问题:Java PDXObjectImage.getWidth方法的具体用法?Java PDXObjectImage.getWidth怎么用?Java PDXObjectImage.getWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.pdfbox.pdmodel.graphics.xobject.PDXObjectImage
的用法示例。
在下文中一共展示了PDXObjectImage.getWidth方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testPdfBox
import org.apache.pdfbox.pdmodel.graphics.xobject.PDXObjectImage; //导入方法依赖的package包/类
@Test
public void testPdfBox() throws IOException {
File pdfFile = new File(PdfHelper.PDF_TEST_RESOURCES + "pdf/1.pdf");
File outDir = new File("target");
PDDocument document = PDDocument.load(pdfFile);
@SuppressWarnings("unchecked")
List<PDPage> pages = document.getDocumentCatalog().getAllPages();
int imageId = 0;
for (PDPage page : pages) {
for (PDXObjectImage img : page.getResources().getImages().values()) {
int height = img.getHeight();
int width = img.getWidth();
System.out.println(img.getCOSStream().toString());
img.write2file(new File(outDir, imageId++ + "."
+ img.getSuffix()));
}
}
}
示例2: appendContent
import org.apache.pdfbox.pdmodel.graphics.xobject.PDXObjectImage; //导入方法依赖的package包/类
@Override
protected void appendContent(int start, int pages, int page, PDPageContentStream contentStream,
PDRectangle rect) throws IOException {
PDXObjectImage image = getResource().getImage();
if (image != null) {
float width = image.getWidth();
float height = image.getHeight();
AffineTransform transform = new AffineTransform(width, 0, 0, height, getCornerX(
rect.getWidth(), width), getCornerY(rect.getHeight(), height));
transform.rotate((float) ((getRotate() * Math.PI) / 180), 0.5, 0.5);
contentStream.drawXObject(image, transform);
}
}
示例3: appendContent
import org.apache.pdfbox.pdmodel.graphics.xobject.PDXObjectImage; //导入方法依赖的package包/类
@Override
protected void appendContent(int end, int start, int pages, int page,
PDPageContentStream contentStream, PDRectangle rect) throws IOException {
PDXObjectImage image = getResource().getImage();
if (image != null) {
float width = image.getWidth();
float height = image.getHeight();
AffineTransform transform = new AffineTransform(width, 0, 0, height, getCornerX(
rect.getWidth(), width), getCornerY(rect.getHeight(), height));
transform.rotate((float) ((getRotate() * Math.PI) / 180), 0.5, 0.5);
contentStream.drawXObject(image, transform);
}
}