javascript replace:
var tel = "#0-9#80-123456#";
var telTemp = tel.replace(/\#|\-/g,""); //replace 掉 # , -
alert(tel + " , " + telTemp); //#0-9#80-123456# , 0980123456
2016年2月25日 星期四
2016年2月15日 星期一
itext image to pdf 大小設定
Document document = new Document();
String filePath = "D:/J089/J089-workspace/SimpleTest/pdf/temp/tmp.pdf";
PdfWriter.getInstance(document, new FileOutputStream(filePath));
document.open();
Image image1 = Image.getInstance(imgPath);
方法一:
float pageWidth = document.getPageSize().getWidth();
float leftMargin = document.leftMargin();
float rightMargin = document.rightMargin();
float imageWidth = image1.getWidth();
float scaler = (( pageWidth - leftMargin - rightMargin ) / imageWidth ) * 100;
image1.scalePercent(scaler);
方法二:
float documentWidth = document.getPageSize().getWidth() - document.leftMargin() - document.rightMargin();
float documentHeight = document.getPageSize().getHeight() - document.topMargin() - document.bottomMargin();
image1.scaleToFit(documentWidth, documentHeight);
document.add(image1);
document.close();
訂閱:
文章 (Atom)