本文整理匯總了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);
}