Posts

Showing posts from January, 2010
555 KUBIK | facade projection | from urbanscreen on Vimeo .

Free PDF generator library for C#

i TextSharp                            Download the iTextSharp library http://sourceforge.net/projects/itextsharp/ Documentation http://itextsharp.sourceforge.net/tutorial/index.html Example from SinhalaGospel.com private void GeneratePdf(int contID) { string path = ""; Document document = new Document(); try { cGospel gospel = new cGospel(); tbl_Gospel dtCont = gospel.GetContent(contID); string contentID = dtCont.ContentID.ToString(); string gospelTitle = dtCont.Gospel; string chapterID = dtCont.ChapterID.Value.ToString(); string titleID = dtCont.TitleID.ToString(); string title = dtCont.Title;                 string content = dtCont.Content; path = "../Contents/"+gospelTitle+"_"+chapterID+"_"+titleID+".pdf"; PdfWriter.GetInstance(document, new FileStream(Server.MapPath(path), Fil...

Scale Down Images in C#

1) open a file stream         FileStream fs = File.OpenRead(fullImgPath); 2) load the image         Image fullImg = Image.FromStream(fs); 3) define the new height         int thHeight = Convert.ToInt32(ConfigurationManager.AppSettings["thumbHeight"]); 4) define a callback function when thumbnail abort         Image.GetThumbnailImageAbort dummyCallback=new Image.GetThumbnailImageAbort(ThumbnailCallback); 5) set the new height and width of the image using GetThumbnailImage function         Image thumbImg = fullImg.GetThumbnailImage((int)(fullImg.Width * thHeight) / fullImg.Height, thHeight, dummyCallback, IntPtr.Zero); 6) save the thumb image         thumbImg.Save(thumbImgpath); 7) dispose         thumbImg.Dispose(); 8) the call back function implementation public static bool ThumbnailCallback() { return false; }