本文整理汇总了Java中com.itextpdf.text.Image.getWidth方法的典型用法代码示例。如果您正苦于以下问题:Java Image.getWidth方法的具体用法?Java Image.getWidth怎么用?Java Image.getWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.itextpdf.text.Image
的用法示例。
在下文中一共展示了Image.getWidth方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: reshapeImage
import com.itextpdf.text.Image; //导入方法依赖的package包/类
private float reshapeImage(Image image, float imagewidthmax, float imageheightmax){
float imageheight = image.getHeight();
float imagewidth = image.getWidth();
float scaler;
if((imageheightmax>imageheight)&&(imageheightmax>imagewidth)) return 1;
if(imageheight < imagewidth){
scaler = imagewidthmax/image.getWidth()*100;
image.scalePercent(scaler);
}
else {
scaler = imageheightmax/image.getHeight()*100;
image.scalePercent(scaler);
}
return scaler/100;
}
示例2: getAutoZoonImageHtmlByMaxDimen
import com.itextpdf.text.Image; //导入方法依赖的package包/类
public static String getAutoZoonImageHtmlByMaxDimen(String imgUrl, int imageMaxDimen, int border)
{
String ret = null;
Image img = getImageFromUrl(imgUrl);
if (img == null)
{
return null;
}
else
{
float w = img.getWidth();
float h = img.getHeight();
if (w >= h)
{
//宽度较大,以宽度作为基准来自动缩放
ret = String.format("<p align=\"left\"><img width=\"%s\" height=\"%s\" border=\"%s\" src=\"%s\"></p>",
imageMaxDimen,
(int)(h * imageMaxDimen / w),
border,
imgUrl);
}
else
{
//高度较大
ret = String.format("<p align=\"left\"><img width=\"%s\" height=\"%s\" border=\"%s\" src=\"%s\"></p>",
(int)(w * imageMaxDimen / h),
imageMaxDimen,
border,
imgUrl);
}
}
return ret;
}
示例3: getAutoZoomWidthByHeight
import com.itextpdf.text.Image; //导入方法依赖的package包/类
/**
* 获取自动缩放后的宽度
* @author Administrator
* @param url
* @param height
* @return
*/
public static int getAutoZoomWidthByHeight(String url, int height)
{
Image image = getImageFromUrl(url);
if (image == null)
{
return 0;
}
else
{
float w = image.getWidth();
float h = image.getHeight();
return (int)(w * height / h);
}
}
示例4: getAutoZoomHeightByWidth
import com.itextpdf.text.Image; //导入方法依赖的package包/类
/**
* 获取自动缩放后的高度
* @author Administrator
* @param url
* @param width
* @return
*/
public static int getAutoZoomHeightByWidth(String url, int width)
{
Image image = getImageFromUrl(url);
if (image == null)
{
return 0;
}
else
{
float w = image.getWidth();
float h = image.getHeight();
return (int)(h * width / w);
}
}
示例5: getCenterX
import com.itextpdf.text.Image; //导入方法依赖的package包/类
/**
* Gets the X value for centering the watermark image
*
* @param r
* @param img
* @return
*/
protected float getCenterX(Rectangle r, Image img)
{
float x = 0;
float pdfwidth = r.getWidth();
float imgwidth = img.getWidth();
x = (pdfwidth - imgwidth) / 2;
return x;
}
示例6: addHeaderImage
import com.itextpdf.text.Image; //导入方法依赖的package包/类
private void addHeaderImage() {
try {
URL imageURL = getClass().getResource("/images/logo.png");
Image logo = Image.getInstance(imageURL);
float x = logo.getWidth();
float y = logo.getHeight();
System.out.println("IMAGE HEIGHT: " + y + "IMAGE WIDTH: " + x);
PDFBuilderForCDA.this.document.add(logo);
} catch (Exception ex) {
ex.printStackTrace();
}
}
示例7: getCenterX
import com.itextpdf.text.Image; //导入方法依赖的package包/类
/**
* Gets the X value for centering the signature stamp
*
* @param r
* @param img
* @return
*/
protected float getCenterX(Rectangle r, Image img)
{
float x = 0;
float pdfwidth = r.getWidth();
float imgwidth = img.getWidth();
x = (pdfwidth - imgwidth) / 2;
return x;
}
示例8: scaleToFit
import com.itextpdf.text.Image; //导入方法依赖的package包/类
private static void scaleToFit(Document document, Image image) {
float scale = ((document.getPageSize().getWidth() - document.leftMargin()
- document.rightMargin()) / image.getWidth()) * 100;
image.scalePercent(scale);
}