UWInfo Blog
發表新文章
[Join] | [忘記密碼] | [Login]
搜尋

搜尋意見
文章分類-#Author#
[所有文章分類]
所有文章分類
  • ASP.NET (48)
  • ASP.NET2.0 (15)
  • ASP.NET4.0 (34)
  • JavaScript (49)
  • jQuery (26)
  • FireFox (4)
  • UW系統設定 (3)
  • SQL (39)
  • SQL 2008 (25)
  • mirror (4)
  • SVN (4)
  • IE (9)
  • IIS (20)
  • IIS6 (1)
  • 閒聊 (7)
  • W3C (6)
  • 作業系統 (9)
  • C# (24)
  • CSS (12)
  • FileServer (1)
  • HTML 5 (11)
  • CKEditor (3)
  • UW.dll (13)
  • Visual Studio (16)
  • Browser (8)
  • SEO (1)
  • Google Apps (3)
  • 網站輔助系統 (4)
  • DNS (5)
  • SMTP (4)
  • 網管 (11)
  • 社群API (3)
  • SSL (4)
  • App_Inventor (1)
  • URLRewrite (2)
  • 開發工具 (6)
  • JSON (1)
  • Excel2007 (1)
  • 試題 (3)
  • LINQ (1)
  • bootstrap (0)
  • Vue (3)
  • IIS7 (3)
  • foodpanda (2)
  • 編碼 (2)
  • 資安 (3)
  • Sourcetree (1)
  • MAUI (1)
  • CMD (1)
  • my sql (1)
最新回應
  • Newtonsoft.Json.JsonConvert.DeserializeObject 失敗的情況
    test...more
  • dotnet ef dbcontext scaffold
    ...more
  • [ASP.NET] 利用 aspnet_regiis 加密 web.config
    ...more
  • IIS ARR (reverse proxy) 服務安裝
    ...more
  • [錯誤訊息] 請加入 ScriptResourceMapping 命名的 jquery (區分大小寫)
    ...more
  • 用 Javascript 跨網頁讀取 cookie (Cookie cross page, path of cookie)
    ...more
  • 線上客服 - MSN
    本人信箱被盜用以致資料外洩,是否可以請貴平台予以協助刪除該信箱之使用謝謝囉...more
  • 插入文字到游標或選取處
    aaaaa...more
  • IIS 配合 AD (Active Directory) 認証, 使用 .Net 6.0
    太感謝你了~~~你救了我被windows 認證卡了好幾天QQ...more
  • PostgreSQL 的 monitor trigger
    FOR EACH ROW 可能要改為 FOR EACH STATEMENT ...more
標籤
  • c
  • connection
  • aspx[t]
  • [t]
  • json
  • ajax
  • 122
  • COALESCE
  • plugin
  • scaffo
  • net
  • 44
  • TLS1
  • a
  • 變更欄位
  • 654
  • 碧
  • .net
  • 536
  • asp,
  • 62
  • MScpO3NFTG
  • 72
  • iis連接數
  • Button
  • ie11
  • uw
  • ios
  • 專案 UNION A
  • 140
  • en
  • IDENTITY
  • end
  • 剪
  • [u2]
  • MaxHttpCol
  • config
  • 上傳檔案太大
  • -8908
  • for
  • 58
  • recovery O
  • NPOI 弱點
  • 桌面
  • PG
  • SVG
  • -2173
  • 56
  • db
  • download
搜尋 Pdf 結果:
PrintDocument 另存成 PDF
如果列印主機是 windows server 主機,通常會有 "Microsoft Print to PDF" 名稱的印表機
那使用 Print Document 物件另存成 PDF code 如下
pd.PrinterSettings.PrinterName = "Microsoft Print to PDF";
pd.PrinterSettings.PrintToFile = true;
pd.PrinterSettings.PrintFileName = @"C:\TEMP\XPS\" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".pdf";
More...
darren, 2025/5/12 下午 04:36:12
命名規則

名命規則

C#: 

    參數, 區域變數: 小駝峰(CamelCasing)
    其它: 大駝峰(PascalCasing)
    參考:
    
https://docs.microsoft.com/zh-tw/dotnet/standard/design-guidelines/naming-guidelines

Javascript:
    小駝峰(CamelCasing)


網址:
    全小寫, 用 - (減號) 分隔單字
    參考:

    https://www.seoseo.com.tw/article_detail_609.html
    https://blog.miniasp.com/post/2011/01/14/Avoid-using-underline-as-domain-name-character
    http://epaper.gotop.com.tw/pdf/acn023600.pdf


class 名命 HTML : 
    全小寫, 用 - (減號) 分隔單字 

複合字範列:
Pascal Camel Not
BitFlag bitFlag Bitflag
Callback callback CallBack
Canceled canceled Cancelled
DoNot doNot Don't
Email email EMail
Endpoint endpoint EndPoint
FileName fileName Filename
Gridline gridline GridLine
Hashtable hashtable HashTable
Id id ID
Indexes indexes Indices
LogOff logOff LogOut
LogOn logOn LogIn
Metadata metadata MetaData, metaData
Multipanel multipanel MultiPanel
Multiview multiview MultiView
Namespace namespace NameSpace
Ok ok OK
Pi pi PI
Placeholder placeholder PlaceHolder
SignIn signIn SignOn
SignOut signOut SignOff
UserName userName Username
WhiteSpace whiteSpace Whitespace
Writable writable Writeable
DateTimePicker dateTimePicker DatetimePicker
More...
Bike, 2020/7/28 上午 08:00:08
[ASP.NET] 利用 aspnet_regiis 加密 web.config
請用系統管理員身分 開啟 cmd.exe

cd C:\Windows\Microsoft.Net\Framework\v2.0.50727

aspnet_regiis -pef "connectionStrings" "專案路徑"


aspnet_regiis -pef "appSettings" "專案路徑"

* 若出現 'aspnet_regiis'  不是內部或外部命令,可執行的程式或批次檔

先確認iis上專案的Framework版本
cd C:\Windows\Microsoft.Net\Framework\該版本的資料夾

若為v4.0.30319
cd C:\Windows\Microsoft.Net\Framework\v4.0.30319

應該就成功了

---------------------------------------

解密的部分

aspnet_regiis -pdf "connectionStrings" "專案路徑"

aspnet_regiis -pdf "appSettings" "專案路徑"
More...
choco, 2019/5/24 下午 07:06:03
zero-width space
寫程式這麼多年,終於被這個東西給害到,所以特別提一下
zero-width space: 就是沒有寬度的空白,字元碼  \u200b , 或是 urlencode =  %e2%80%8b
當你從 word , excel ,PDF 複製文字貼到記事本,網頁textbox, 或是 visual studio
有時候會把這個碼也一起貼上,重點是: 你肉眼根本看不出來

​2017-08-15 22:05:15​ -> 2017前面有 \u200b, 尾巴也有 
2017-08-15 22:05:15 -> 這個就正常

這會造成甚麼,DateTime.Parse 就會出錯,或是對字串做 MD5 hash 會造成錯誤的結果
然後就會一直 debug 找不出原因,要用 urlencode 測看看才會現出原形
另外,這個碼也無法用 Trim() 清掉,因為他不是 Char.IsWhiteSpace 成員

所以,從 word excel pdf 或是其他網頁 copy 文字貼到程式碼做測試
如果發生怪怪的bug,可能要思考一下是不是這個字元在作怪
More...
darren, 2018/7/19 下午 12:08:41
簡單的 HTTP Relay By MVC.
客戶要求
1. 檔案只能放在 Firewall 內的後台用 Web server (Server A).
2. 使用者只能存取 DMZ 的 Web server (Server B).
3. Server B 只能用 HTTP 通過 Firewall 向 Server A 要資料.(i.e.  Server B 不能掛戴 Server A 的目錄成為虛擬目錄)

所以在 Server B 上面建立了一支程式用 HTTP 的方式讀取 Server A 的檔案再寫出去.

例如, http://ServerB/Upload/test.pdf 會讀取 http://ServerA/Upload/test.pdf 再送到 Client 端

namespace WWW.Controllers
{
    public class UploadController : Controller
    {
        // GET: Upload
        public void Index(string Filename)
        {
            //Create a stream for the file
            Stream stream = null;

            //This controls how many bytes to read at a time and send to the client
            int bytesToRead = 10000;

            // Buffer to read bytes in chunk size specified above
            byte[] buffer = new Byte[bytesToRead];

            string url = "http://admin-dev.nanya.bike.idv.tw/newnanyaback/Upload/" + Filename;

            // The number of bytes read
            try
            {
                //Create a WebRequest to get the file
                HttpWebRequest fileReq = (HttpWebRequest)HttpWebRequest.Create(url);

                //Create a response for this request
                HttpWebResponse fileResp = (HttpWebResponse)fileReq.GetResponse();

                if (fileReq.ContentLength > 0)
                    fileResp.ContentLength = fileReq.ContentLength;

                //Get the Stream returned from the response
                stream = fileResp.GetResponseStream();

                // prepare the response to the client. resp is the client Response
                var resp = HttpContext.Response;

                if (Filename.ToLower().EndsWith(".png") ||
                    Filename.ToLower().EndsWith(".jpg") ||
                    Filename.ToLower().EndsWith(".jpeg") ||
                    Filename.ToLower().EndsWith(".gif")
                    )
                {
                    resp.ContentType = "image";
                }
                else
                {
                    //Indicate the type of data being sent
                    resp.ContentType = "application/octet-stream";

                    //Name the file
                    resp.AddHeader("Content-Disposition", "attachment; filename=\"" + HttpUtility.UrlEncode(Filename, Encoding.UTF8) + "\"");
                }

                resp.AddHeader("Content-Length", fileResp.ContentLength.ToString());

                int length;
                do
                {
                    // Verify that the client is connected.
                    if (resp.IsClientConnected)
                    {
                        // Read data into the buffer.
                        length = stream.Read(buffer, 0, bytesToRead);

                        // and write it out to the response's output stream
                        resp.OutputStream.Write(buffer, 0, length);

                        // Flush the data
                        resp.Flush();

                        //Clear the buffer
                        buffer = new Byte[bytesToRead];
                    }
                    else
                    {
                        // cancel the download if client has disconnected
                        length = -1;
                    }
                } while (length > 0); //Repeat until no data is read
            }
            finally
            {
                if (stream != null)
                {
                    //Close the input stream
                    stream.Close();
                }
            }
        }
    }
}



但不是這樣就好了, 在 RouteConfig.cs 中要加上:
            routes.MapRoute(
                name: "Upload",
                url: "Upload/{filename}",
                defaults: new { controller = "Upload", action = "Index", filename = UrlParameter.Optional }
            );

此外在 Web.Config 中也要加上:

  <system.webServer>
    <handlers>
      <add name="UrlRoutingHandler_Upload"
           type="System.Web.Routing.UrlRoutingHandler, 
               System.Web, Version=4.0.0.0, 
               Culture=neutral, 
               PublicKeyToken=b03f5f7f11d50a3a"
           path="/Upload/*"
           verb="GET"/>
    </handlers>
  </system.webServer>

參考:
http://stackoverflow.com/questions/5596747/download-stream-file-from-url-asp-net

http://blog.darkthread.net/post-2014-12-05-mvc-routing-for-url-with-filename.aspx
More...
Bike, 2016/12/1 下午 09:34:30
在 PDF 加浮水印, 用 iTextSharp
找了兩三篇文章再加一點修正才組出來的,  記錄一下, 要用 iTextSharp 哦.

using System.IO;
using iTextSharp.text;
using iTextSharp.text.pdf;

---
 
            string oldFile = Server.MapPath("/Content/PDF/300000419_20160929162658862.pdf"); //"oldFile.pdf";
            string newFile = oldFile.Replace(".pdf", "_New11.pdf");

            // open the reader
            PdfReader reader = new PdfReader(oldFile);
            Rectangle size = reader.GetPageSizeWithRotation(1);
            Document document = new Document(size);
            int NumberOfPages = reader.NumberOfPages;

            // open the writer
            FileStream fs = new FileStream(newFile, FileMode.Create, FileAccess.Write);
            PdfWriter writer = PdfWriter.GetInstance(document, fs);
            document.Open();

            // the pdf content
            PdfContentByte cb = writer.DirectContent;

            string text = "Watermark...";

            string windir = Environment.GetEnvironmentVariable("windir");
            Chunk textAsChunk = new Chunk(text, new Font(BaseFont.CreateFont(windir + "\\Fonts\\mingliu.ttc,0", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED), 20, Font.NORMAL, new BaseColor(255,0,0)));

            // create the new page and add it to the pdf
            for (int i = 1; i<= NumberOfPages; i++)
            {
                if(i > 1)
                {
                    document.NewPage();
                }

                ColumnText.ShowTextAligned(cb, Element.ALIGN_LEFT, new Phrase(textAsChunk), 0, 0, 0);

                PdfImportedPage page = writer.GetImportedPage(reader, i);
                cb.AddTemplate(page, 0, 0);
            }

            // close the streams and voilá the file should be changed :)
            document.Close();
            fs.Close();
            writer.Close();
            reader.Close();

            Response.Write(newFile + "<br>");
            Response.Write(NumberOfPages + "<br>");
More...
Bike, 2016/9/29 下午 06:23:59
Html to PDF
找了一下相關工具,發現這個還不錯
http://selectpdf.com/community-edition/

免費的
這是給開發社群的,基本功能有,但是限制是只能產生 5 頁的 PDF
但5頁限制用於產生帳單,出貨單已經很夠用了
附上 .net40  的元件
 
More...
darren, 2016/3/4 下午 12:28:46
Google Chrome瀏覽器擴充套件外掛
我找到了我一直很想要的用滑鼠滑一滑就可以關掉頁面和上一頁下一頁的擴充套件啦~​​​

Smooth Gestures 

是這裡分享的>>​幸運草的吉光片羽

他還有分享其他很好用的套件,大家可以安裝來用用唷~

More...
Yuan, 2014/1/4 下午 11:43:12
漢光-夢想家DNS
這是一篇加密文章,需輸入密碼才可閱讀
More...
Reiko, 2013/3/18 下午 02:21:12
在列印前把列印的內容使用圖檔存備份
主要是使用 Printing.PreviewPrintController 的產生預覽圖片的功能來儲存列印內容, 再把圖片送到印表機, 以保証列印內容和儲存的圖檔是一致的. 值得一提的是, 在預覽時可以使用不同的印表機, 以便讓產生較小的圖檔, 否則有時會發生 GDI+ 的錯誤.

Sample 如下:

Imports System.Drawing.Printing

Namespace X
    Partial Public Class PrintSomething
        Dim PD As PrintDocument

        Dim ppc As New Printing.PreviewPrintController()

        Dim TotalPage As Int32 = 0

        ''' <summary>
        ''' 第幾次列印, 用來控制寫出的圖檔
        ''' </summary>
        ''' <remarks></remarks>
        Dim PrintCount As Int32 = 1

        Dim PageCount As Int32 = 1

            :
            :
            :
      
        Sub New(ByVal oPM As DB.PackingListMain, ByVal dtDetail As DataTable, dtUsedCoupon As DataTable)
            '初始化資料
            :
            :
            :
        End Sub

        Sub InitPrintDocument()
            '在這裡設定 PrintDocument 的紙張, 印表機, 邊界, 橫印或直印

            PD = New PrintDocument

            :
            :
            :

        End Sub

        Sub print()
            InitPrintDocument()

            PD.PrintController = ppc

           
            ' 第一次先把列印結果存在 Printing.PreviewPrintController 中
            AddHandler PD.PrintPage, AddressOf GeneratePreview

            '再來儲存圖片
            AddHandler PD.EndPrint, AddressOf SaveImage

            PD.Print()
        End Sub


        Dim ppi() As Printing.PreviewPageInfo
        Dim PrintPage As Int32 = 0

        Sub SaveImage(ByVal sender As Object, ByVal ev As PrintEventArgs)

            PrintDebug("Save Image Start, " & Now.ToString("yyyy-MM-dd HH:mm:ss.fff"))

            '把圖檔存起來
            Dim TF As String = Now.ToString("yyyyMMddHHmmss") ' DB.SysConfig.Path.LocalDataRoot
            Dim PathLocal As String = "C:\PrintLog\" & TF.Substring(0, 4) & "-" & TF.Substring(4, 2) & "\"
            Dim PathPackingListSheetImage As String = DB.SysConfig.PackingListSheetImage & TF.Substring(0, 4) & "-" & TF.Substring(4, 2) & "\"

            System.IO.Directory.CreateDirectory(PathLocal)
            System.IO.Directory.CreateDirectory(PathPackingListSheetImage)

            Dim LatestImages As String = ""
            ppi = ppc.GetPreviewPageInfo()

            For x As Integer = 0 To ppi.Length - 1
                Dim Filename As String = TF & "_" & Me.oPM.Id & "_" & x & ".png"

                ppi(x).Image.Save(PathLocal & Filename, System.Drawing.Imaging.ImageFormat.Png)
            Next


            '把圖檔印出來
            For x As Integer = 0 To ppi.Length - 1
  '建立新的 PrintDocument
                InitPrintDocument()

                If CST.WebConfig.Server_NAME = "測試主機" Then
                    UW.WU.DebugWriteLine("PrinterName: " & Me.PD.PrinterSettings.PrinterName)
                    UW.WU.DebugWriteLine("PaperSize: " & PD.DefaultPageSettings.PaperSize.PaperName)

                    PD.DocumentName = "PackingList"
                    PD.PrinterSettings.PrintFileName = "C:\PDF\PackingList" & Now.ToString("yyyyMMddHHmmss") & "_" & PrintPage & ".prn"
                    PD.PrinterSettings.PrintToFile = True

                    'PD.PrinterSettings.
                End If

                '很奇怪, 這裡不會分頁, 所以要一張一張印   
                AddHandler PD.PrintPage, AddressOf pd_PrintPage2
                PD.Print()


               PrintPage += 1

            Next
        End Sub

        Private Sub pd_PrintPage2(ByVal sender As Object, ByVal ev As PrintPageEventArgs)
            '很奇怪, 這裡不會分頁, 所以要一張一張印           
            ev.Graphics.DrawImage(ppi(PrintPage).Image, 0, 0)
            ev.HasMorePages = False
        End Sub


        Private Sub GeneratePreview(ByVal sender As Object, ByVal ev As PrintPageEventArgs)
            ' 列印內容
        End Sub

        End Class
    End Class

End Namespace

More...
Bike, 2012/5/3 下午 04:00:38
~ Uwinfo ~