myAdBanner

2013年10月28日 星期一

數字前面補0 使用sprintf

* %% - 返回百分比符號
* %b - 二進位數字
* %c - 依照 ASCII 值的字元
* %d - 帶符號十進位數字
* %e - 可續計數法(比如 1.5e+3)
* %u - 無符號十進位數字
* %f - 浮點數(local settings aware)
* %F - 浮點數(not local settings aware)
* %o - 八進位數
* %s - 字串
* %x - 十六進位數(小寫字母)
* %X - 十六進位數(大寫字母)

< ?php
$number = 123;
$txt = sprintf("With 2 decimals: %1\$.2f
With no decimals: %1\$u",$number);
echo $txt."<br>";
echo sprintf("%05d", 1); 
?>
輸出: With 2 decimals: 123.00 With no decimals: 123 00001

2013年10月21日 星期一

用jquery來控制div的顯示與隱藏





   
   
   
   

2013年10月15日 星期二

iis7 改 port

選取站台 右鍵 編輯連繫 http 80 改 8080

2013年10月8日 星期二

解決 PHP 連 MySQL 亂碼的問題

<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_wcjx_conn = "localhost";
$database_wcjx_conn = "dbName";
$username_wcjx_conn = "root";
$password_wcjx_conn = "12345678";
$wcjx_conn = mysql_pconnect($hostname_wcjx_conn, $username_wcjx_conn, $password_wcjx_conn) or trigger_error(mysql_error(),E_USER_ERROR); 
// 加上這一段就OK了
mysql_query("SET CHARACTER SET utf8",$wcjx_conn);
mysql_query("SET CHARACTER_SET_database= utf8",$wcjx_conn);
mysql_query("SET CHARACTER_SET_CLIENT= utf8",$wcjx_conn);
mysql_query("SET CHARACTER_SET_RESULTS= utf8",$wcjx_conn);
?>

2013年10月7日 星期一

itext 文字浮水印

        string sFileIn = "D:\\pdftmp\\102\\09\\10209240001.pdf";
        PdfReader reader = new PdfReader(sFileIn);
        MemoryStream ms = new MemoryStream();

        PdfStamper stamper = new PdfStamper(reader, ms);

        for (int i = 1; i <= reader.NumberOfPages; i++)
        {
            iTextSharp.text.Rectangle pageSize = reader.GetPageSizeWithRotation(i);
            PdfContentByte pdfPageContents = stamper.GetUnderContent(i);
            pdfPageContents.BeginText();
            BaseFont bfChinese = BaseFont.CreateFont(@"C:\WINDOWS\Fonts\kaiu.ttf", BaseFont.IDENTITY_V, BaseFont.NOT_EMBEDDED); //字體 標楷體直書
            //BaseFont bfChinese = BaseFont.createFont("C:\\windows\\fonts\\KAIU.TTF", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED); //字體 標楷體橫書

            pdfPageContents.SetFontAndSize(bfChinese, 14);//14 字型大小
            pdfPageContents.SetRGBColorFill(0, 0, 0); //文字顏色
            float textAngle = 0.0f; //旋轉角度
            float left = 570; //PageSize.Width / 2;
            float bottom = 700; // PapeSize.A4.Hight / 2 + 120f;
            pdfPageContents.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "版權所有翻印必究。", left, bottom, textAngle);
            //pdfPageContents.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "本內容之版權由相關機構擁有", left + 15, bottom, textAngle);
                    
            stamper.FormFlattening = true;
            stamper.Close();
            reader.Close();
            pdfPageContents.EndText();
        }
        //stamper.FormFlattening = true;
        //stamper.Close();
        FileStream fs = new FileStream("D:\\pdftmp\\102\\09\\watermarked-output.pdf", FileMode.Create, FileAccess.ReadWrite);
        BinaryWriter bw = new BinaryWriter(fs);
        bw.Write(ms.ToArray());
        fs.Close();
        bw.Close();

用此方式如產生
『此頁上有錯誤。Acrobat可能無法正確顯示頁面。請聯繫PDF文件的建立者來更正問題。』

請移除舊版檢視軟體(Adobe Reader),移除後請至「ADOBE READER」網站,下載並安裝Adobe Reader(須10.1.4以上版本)。

itext 加上圖片浮水印


        string FileLocation = "D:\\pdftmp\\102\\09\\10209240001.pdf";  //PDF原始檔路徑
        string WatermarkLocation = "D:\\www\\aspx\\cute\\water-4.png"; //浮水印圖檔路徑

        Document document = new Document();
        PdfReader pdfReader = new PdfReader(FileLocation);
        PdfStamper stamp = new PdfStamper(pdfReader, new FileStream(FileLocation.Replace(".pdf", "[temp][file].pdf"), FileMode.Create));

        iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(WatermarkLocation);
        img.SetAbsolutePosition(560, 100); // 圖片位置 (560,0 = 距離 左方,下方 位置)
        img.ScalePercent(35f);  //縮放比例

        PdfContentByte waterMark;
        for (int page = 1; page <= pdfReader.NumberOfPages; page++)
        {
            waterMark = stamp.GetOverContent(page);
            waterMark.AddImage(img);
        }
        stamp.FormFlattening = true;
        stamp.Close();
        File.Delete(FileLocation);
        File.Move(FileLocation.Replace(".pdf", "[temp][file].pdf"), FileLocation);

2013年9月22日 星期日

windows 指令大全

「開始」→「執行」指令大全

指令:gpedit.msc -----------------------群組原則
指令:sndrec32---------------------------錄音機
指令:Nslookup--------------------------IP位址偵測器
指令:explorer----------------------------開啟檔案總管
指令:logoff-------------------------------登出指令 tsshutdn-------60秒倒計時關機指令
指令:lusrmgr.msc-----------------------本地機用戶和組
指令:services.msc-----------------------本機服務設定
指令:oobe/msoobe /a-------------------檢查XP是否啟動
指令:notepad-----------------------------開啟記事本
指令:cleanmgr---------------------------磁碟垃圾整理
指令:net start messenger---------------開始信使服務
指令:compmgmt.msc-------------------電腦管理
指令:net stop messenger---------------停止信使服務
指令:conf---------------------------------啟動
指令:netmeeting dvdplay---------------DVD播放器 charmap--------啟動字元對應表
指令:diskmgmt.msc---------------------磁牒管理實用程序
指令:calc----------------------------------啟動電子計算器
指令:dfrg.msc----------------------------磁碟重組工具
指令:chkdsk.exe-------------------------Chkdsk磁牒檢查
指令:devmgmt.msc--------------------- 裝置管理員
指令:drwtsn32--------------------------- 系統醫生
指令:rononce -p -------------------------15秒關機
指令:dxdiag-------------------------------檢查DirectX資訊
指令:regedt32-----------------------------註冊表編輯器
指令:Msconfig.exe-----------------------系統配置實用程序
指令:rsop.msc-----------------------------群組原則結果集
指令:mem.exe------------------------------顯示記憶體使用情況
指令:regedit.exe--------------------------------註冊表
指令:winchat-----------------------------------XP自帶區域網路聊天
指令:progman-----------------------------------程序管理器
指令:winmsd-------------------------------系統資訊
指令: perfmon.msc-------------------------電腦效能監測程序
指令:winver-----------------------------------檢查Windows版本
指令:sfc /scannow-------------------------------掃瞄錯誤並復原
指令:taskmgr------------------------------工作管理器(2000/xp/-2003)
指令:eventvwr.msc----------------------------------事件檢視器
指令:secpol.msc-------------------------------------本機安全性設定
指令:rsop.msc-----------------------------------原則的結果集
指令:ntbackup--------------------------------啟動制作備份還原嚮導
指令:mstsc----------------------------------------遠端桌面
指令:wmimgmt.msc---------------------開啟windows管理體系結構WMI)
指令:wupdmgr----------------------------------windows更新程序
指令:wscript------------------------------------windows指令碼宿主設定
指令:write---------------------------------------------寫字板
指令:wiaacmgr-----------------------------------掃瞄儀和照相機嚮導
指令:winchat----------------------------------------XP原有的區域網路聊天
指令:mplayer2----------------------------------------------簡易
指令:widnows media player mspaint-----------------------------畫圖板
指令:mstsc-----------------------------------------------遠端桌面連接
指令:mplayer2--------------------------------------------媒體播放機
指令:magnify--------------------------------------------放大鏡實用程序
指令:mmc-------------------------------------------------------開啟控制台
指令:mobsync-----------------------------------------------------同步指令
指令:dfrg.msc-----------------------------------------------磁碟重組程式
指令:dcomcnfg-----------------------------------------開啟系統元件服務
指令:ddeshare----------------------------------------------------開啟DDE共享設定
指令:dvdplay----------------------------------------------------DVD播放器
指令:nslookup-------------------------------------------網路管理的工具嚮導
指令:ntbackup---------------------------------------------系統制作備份和還原
指令:narrator------------------------------------------------螢幕「講述人」
指令:ntmsmgr.msc-----------------------------------------------移動存儲管理器
指令:ntmsoprq.msc-------------------------------------移動存儲管理員操作請求
指令:netstat -an------------------------------------------(TC)指令檢查連接
指令:syncapp----------------------------------------------------新增一個公文包
指令:sysedit------------------------------------------------系統配置編輯器
指令:sigverif---------------------------------------文件簽名驗證程序
指令:shrpubw-------------------------------------------新增共用資料夾
指令:secpol.msc-------------------------------------------本機安全原則
指令:syskey----------系統加密,一旦加密就不能解開,保護windows xp系統的雙重密碼
指令:Sndvol32------------------------------------音量控制程序
指令:sfc.exe--------------------------------------系統檔案檢查器
指令:sfc /scannow---------------------------------windows文件保護
指令:tourstart--------------------------------xp簡介(安裝完成後出現的漫遊xp程序)
指令:taskmgr----------------------------------------------工作管理器
指令:eventvwr----------------------------------------------事件檢視器
指令:eudcedit------------------------------------------------造字程序
指令:explorer---------------------------------------開啟檔案總管
指令:packager--------------------------------------對像包裝程序
指令:regsvr32 /u *.dll-----------------------------------停止dll文件執行
指令:regsvr32 /u zipfldr.dll-------------------------------取消ZIP支持
指令:cmd.exe-----------------------------------CMD命令提示字元
指令:chkdsk.exe----------------------------------Chkdsk磁牒檢查
指令:certmgr.msc----------------------------證書管理實用程序
指令:calc---------------------------------------------------啟動計算器
指令:cliconfg-------------------------------------SQL SERVER 客戶端網路實用程序
指令:Clipbrd----------------------------------------------剪貼板檢視器
指令:netmeeting compmgmt.msc-----------------------------------電腦管理
指令:ciadv.msc-------------------------------------索引服務程序
指令:osk--------------------------------------------------開啟螢幕小鍵盤
指令:odbcad32-----------------------------ODBC資料來源管理器
指令:iexpress----------------------------------------木馬元件服務工具,系統原有的
指令:fsmgmt.msc-------------------------------------共用資料夾管理器
指令:utilman-----------------------------------------------協助工具管理器
指令:Clipbrd------------------------------剪貼板檢視器
指令:packager------------------------------------------------對像包裝程序
指令:sfc /scannow--------------------------------------------windows文件保護