مطالب
استخراج تصاویر داخل یک فایل pdf با استفاده از کتابخانه iTextSharp
کتابخانه iTextSharp کتابخانه‌ای بسیار قوی و معروف، جهت کار با فایل‌های pdf می‌باشد. کارهایی از قبیل ساخت و ویرایش و تبدیل فایل‌های pdf با این کتابخانه قدرتمند به راحتی محیا است.
گاهی نیاز داریم تا اطلاعاتی را از داخل یک فایل pdf استخراج کنیم. ما الان می‌خواهیم کل تصاویر موجود در یک فایل pdf را استخراج کنیم.
ابتدا باید فایل pdf را باز کنیم. با استفاده از کلاس PdfReader اینکار امکان پذیر می‌شود. سپس باید تعداد کل صفحات را خوانده و بر روی آنها تکرار کنیم و اطلاعات مورد نیاز را پردازش کنیم. 
var pdfReader = new PdfReader(pdfFile);
for (var pageNumber = 1; pageNumber <= pdfReader.NumberOfPages; pageNumber++)
  {
      var pdf = new PdfReader(pdfFile);
      var pg = pdf.GetPageN(pageNumber);
       // process page
  }
اکنون ما در حلقه به صفحات دسترسی داریم و به ازای هر صفحه لیست منابع توکار آن صفحه را دریافت میکنیم: 
var pdf = new PdfReader(pdfFile);
var pg = pdf.GetPageN(pageNumber);
var res = (PdfDictionary)PdfReader.GetPdfObject(pg.Get(PdfName.RESOURCES));
var xobj = (PdfDictionary)PdfReader.GetPdfObject(res.Get(PdfName.XOBJECT));
if (xobj == null) continue;
foreach (var name in xobj.Keys)
 {
    var obj = xobj.Get(name);
     if (obj.IsIndirect())
    {
        // process obj ...
    }
}
حالا باید آبجکتهایی که تصویر هستند را به image تبدیل کنیم .
var tg = (PdfDictionary)PdfReader.GetPdfObject(obj);
var width = tg.Get(PdfName.WIDTH).ToString();
var height = tg.Get(PdfName.HEIGHT).ToString();
ImageRenderInfo  imgRi = ImageRenderInfo.CreateForXObject(new Matrix(float.Parse(width), float.Parse(height)), (PRIndirectReference)obj, tg);
حال یک ImageRenderInfo داریم که باید در دیسک ذخیره کنیم. این کار را در یک متد مجزا انجام می‌دهیم.
private  void RenderImage(ImageRenderInfo renderInfo, string imgPath)
    {
            var image = renderInfo.GetImage();
            using (var dotnetImg = image.GetDrawingImage())
            {
                if (dotnetImg == null) return;

                using (var ms = new MemoryStream())
                {
                    dotnetImg.Save(ms, ImageFormat.Jpeg);
                    var d = new Bitmap(dotnetImg);
                    d.Save(imgPath);
               }
       }
 }
کد نهایی به صورت زیر می‌باشد:
private void ExtractImage(string pdfFile, string imgPath)
{
    var fileCounter = 0;
    var pdfReader = new PdfReader(pdfFile);
    for (var pageNumber = 1; pageNumber <= pdfReader.NumberOfPages; pageNumber++)
    {
        var pdf = new PdfReader(pdfFile);
        var pg = pdf.GetPageN(pageNumber);
        var res = (PdfDictionary)PdfReader.GetPdfObject(pg.Get(PdfName.RESOURCES));
        var xobj = (PdfDictionary)PdfReader.GetPdfObject(res.Get(PdfName.XOBJECT));
        if (xobj == null) continue;
            foreach (var name in xobj.Keys)
            {
                var obj = xobj.Get(name);
                if (obj.IsIndirect())
                {
                    var tg = (PdfDictionary)PdfReader.GetPdfObject(obj);
                    var width = tg.Get(PdfName.WIDTH).ToString();
                    var height = tg.Get(PdfName.HEIGHT).ToString();
                    var imgRi = ImageRenderInfo.CreateForXObject(new Matrix(float.Parse(width), float.Parse(height)), (PRIndirectReference)obj, tg);
                    fileCounter++;
                    RenderImage(imgRi, imgPath + fileCounter + ".jpeg");
                }
            }
    }
}
و به شکل زیر آن را فراخوانی میکنیم.
var path = @"C:\";
var fileName = "1.pdf";

var outPath = path + fileName + @"_extractedImgs\";
Directory.CreateDirectory(outPath);

ExtractImage(path + fileName, outPath);
اشتراک‌ها
کلاس های Mixin در Typescript 2.2

A mixin class is a class that implements a distinct aspect of functionality. Other classes can then include the mixin and access its methods and properties. That way, mixins provide a form of code reuse that is based on composing behavior. 

کلاس های Mixin در Typescript 2.2
اشتراک‌ها
دوره ساخت Minimal APIs در NET 7.

Learn Minimal APIs in .NET 7
Learn how to build Minimal APIs in .NET 7 with hands-on course. By the end of the course, you will be able to build well-constructed Minimal API Endpoints using C#, .NET7, and Swagger.

⭐️ Contents ⭐️
⌨️ (0:00:00) Introduction
⌨️ (0:01:30) Topics Covered
⌨️ (0:02:47) Why Minimal API?
⌨️ (0:06:07) Create Project
⌨️ (0:07:57) Comparing Files Minimal vs Standard
⌨️ (0:11:05) Program file changes
⌨️ (0:13:50) Clean Program class file
⌨️ (0:16:02) API Basics
⌨️ (0:16:44) What is API?
⌨️ (0:21:11) Request and response
⌨️ (0:25:59) Request Object
⌨️ (0:30:12) Response Object
⌨️ (0:35:36) httpverb
⌨️ (0:40:38) Create First Endpoint
⌨️ (0:43:43) Return Types
⌨️ (0:46:15) Route Parameters
⌨️ (0:48:29) Create Coupon Model and Coupon Store
⌨️ (0:51:38) Get All Endpoint
⌨️ (0:53:09) Get Individual Coupon
⌨️ (0:55:19) Create Coupon
⌨️ (0:59:53) Name Endpoints
⌨️ (1:03:17) Products and Accepts in Minimal API
⌨️ (1:06:58) Dependency Injection in Minimal API
⌨️ (1:10:25) Add DTOs
⌨️ (1:13:56) AutoMapper and Dependency Injection
⌨️ (1:18:32) Fluent Validators
⌨️ (1:24:07) Async Endpoints
⌨️ (1:26:11) API Response
⌨️ (1:32:57) Assignment - Put and Delete
⌨️ (1:33:49) Assignment Solution - Put and Delete Endpoints 

دوره ساخت Minimal APIs در NET 7.
اشتراک‌ها
Tools for Apache Cordova - مثال ها و مستندات
Open source code is the norm for so many developers these days, and unsurprisingly, so is open documentation. From Azure to TypeScript, public repositories have become a go-to place for sharing samples, tutorials, and “tips and tricks” so that everyone can learn and contribute together as a community.
Tools for Apache Cordova - مثال ها و مستندات
اشتراک‌ها
کتابخانه jquery-popdown
What is a popdown? It's a simple dialog that pops down from the top of your browser window once it's loaded HTML in the background. A simple way to load web forms, content, user feedback messages, media and any other in place style content. It's lightweight (4kb) and fast.  Demo
کتابخانه jquery-popdown
اشتراک‌ها
حداقل‌ نیازهای مدیریت یک پروژه‌ی بزرگ

Basic Things

After working on the initial stages of several largish projects, I accumulated a list of things that share the following three properties:

  • they are irrelevant while the project is small,
  • they are a productivity multiplier when the project is large,
  • they are much harder to introduce down the line.

حداقل‌ نیازهای مدیریت یک پروژه‌ی بزرگ
اشتراک‌ها
C# در مرورگر با Blazor

 Blazor is the new Microsoft experimental framework that brings C# into any browser without a plug-in. It holds the promise of modern single-page applications, combined with the ability to use C# and its vast base-class library. Blazor takes C# development to a new level. It’s the final piece necessary to make the language a full-stack development tool. It will have all the power of the popular JavaScript frameworks, but based on the familiar languages, APIs and tooling of the Microsoft .NET Framework. 

C# در مرورگر با Blazor
اشتراک‌ها
نقشه ذهنی #C

This blog post contains a mind map of language features starting from C# 1 up til now - including some of the new C# 12 features that will be released in November 2023.

نقشه ذهنی #C