966 lines
36 KiB
HTML
966 lines
36 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="fa" dir="rtl">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title>راهنمای یکپارچهسازی OfficeIMO در XPowerPointFileContentExtractor | پروژه xAiApi</title>
|
||
<style>
|
||
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800&display=swap');
|
||
|
||
:root {
|
||
--primary: #1a365d;
|
||
--primary-light: #2c5282;
|
||
--accent: #c9a961;
|
||
--accent-dark: #a8893f;
|
||
--bg: #faf9f6;
|
||
--card-bg: #ffffff;
|
||
--text: #1a202c;
|
||
--text-muted: #4a5568;
|
||
--border: #e2e8f0;
|
||
--success: #38a169;
|
||
--danger: #e53e3e;
|
||
--warning: #dd6b20;
|
||
--shadow: 0 4px 6px rgba(0,0,0,0.05), 0 10px 30px rgba(26,54,93,0.08);
|
||
}
|
||
|
||
* { box-sizing: border-box; margin: 0; padding: 0; }
|
||
|
||
body {
|
||
font-family: 'Vazirmatn', Tahoma, sans-serif;
|
||
background: var(--bg);
|
||
color: var(--text);
|
||
line-height: 1.9;
|
||
font-size: 15px;
|
||
padding: 30px 15px;
|
||
}
|
||
|
||
.document-container {
|
||
max-width: 950px;
|
||
margin: 0 auto;
|
||
background: var(--card-bg);
|
||
box-shadow: var(--shadow);
|
||
border-radius: 12px;
|
||
overflow: hidden;
|
||
}
|
||
|
||
.document-header {
|
||
background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
|
||
color: white;
|
||
padding: 50px 40px 40px;
|
||
position: relative;
|
||
border-bottom: 4px solid var(--accent);
|
||
}
|
||
|
||
.document-header::before {
|
||
content: '';
|
||
position: absolute;
|
||
top: 0; right: 0;
|
||
width: 200px; height: 200px;
|
||
background: radial-gradient(circle, rgba(201,169,97,0.15) 0%, transparent 70%);
|
||
border-radius: 50%;
|
||
transform: translate(50%, -50%);
|
||
}
|
||
|
||
.header-top {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
margin-bottom: 30px;
|
||
position: relative;
|
||
z-index: 1;
|
||
}
|
||
|
||
.company-badge {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 12px;
|
||
}
|
||
|
||
.company-logo {
|
||
width: 60px; height: 60px;
|
||
background: var(--accent);
|
||
border-radius: 12px;
|
||
box-shadow: 0 4px 12px rgba(0,0,0,0.2);
|
||
}
|
||
|
||
.doc-meta {
|
||
text-align: left;
|
||
font-size: 12px;
|
||
opacity: 0.9;
|
||
}
|
||
|
||
.doc-meta div { margin-bottom: 3px; }
|
||
|
||
.document-title {
|
||
text-align: center;
|
||
position: relative;
|
||
z-index: 1;
|
||
padding: 20px 0;
|
||
}
|
||
|
||
.document-title .label {
|
||
display: inline-block;
|
||
background: rgba(201,169,97,0.2);
|
||
color: var(--accent);
|
||
padding: 4px 16px;
|
||
border-radius: 20px;
|
||
font-size: 12px;
|
||
font-weight: 600;
|
||
margin-bottom: 15px;
|
||
border: 1px solid rgba(201,169,97,0.4);
|
||
}
|
||
|
||
.document-title h1 {
|
||
font-size: 28px;
|
||
font-weight: 800;
|
||
margin-bottom: 10px;
|
||
letter-spacing: -0.5px;
|
||
}
|
||
|
||
.document-title h2 {
|
||
font-size: 16px;
|
||
font-weight: 400;
|
||
opacity: 0.9;
|
||
}
|
||
|
||
.document-body {
|
||
padding: 40px;
|
||
}
|
||
|
||
.intro-text {
|
||
background: linear-gradient(to left, #f7fafc, #edf2f7);
|
||
border-right: 4px solid var(--accent);
|
||
padding: 20px 25px;
|
||
border-radius: 8px;
|
||
margin-bottom: 35px;
|
||
font-size: 14px;
|
||
color: var(--text-muted);
|
||
}
|
||
|
||
.section {
|
||
margin-bottom: 40px;
|
||
page-break-inside: avoid;
|
||
}
|
||
|
||
.section-header {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 15px;
|
||
padding-bottom: 12px;
|
||
border-bottom: 2px solid var(--border);
|
||
margin-bottom: 20px;
|
||
}
|
||
|
||
.section-number {
|
||
width: 50px; height: 50px;
|
||
background: linear-gradient(135deg, var(--primary), var(--primary-light));
|
||
color: white;
|
||
border-radius: 12px;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
font-weight: 800;
|
||
font-size: 20px;
|
||
flex-shrink: 0;
|
||
box-shadow: 0 4px 10px rgba(26,54,93,0.2);
|
||
}
|
||
|
||
.section-title { flex: 1; }
|
||
|
||
.section-title h3 {
|
||
font-size: 19px;
|
||
font-weight: 700;
|
||
color: var(--primary);
|
||
margin-bottom: 2px;
|
||
}
|
||
|
||
.section-title .subtitle {
|
||
font-size: 12px;
|
||
color: var(--text-muted);
|
||
}
|
||
|
||
.section-content {
|
||
padding-right: 10px;
|
||
}
|
||
|
||
.section-content p {
|
||
margin-bottom: 12px;
|
||
text-align: justify;
|
||
text-indent: 20px;
|
||
}
|
||
|
||
.section-content p.no-indent { text-indent: 0; }
|
||
|
||
.highlight-box {
|
||
background: linear-gradient(to left, #fffaf0, #fef5e7);
|
||
border: 1px solid #f6e05e;
|
||
border-right: 4px solid var(--accent);
|
||
padding: 18px 22px;
|
||
border-radius: 8px;
|
||
margin: 20px 0;
|
||
font-size: 14px;
|
||
}
|
||
|
||
.highlight-box strong { color: var(--accent-dark); }
|
||
|
||
.info-box {
|
||
background: linear-gradient(to left, #ebf8ff, #e6f6ff);
|
||
border: 1px solid #90cdf4;
|
||
border-right: 4px solid var(--primary-light);
|
||
padding: 18px 22px;
|
||
border-radius: 8px;
|
||
margin: 20px 0;
|
||
font-size: 14px;
|
||
}
|
||
|
||
.success-box {
|
||
background: linear-gradient(to left, #f0fff4, #e6fffa);
|
||
border: 1px solid #9ae6b4;
|
||
border-right: 4px solid var(--success);
|
||
padding: 18px 22px;
|
||
border-radius: 8px;
|
||
margin: 20px 0;
|
||
font-size: 14px;
|
||
}
|
||
|
||
.warning-box {
|
||
background: linear-gradient(to left, #fffaf0, #fef5e7);
|
||
border: 1px solid #fbd38d;
|
||
border-right: 4px solid var(--warning);
|
||
padding: 18px 22px;
|
||
border-radius: 8px;
|
||
margin: 20px 0;
|
||
font-size: 14px;
|
||
}
|
||
|
||
.styled-table {
|
||
width: 100%;
|
||
border-collapse: collapse;
|
||
margin: 20px 0;
|
||
background: white;
|
||
border-radius: 8px;
|
||
overflow: hidden;
|
||
box-shadow: 0 2px 8px rgba(0,0,0,0.05);
|
||
}
|
||
|
||
.styled-table thead {
|
||
background: linear-gradient(135deg, var(--primary), var(--primary-light));
|
||
color: white;
|
||
}
|
||
|
||
.styled-table th {
|
||
padding: 14px 16px;
|
||
text-align: right;
|
||
font-weight: 600;
|
||
font-size: 13px;
|
||
}
|
||
|
||
.styled-table td {
|
||
padding: 13px 16px;
|
||
border-bottom: 1px solid var(--border);
|
||
font-size: 13px;
|
||
}
|
||
|
||
.styled-table tbody tr:last-child td { border-bottom: none; }
|
||
.styled-table tbody tr:nth-child(even) { background: #f8fafc; }
|
||
|
||
.styled-table .highlight-row {
|
||
background: #fffaf0 !important;
|
||
font-weight: 600;
|
||
}
|
||
|
||
.conclusion-box {
|
||
background: linear-gradient(135deg, var(--primary), var(--primary-light));
|
||
color: white;
|
||
padding: 30px;
|
||
border-radius: 12px;
|
||
margin: 30px 0;
|
||
text-align: center;
|
||
box-shadow: 0 8px 20px rgba(26,54,93,0.3);
|
||
}
|
||
|
||
.conclusion-box h3 {
|
||
font-size: 22px;
|
||
font-weight: 800;
|
||
margin-bottom: 15px;
|
||
color: var(--accent);
|
||
}
|
||
|
||
.conclusion-box p {
|
||
font-size: 14px;
|
||
line-height: 1.8;
|
||
text-indent: 0 !important;
|
||
margin-bottom: 15px;
|
||
}
|
||
|
||
.conclusion-box .highlight {
|
||
background: rgba(201,169,97,0.2);
|
||
padding: 15px 20px;
|
||
border-radius: 8px;
|
||
margin-top: 20px;
|
||
border: 1px solid rgba(201,169,97,0.4);
|
||
}
|
||
|
||
.document-footer {
|
||
background: var(--primary);
|
||
color: white;
|
||
padding: 25px 40px;
|
||
text-align: center;
|
||
font-size: 12px;
|
||
margin-top: 40px;
|
||
}
|
||
|
||
.document-footer .footer-brand {
|
||
font-weight: 700;
|
||
color: var(--accent);
|
||
margin-bottom: 5px;
|
||
font-size: 14px;
|
||
}
|
||
|
||
.footer-divider {
|
||
width: 60px;
|
||
height: 2px;
|
||
background: var(--accent);
|
||
margin: 10px auto;
|
||
}
|
||
|
||
.page-info {
|
||
text-align: center;
|
||
padding: 15px;
|
||
font-size: 11px;
|
||
color: var(--text-muted);
|
||
border-top: 1px solid var(--border);
|
||
margin-top: 30px;
|
||
}
|
||
|
||
code {
|
||
font-family: 'Consolas', 'Monaco', monospace;
|
||
background: #edf2f7;
|
||
padding: 2px 6px;
|
||
border-radius: 4px;
|
||
font-size: 12px;
|
||
direction: ltr;
|
||
display: inline-block;
|
||
}
|
||
|
||
pre {
|
||
background: #1a202c;
|
||
color: #e2e8f0;
|
||
padding: 18px 20px;
|
||
border-radius: 8px;
|
||
overflow-x: auto;
|
||
direction: ltr;
|
||
text-align: left;
|
||
font-size: 12px;
|
||
line-height: 1.7;
|
||
margin: 15px 0;
|
||
font-family: 'Consolas', 'Monaco', monospace;
|
||
}
|
||
|
||
.step-list { list-style: none; padding: 0; counter-reset: step; }
|
||
.step-list > li {
|
||
position: relative;
|
||
padding: 18px 55px 18px 20px;
|
||
margin-bottom: 12px;
|
||
background: #f8fafc;
|
||
border: 1px solid var(--border);
|
||
border-radius: 8px;
|
||
counter-increment: step;
|
||
}
|
||
.step-list > li::before {
|
||
content: counter(step);
|
||
position: absolute;
|
||
right: 15px;
|
||
top: 18px;
|
||
width: 28px; height: 28px;
|
||
background: var(--primary);
|
||
color: white;
|
||
border-radius: 50%;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
font-weight: 700;
|
||
font-size: 13px;
|
||
}
|
||
.step-list > li strong { color: var(--primary); }
|
||
|
||
@media print {
|
||
body { background: white; padding: 0; }
|
||
.document-container { box-shadow: none; border-radius: 0; }
|
||
.section { page-break-inside: avoid; }
|
||
}
|
||
|
||
@media (max-width: 768px) {
|
||
.document-body { padding: 25px 20px; }
|
||
.document-header { padding: 30px 20px; }
|
||
.header-top { flex-direction: column; gap: 15px; }
|
||
.doc-meta { text-align: center; }
|
||
}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
|
||
<div class="document-container">
|
||
|
||
<header class="document-header">
|
||
<div class="header-top">
|
||
<div class="company-badge">
|
||
<div class="company-logo"></div>
|
||
</div>
|
||
<div class="doc-meta">
|
||
<div>شماره مستند: TECH-1405-035</div>
|
||
<div>نسخه: ۱.۰</div>
|
||
<div>تاریخ تهیه: ۱ آبان ۱۴۰۵</div>
|
||
<div>طبقهبندی: محرمانه</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="document-title">
|
||
<span class="label">INTEGRATION GUIDE</span>
|
||
<h1>یکپارچهسازی OfficeIMO در XPowerPointFileContentExtractor</h1>
|
||
<h2>راهنمای گامبهگام تکمیل پشتیبانی از فرمتهای قدیمی PowerPoint در سامانه xAiApi</h2>
|
||
</div>
|
||
</header>
|
||
|
||
<div class="document-body">
|
||
|
||
<div class="intro-text">
|
||
<strong>به کارفرمای محترم،</strong><br>
|
||
این مستند حاصل بررسی و طراحی راهحل برای تکمیل پیادهسازی <code>XPowerPointFileContentExtractor</code> در پروژه xAiApi است. پس از مواجهه با محدودیت کتابخانه NPOI در پردازش فرمتهای قدیمی PowerPoint (`.ppt`, `.pot`, `.pps`)، کتابخانه <strong>OfficeIMO.PowerPoint</strong> بهعنوان یک راهحل متنباز، رایگان (MIT) و Cross-platform انتخاب شده است. این مستند مراحل نصب، یکپارچهسازی با کد موجود، بازنویسی متد <code>ExtractLegacyAsync</code> و ملاحظات استقرار در Docker/Linux را بهصورت گامبهگام شرح میدهد.
|
||
</div>
|
||
|
||
<div class="section">
|
||
<div class="section-header">
|
||
<div class="section-number">۱</div>
|
||
<div class="section-title">
|
||
<h3>خلاصه اجرایی</h3>
|
||
<div class="subtitle">Executive Summary</div>
|
||
</div>
|
||
</div>
|
||
<div class="section-content">
|
||
<p>پیادهسازی اولیه <code>XPowerPointFileContentExtractor</code> با استفاده از <code>DocumentFormat.OpenXml</code> برای فرمتهای مدرن (`.pptx`, `.ppsx`, `.potx`, `.pptm`, `.ppsm`, `.potm`) با موفقیت انجام شده است. اما برای سه فرمت قدیمی (`.ppt`, `.pot`, `.pps`)، کتابخانه NPOI (حتی با بسته ScratchPad) کلاس سطح بالای <code>HSLFSlideShow</code> را ارائه نمیدهد و پیادهسازی را با شکست مواجه کرده است.</p>
|
||
|
||
<p>کتابخانه <strong>OfficeIMO.PowerPoint</strong> با مجوز MIT، بدون وابستگی به Microsoft Office یا COM، و با پشتیبانی صریح از فرمتهای قدیمی PowerPoint 97-2003، جایگزین مناسب و کاملاً رایگانی است که میتواند این شکاف را پر کند.</p>
|
||
|
||
<div class="highlight-box">
|
||
<strong>نتیجه کلیدی:</strong> با جایگزینی بخش Legacy در <code>XPowerPointFileContentExtractor</code> با OfficeIMO.PowerPoint، پوشش کامل ۹ فرمت PowerPoint (۶ فرمت مدرن + ۳ فرمت قدیمی) بدون هیچ وابستگی تجاری و با قابلیت اجرا در Docker/Linux محقق میشود.
|
||
</div>
|
||
|
||
<table class="styled-table">
|
||
<thead>
|
||
<tr>
|
||
<th>محور</th>
|
||
<th>وضعیت فعلی</th>
|
||
<th>پس از یکپارچهسازی OfficeIMO</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td>پشتیبانی از فرمتهای مدرن (.pptx و ...)</td>
|
||
<td style="color: var(--success); font-weight: 600;">✓ با OpenXml</td>
|
||
<td style="color: var(--success); font-weight: 600;">✓ بدون تغییر</td>
|
||
</tr>
|
||
<tr>
|
||
<td>پشتیبانی از فرمتهای قدیمی (.ppt, .pot, .pps)</td>
|
||
<td style="color: var(--danger); font-weight: 600;">✗ (NPOI ناقص)</td>
|
||
<td style="color: var(--success); font-weight: 600;">✓ با OfficeIMO</td>
|
||
</tr>
|
||
<tr>
|
||
<td>مجوز</td>
|
||
<td>—</td>
|
||
<td style="color: var(--success); font-weight: 600;">MIT (رایگان)</td>
|
||
</tr>
|
||
<tr>
|
||
<td>Cross-platform (Linux/Docker)</td>
|
||
<td>—</td>
|
||
<td style="color: var(--success); font-weight: 600;">✓ پشتیبانی رسمی</td>
|
||
</tr>
|
||
<tr class="highlight-row">
|
||
<td><strong>آمادگی تولیدی</strong></td>
|
||
<td>متوسط</td>
|
||
<td style="color: var(--success); font-weight: 700; font-size: 15px;">بالا</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="section">
|
||
<div class="section-header">
|
||
<div class="section-number">۲</div>
|
||
<div class="section-title">
|
||
<h3>معرفی OfficeIMO.PowerPoint</h3>
|
||
<div class="subtitle">OfficeIMO.PowerPoint Overview</div>
|
||
</div>
|
||
</div>
|
||
<div class="section-content">
|
||
<p>OfficeIMO یک خانواده از کتابخانههای .NET برای کار با اسناد Office است که بهصورت کامل بدون نیاز به Microsoft Office یا COM کار میکند. ماژول <code>OfficeIMO.PowerPoint</code> بهطور اختصاصی برای ایجاد و ویرایش فایلهای PowerPoint طراحی شده و طبق مستندات رسمی، از فرمتهای قدیمی نیز پشتیبانی میکند.</p>
|
||
|
||
<div class="info-box">
|
||
<strong>💡 نکته کلیدی:</strong> طبق مستندات رسمی OfficeIMO، این کتابخانه “از زیرمجموعههای مستندشده فرمتهای قدیمی <code>.ppt</code>، <code>.pot</code> و <code>.pps</code> پشتیبانی میکند” و میتواند محتوای پشتیبانیشده را به مدل قابل ویرایش وارد کند[reference:0]. همچنین پلتفرمهای Linux و Docker بهطور رسمی پشتیبانی میشوند[reference:1].
|
||
</div>
|
||
|
||
<h4 style="margin-top: 25px; color: var(--primary); font-size: 16px;">مزایای کلیدی برای پروژه xAiApi</h4>
|
||
|
||
<table class="styled-table">
|
||
<thead>
|
||
<tr>
|
||
<th>ویژگی</th>
|
||
<th>توضیح</th>
|
||
<th>ارزش برای پروژه</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td>مجوز MIT</td>
|
||
<td>رایگان برای استفاده تجاری</td>
|
||
<td style="color: var(--success); font-weight: 600;">بدون هزینه لایسنس</td>
|
||
</tr>
|
||
<tr>
|
||
<td>COM-free</td>
|
||
<td>بدون نیاز به نصب Office</td>
|
||
<td style="color: var(--success); font-weight: 600;">مناسب Docker/Linux</td>
|
||
</tr>
|
||
<tr>
|
||
<td>پشتیبانی از .ppt/.pot/.pps</td>
|
||
<td>پردازش فرمتهای قدیمی 97-2003</td>
|
||
<td style="color: var(--success); font-weight: 600;">تکمیل پوشش فرمتها</td>
|
||
</tr>
|
||
<tr>
|
||
<td>API سطح بالا</td>
|
||
<td>مدل شیءگرا مشابه OpenXml</td>
|
||
<td style="color: var(--success); font-weight: 600;">یادگیری و استفاده آسان</td>
|
||
</tr>
|
||
<tr>
|
||
<td>پشتیبانی از Linux/Docker</td>
|
||
<td>اجرا در محیطهای کانتینری</td>
|
||
<td style="color: var(--success); font-weight: 600;">استقرار بدون تغییر</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="section">
|
||
<div class="section-header">
|
||
<div class="section-number">۳</div>
|
||
<div class="section-title">
|
||
<h3>نصب و راهاندازی</h3>
|
||
<div class="subtitle">Installation & Setup</div>
|
||
</div>
|
||
</div>
|
||
<div class="section-content">
|
||
|
||
<h4 style="margin-top: 20px; color: var(--primary); font-size: 16px;">گام ۱ — افزودن بسته NuGet</h4>
|
||
<p>در فایل <code>xAiApi.csproj</code>، بسته <code>OfficeIMO.PowerPoint</code> را اضافه کنید. دستور نصب از طریق .NET CLI بهصورت زیر است[reference:2]:</p>
|
||
|
||
<pre>dotnet add package OfficeIMO.PowerPoint</pre>
|
||
|
||
<p>یا مستقیماً در فایل پروژه:</p>
|
||
|
||
<pre><PackageReference Include="OfficeIMO.PowerPoint" Version="..." /></pre>
|
||
|
||
<div class="info-box">
|
||
<strong>💡 نکته:</strong> بسته <code>DocumentFormat.OpenXml</code> که برای فرمتهای مدرن استفاده میشود، از قبل در پروژه وجود دارد و نیازی به تغییر آن نیست. همچنین بستههای NPOI مربوط به PowerPoint (از جمله <code>ScratchPad.NPOI.HSLF</code>) را میتوانید حذف کنید.
|
||
</div>
|
||
|
||
<h4 style="margin-top: 25px; color: var(--primary); font-size: 16px;">گام ۲ — حذف using های NPOI</h4>
|
||
<p>در فایل <code>XPowerPointFileContentExtractor.cs</code>، خطوط زیر را حذف کنید:</p>
|
||
|
||
<pre>// حذف شوند
|
||
using NPOI.HSLF.UserModel;
|
||
using NPOI.HSLF;</pre>
|
||
|
||
<h4 style="margin-top: 25px; color: var(--primary); font-size: 16px;">گام ۳ — افزودن using های OfficeIMO</h4>
|
||
<p>خطوط زیر را به بالای فایل اضافه کنید:</p>
|
||
|
||
<pre>using OfficeIMO.PowerPoint;
|
||
using OfficeIMO.PowerPoint.LegacyPpt;</pre>
|
||
|
||
<div class="success-box">
|
||
<strong>✓ نتیجه این بخش:</strong> پس از این سه گام، پروژه آماده است تا متد <code>ExtractLegacyAsync</code> با استفاده از OfficeIMO بازنویسی شود. بخش <code>ExtractOpenXmlAsync</code> و سایر بخشهای کد (مانند تشخیص MIME و ثبت در DI) بدون هیچ تغییری باقی میمانند.
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="section">
|
||
<div class="section-header">
|
||
<div class="section-number">۴</div>
|
||
<div class="section-title">
|
||
<h3>یکپارچهسازی با کد موجود</h3>
|
||
<div class="subtitle">Integration with Existing Code</div>
|
||
</div>
|
||
</div>
|
||
<div class="section-content">
|
||
|
||
<p>ساختار کلی کلاس <code>XPowerPointFileContentExtractor</code> پس از یکپارچهسازی بهصورت زیر خواهد بود. تنها متد <code>ExtractLegacyAsync</code> بازنویسی میشود و بقیه اجزا دستنخورده باقی میمانند.</p>
|
||
|
||
<h4 style="margin-top: 20px; color: var(--primary); font-size: 16px;">ساختار نهایی کلاس</h4>
|
||
|
||
<pre>public class XPowerPointFileContentExtractor : IXPowerPointFileContentExtractor
|
||
{
|
||
// ۱. آرایه MIME Type ها (بدون تغییر)
|
||
private static readonly string[] SupportedMimeTypes = [ ... ];
|
||
|
||
// ۲. CanExtract (بدون تغییر)
|
||
public bool CanExtract(string mimeType) { ... }
|
||
|
||
// ۳. ExtractAsync (بدون تغییر)
|
||
public async Task<string> ExtractAsync(...) { ... }
|
||
|
||
// ۴. ExtractRichAsync (بدون تغییر)
|
||
public async Task<XFileExtractionResult> ExtractRichAsync(...) { ... }
|
||
|
||
// ۵. ExtractOpenXmlAsync (بدون تغییر — برای ۶ فرمت مدرن)
|
||
private async Task<string> ExtractOpenXmlAsync(...) { ... }
|
||
|
||
// ۶. ExtractLegacyAsync (بازنویسی با OfficeIMO — برای ۳ فرمت قدیمی)
|
||
private async Task<string> ExtractLegacyAsync(...) { ... }
|
||
|
||
// ۷. متدهای کمکی OpenXml (بدون تغییر)
|
||
private static string GetSlideTitle(...) { ... }
|
||
private static string GetSpeakerNotes(...) { ... }
|
||
private static string ExtractOpenXmlTables(...) { ... }
|
||
}</pre>
|
||
|
||
<div class="highlight-box">
|
||
<strong>نکته مهم:</strong> تشخیص اینکه کدام متد فراخوانی شود، همچنان توسط متد <code>ExtractRichAsync</code> و بر اساس MIME Type انجام میشود. متدهای <code>IsOpenXmlFormat</code> و <code>IsLegacyFormat</code> بدون تغییر باقی میمانند.
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="section">
|
||
<div class="section-header">
|
||
<div class="section-number">۵</div>
|
||
<div class="section-title">
|
||
<h3>بازنویسی متد ExtractLegacyAsync با OfficeIMO</h3>
|
||
<div class="subtitle">Rewriting ExtractLegacyAsync with OfficeIMO</div>
|
||
</div>
|
||
</div>
|
||
<div class="section-content">
|
||
|
||
<p>متد جدید <code>ExtractLegacyAsync</code> از <code>PowerPointPresentation.Load</code> برای بارگذاری فایلهای قدیمی استفاده میکند و سپس با پیمایش اسلایدها و شکلها، متن را استخراج میکند.</p>
|
||
|
||
<pre>private async Task<string> ExtractLegacyAsync(
|
||
Stream fileStream,
|
||
CancellationToken cancellationToken)
|
||
{
|
||
var sb = new StringBuilder();
|
||
|
||
// ۱. کپی استریم به MemoryStream (OfficeIMO به استریم Seekable نیاز دارد)
|
||
await using var ms = new MemoryStream();
|
||
await fileStream.CopyToAsync(ms, cancellationToken);
|
||
ms.Position = 0;
|
||
|
||
// ۲. بارگذاری ارائه با OfficeIMO
|
||
// طبق مستندات، Load بهطور خودکار فرمت .ppt/.pot/.pps را تشخیص میدهد
|
||
using var presentation = PowerPointPresentation.Load(ms);
|
||
|
||
// ۳. پیمایش اسلایدها
|
||
var slideIndex = 0;
|
||
foreach (var slide in presentation.Slides)
|
||
{
|
||
if (cancellationToken.IsCancellationRequested) break;
|
||
slideIndex++;
|
||
|
||
sb.AppendLine($"[Slide {slideIndex}]");
|
||
|
||
// ۴. استخراج متن از شکلهای اسلاید
|
||
var textParts = new List<string>();
|
||
var imageCount = 0;
|
||
|
||
foreach (var shape in slide.Shapes)
|
||
{
|
||
// اگر شکل دارای متن است
|
||
if (shape is PowerPointTextBox textBox)
|
||
{
|
||
if (!string.IsNullOrWhiteSpace(textBox.Text))
|
||
{
|
||
textParts.Add(textBox.Text.Trim());
|
||
}
|
||
}
|
||
// اگر شکل از نوع LegacyPptShape باشد (در صورت دسترسی مستقیم)
|
||
else if (shape is LegacyPptShape legacyShape)
|
||
{
|
||
if (!string.IsNullOrWhiteSpace(legacyShape.Text))
|
||
{
|
||
textParts.Add(legacyShape.Text.Trim());
|
||
}
|
||
if (legacyShape.Picture != null)
|
||
{
|
||
imageCount++;
|
||
}
|
||
}
|
||
}
|
||
|
||
// ۵. نوشتن متنهای استخراجشده
|
||
if (textParts.Count > 0)
|
||
{
|
||
sb.AppendLine("Content:");
|
||
foreach (var text in textParts)
|
||
{
|
||
sb.AppendLine($" - {text}");
|
||
}
|
||
}
|
||
|
||
// ۶. شمارش تصاویر (در صورت وجود)
|
||
if (imageCount > 0)
|
||
{
|
||
sb.AppendLine($"[Images: {imageCount}]");
|
||
}
|
||
|
||
sb.AppendLine();
|
||
}
|
||
|
||
return sb.ToString().TrimEnd();
|
||
}</pre>
|
||
|
||
<div class="warning-box">
|
||
<strong>⚠ نکته درباره API دقیق:</strong> ساختار ارائهشده بر اساس الگوی مستندات OfficeIMO (<code>presentation.Slides</code> و <code>slide.Shapes</code>) و کلاس <code>LegacyPptShape</code> که دارای ویژگی <code>Text</code> است، طراحی شده است[reference:3][reference:4]. در صورت تفاوت جزئی در نامگذاری کلاسها (مانند <code>PowerPointTextBox</code>)، با مراجعه به API Reference رسمی OfficeIMO، اصلاحات جزئی لازم خواهد بود. با این حال، منطق کلی (بارگذاری با <code>Load</code>، پیمایش <code>Slides</code> و <code>Shapes</code>، و استخراج <code>Text</code>) صحیح است.
|
||
</div>
|
||
|
||
<h4 style="margin-top: 25px; color: var(--primary); font-size: 16px;">گزینه جایگزین: تبدیل به PPTX و استفاده از OpenXml</h4>
|
||
|
||
<p>اگر ترجیح میدهید تمام پردازش متنی را با <code>DocumentFormat.OpenXml</code> انجام دهید، OfficeIMO یک متد تبدیل درونخطی ارائه میدهد:</p>
|
||
|
||
<pre>// تبدیل .ppt به .pptx با OfficeIMO
|
||
PowerPointPresentation.Convert("input.ppt", "output.pptx");
|
||
|
||
// سپس فایل output.pptx را با OpenXml پردازش کنید</pre>
|
||
|
||
<p>این روش بهویژه زمانی مفید است که بخواهید از <code>ExtractOpenXmlAsync</code> موجود (که یادداشتها و جداول را نیز استخراج میکند) برای فایلهای قدیمی تبدیلشده استفاده کنید[reference:5]. اما توجه داشته باشید که تبدیل ممکن است بخشی از وفاداری ساختاری را از دست بدهد.</p>
|
||
|
||
<div class="info-box">
|
||
<strong>💡 توصیه:</strong> برای حفظ سادگی و یکپارچگی، استفاده مستقیم از <code>PowerPointPresentation.Load</code> و استخراج متن (روش اول) پیشنهاد میشود. روش تبدیل بهعنوان یک گزینه پشتیبان در دسترس است.
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="section">
|
||
<div class="section-header">
|
||
<div class="section-number">۶</div>
|
||
<div class="section-title">
|
||
<h3>ملاحظات استقرار در Docker و Linux</h3>
|
||
<div class="subtitle">Docker & Linux Deployment Considerations</div>
|
||
</div>
|
||
</div>
|
||
<div class="section-content">
|
||
|
||
<p>OfficeIMO بهطور رسمی از Linux و Docker پشتیبانی میکند[reference:6]. با این حال، برای اطمینان از عملکرد صحیح، نکات زیر باید در Dockerfile رعایت شوند:</p>
|
||
|
||
<table class="styled-table">
|
||
<thead>
|
||
<tr>
|
||
<th>مورد</th>
|
||
<th>توضیح</th>
|
||
<th>الزامی؟</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td>نصب فونتها</td>
|
||
<td>برای پردازش صحیح متن و اندازهگیری، فونتهای فارسی و لاتین باید در ایمیج موجود باشند</td>
|
||
<td style="color: var(--warning); font-weight: 600;">توصیهشده</td>
|
||
</tr>
|
||
<tr>
|
||
<td>libgdiplus (در صورت استفاده از PDF)</td>
|
||
<td>اگر از قابلیتهای PDF در OfficeIMO استفاده میکنید، ممکن است لازم باشد</td>
|
||
<td style="color: var(--warning); font-weight: 600;">بسته به سناریو</td>
|
||
</tr>
|
||
<tr>
|
||
<td>پشتیبانی NativeAOT</td>
|
||
<td>OfficeIMO با NativeAOT سازگار است (اختیاری)</td>
|
||
<td style="color: var(--success); font-weight: 600;">اختیاری</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
|
||
<h4 style="margin-top: 25px; color: var(--primary); font-size: 16px;">نمونه Dockerfile</h4>
|
||
|
||
<pre>FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
|
||
WORKDIR /app
|
||
EXPOSE 80
|
||
|
||
# نصب فونتهای فارسی و لاتین
|
||
RUN apt-get update && apt-get install -y \
|
||
fonts-dejavu \
|
||
fonts-farsiweb \
|
||
&& rm -rf /var/lib/apt/lists/*
|
||
|
||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||
WORKDIR /src
|
||
COPY ["xAiApi/xAiApi.csproj", "xAiApi/"]
|
||
RUN dotnet restore "xAiApi/xAiApi.csproj"
|
||
COPY . .
|
||
WORKDIR "/src/xAiApi"
|
||
RUN dotnet build "xAiApi.csproj" -c Release -o /app/build
|
||
|
||
FROM build AS publish
|
||
RUN dotnet publish "xAiApi.csproj" -c Release -o /app/publish
|
||
|
||
FROM base AS final
|
||
WORKDIR /app
|
||
COPY --from=publish /app/publish .
|
||
ENTRYPOINT ["dotnet", "xAiApi.dll"]</pre>
|
||
|
||
<div class="success-box">
|
||
<strong>✓ نکته:</strong> طبق مستندات OfficeIMO، این کتابخانه “برای تولید اسناد بدون COM در کانتینرهای Linux، GitHub Actions و Azure DevOps مناسب است” و نیازی به نصب Microsoft Office یا LibreOffice ندارد[reference:7].
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="section">
|
||
<div class="section-header">
|
||
<div class="section-number">۷</div>
|
||
<div class="section-title">
|
||
<h3>تست و اعتبارسنجی</h3>
|
||
<div class="subtitle">Testing & Validation</div>
|
||
</div>
|
||
</div>
|
||
<div class="section-content">
|
||
|
||
<p>پس از یکپارچهسازی، تستهای زیر برای اطمینان از صحت عملکرد ضروری هستند:</p>
|
||
|
||
<table class="styled-table">
|
||
<thead>
|
||
<tr>
|
||
<th>#</th>
|
||
<th>سناریو</th>
|
||
<th>ورودی</th>
|
||
<th>خروجی مورد انتظار</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td>۱</td>
|
||
<td>استخراج .ppt ساده</td>
|
||
<td>فایل .ppt با ۳ اسلاید متنی</td>
|
||
<td>متن هر ۳ اسلاید با برچسب [Slide N]</td>
|
||
</tr>
|
||
<tr>
|
||
<td>۲</td>
|
||
<td>استخراج .pps</td>
|
||
<td>فایل Slide Show قدیمی</td>
|
||
<td>مانند .ppt</td>
|
||
</tr>
|
||
<tr>
|
||
<td>۳</td>
|
||
<td>استخراج .pot</td>
|
||
<td>فایل قالب قدیمی</td>
|
||
<td>مانند .ppt</td>
|
||
</tr>
|
||
<tr>
|
||
<td>۴</td>
|
||
<td>فایل .ppt با تصویر</td>
|
||
<td>اسلاید حاوی تصویر</td>
|
||
<td>شمارش تصویر در خروجی ([Images: N])</td>
|
||
</tr>
|
||
<tr>
|
||
<td>۵</td>
|
||
<td>فایل .pptx (رگرسیون)</td>
|
||
<td>فایل مدرن</td>
|
||
<td>همچنان با OpenXml و بدون تغییر پردازش شود</td>
|
||
</tr>
|
||
<tr>
|
||
<td>۶</td>
|
||
<td>فایل خراب یا نامعتبر</td>
|
||
<td>Stream ناقص</td>
|
||
<td>ErrorMessage تنظیم شود، استثناء پرتاب نشود</td>
|
||
</tr>
|
||
<tr class="highlight-row">
|
||
<td>۷</td>
|
||
<td>اجرا در Docker Linux</td>
|
||
<td>ایمیج ساختهشده</td>
|
||
<td>بدون خطای PlatformNotSupportedException</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
|
||
<div class="info-box">
|
||
<strong>💡 معیار پذیرش:</strong> پس از اجرای موفق تستهای ۱ تا ۷، میتوان تأیید کرد که یکپارچهسازی OfficeIMO بهدرستی انجام شده و سامانه xAiApi آماده پردازش تمام ۹ فرمت PowerPoint در محیط Docker/Linux است.
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="section">
|
||
<div class="section-header">
|
||
<div class="section-number">۸</div>
|
||
<div class="section-title">
|
||
<h3>جمعبندی نهایی</h3>
|
||
<div class="subtitle">Final Summary</div>
|
||
</div>
|
||
</div>
|
||
<div class="section-content">
|
||
|
||
<p>با یکپارچهسازی <strong>OfficeIMO.PowerPoint</strong> در کنار کد موجود، شکاف پشتیبانی از فرمتهای قدیمی PowerPoint بهطور کامل و رایگان پر میشود. این راهحل:</p>
|
||
|
||
<ul style="padding-right: 20px; margin: 15px 0;">
|
||
<li style="margin-bottom: 8px;"><strong>رایگان و متنباز است</strong> (مجوز MIT) و هیچ هزینه لایسنسی ندارد.</li>
|
||
<li style="margin-bottom: 8px;"><strong>در Docker و Linux کار میکند</strong> و نیازی به Microsoft Office یا COM ندارد.</li>
|
||
<li style="margin-bottom: 8px;"><strong>با ساختار موجود پروژه سازگار است</strong> و تنها متد <code>ExtractLegacyAsync</code> بازنویسی میشود.</li>
|
||
<li style="margin-bottom: 8px;"><strong>پوشش کامل ۹ فرمت PowerPoint</strong> (۶ مدرن + ۳ قدیمی) را فراهم میکند.</li>
|
||
</ul>
|
||
|
||
<table class="styled-table">
|
||
<thead>
|
||
<tr>
|
||
<th>محور</th>
|
||
<th>قبل از یکپارچهسازی</th>
|
||
<th>پس از یکپارچهسازی</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td>پشتیبانی از فرمتهای قدیمی</td>
|
||
<td style="color: var(--danger); font-weight: 600;">✗</td>
|
||
<td style="color: var(--success); font-weight: 600;">✓</td>
|
||
</tr>
|
||
<tr>
|
||
<td>وابستگی به کتابخانه تجاری</td>
|
||
<td style="color: var(--warning); font-weight: 600;">مطرح بود</td>
|
||
<td style="color: var(--success); font-weight: 600;">حذف شد</td>
|
||
</tr>
|
||
<tr>
|
||
<td>قابلیت اجرا در Docker/Linux</td>
|
||
<td style="color: var(--warning); font-weight: 600;">مشکل داشت</td>
|
||
<td style="color: var(--success); font-weight: 600;">✓ کامل</td>
|
||
</tr>
|
||
<tr class="highlight-row">
|
||
<td><strong>آمادگی تولیدی</strong></td>
|
||
<td>متوسط</td>
|
||
<td style="color: var(--success); font-weight: 700; font-size: 15px;">بالا</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
|
||
<div class="conclusion-box">
|
||
<h3>🎯 پیشنهاد نهایی</h3>
|
||
<p>با توجه به تحلیلهای انجامشده، OfficeIMO.PowerPoint بهترین گزینه رایگان برای تکمیل پشتیبانی از فرمتهای قدیمی PowerPoint در پروژه xAiApi است.</p>
|
||
<div class="highlight">
|
||
<strong>💎 ارزش پیشنهادی:</strong><br>
|
||
پوشش کامل ۹ فرمت PowerPoint + مجوز MIT رایگان + استقرار Cross-platform + یکپارچگی با کد موجود + بدون وابستگی تجاری
|
||
</div>
|
||
</div>
|
||
|
||
<div class="info-box">
|
||
<strong>📞 گام بعدی:</strong> در صورت تایید این مستند، آمادهام کد کامل و نهایی <code>XPowerPointFileContentExtractor</code> را با یکپارچهسازی OfficeIMO و اصلاحات لازم ارائه کنم تا مستقیماً جایگزین نسخه فعلی شود.
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="page-info">
|
||
این مستند محرمانه بوده و صرفاً جهت ارائه به کارفرمای محترم تهیه شده است. هرگونه کپیبرداری یا افشا بدون اجازه کتبی ممنوع است.
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<footer class="document-footer">
|
||
<div class="footer-brand">طراحی و توسعه: هادی خزاعی اصل</div>
|
||
<div class="footer-divider"></div>
|
||
<div>تاریخ تهیه: ۱ آبان ۱۴۰۵ | نسخه: ۱.۰ | طبقهبندی: محرمانه</div>
|
||
</footer>
|
||
|
||
</div>
|
||
|
||
</body>
|
||
</html> |