├── .gitignore ├── AiToPPTX ├── include.inc.php ├── lib │ ├── AiToPptx_DrawGroupObject.php │ ├── AiToPptx_DrawSingleObject.php │ ├── AiToPptx_MakeContentTypesXml.php │ ├── AiToPptx_MakeMasterXml.php │ ├── AiToPptx_MakePresentationXml.php │ ├── AiToPptx_MakePresentationXmlRelations.php │ ├── AiToPptx_MakeRootRelations.php │ ├── AiToPptx_MakeSingleSlide.php │ ├── AiToPptx_MakeSlideLayout.php │ ├── AiToPptx_MakeThemeXml.php │ └── functions.inc.php └── xml │ ├── app.xml │ ├── core.xml │ ├── presProps.xml │ ├── tableStyles.xml │ ├── theme.xml │ └── viewProps.xml ├── BusinessLicense ├── AI-TO-PPTX 软件商业授权协议.docx └── AI-TO-PPTX 软件商业授权协议.md ├── DockerMaker ├── Dockerfile ├── LICENSE ├── README.md ├── asyncPptInfo.php ├── config.inc.php ├── downloadPptx.php ├── downloadPptxFile.php ├── example ├── generate_pptx_from_json.php ├── markdown_to_pptx_content_json.php └── redis.php ├── generateContent.php ├── generateOutline.php ├── index.php ├── json ├── 蓝色工作汇报总结.json ├── 蓝色工作汇报总结.png ├── 蓝色通用商务.json ├── 蓝色通用商务.png ├── 读书分享演示.json ├── 读书分享演示.png ├── 课程学习汇报.json └── 课程学习汇报.png ├── randomTemplates.php └── saveConfig.php /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | /cache 3 | /output 4 | -------------------------------------------------------------------------------- /AiToPPTX/include.inc.php: -------------------------------------------------------------------------------- 1 | $章节信息) { 146 | $章节JSON列表 = []; 147 | foreach($章节信息 as $小节名称 => $小节列表) { 148 | //print_R($章节名称); 149 | //print_R($小节列表); 150 | $小节JSON列表 = []; 151 | for($i=0;$i[], 'level'=>0, 'type'=>'-', 'name'=>$小节内容]]; 160 | $小节JSON列表[] = $小节JSON; 161 | } 162 | $章节JSON = []; 163 | $章节JSON['level'] = 3; 164 | $章节JSON['name'] = $小节名称; 165 | $章节JSON['children'] = $小节JSON列表; 166 | $章节JSON列表[] = $章节JSON; 167 | } 168 | $二级标题JSON = []; 169 | $二级标题JSON['level'] = 2; 170 | $二级标题JSON['name'] = $章节名称; 171 | $二级标题JSON['children'] = $章节JSON列表; 172 | $页面JSON列表[] = $二级标题JSON; 173 | //print_R($二级标题JSON); 174 | } 175 | 176 | $最终结构 = []; 177 | $最终结构['level'] = 1; 178 | $最终结构['name'] = $PPTX标题; 179 | $最终结构['children'] = $页面JSON列表; 180 | 181 | return $最终结构; 182 | } 183 | 184 | function 得到单个页面的所有文本($Page) { 185 | $PageChildren = (array)$Page['children']; 186 | //$Page['children'][0]['children'][0]['children']; 187 | //$Page['children'][0]['children'][0]['children'][0]['text'] = "PPT标题"; 188 | //$Page['children'][1]['children'][0]['children'][0]['text'] = "汇报人"; 189 | $Page数据信息 = []; 190 | foreach($PageChildren as $PageChildrenItem) { 191 | if($PageChildrenItem['children'][0]['children'][0]['text']!="") { 192 | //print_R($PageChildrenItem['children'][0]['children'][0]['text']); 193 | //除以10表示用于兼容处理细微的布局差异 194 | $X = intval($PageChildrenItem['point'][0]/5) + 10000; 195 | $Y = intval($PageChildrenItem['point'][1]/5) + 10000; 196 | if($PageChildrenItem['children'][0]['children'][0]['text']!="") { 197 | $Page数据信息[$X."_".$Y."_".rand(1111,9999)] = $Y."_".$X."____".trim($PageChildrenItem['children'][0]['children'][0]['text']); 198 | } 199 | } 200 | //print $PageChildrenItem['children'][0]['children'][0]['text']."\n"; 201 | } 202 | ksort($Page数据信息); 203 | return array_values($Page数据信息); 204 | } 205 | 206 | function 替换首页或尾页($指定页面JSON, $PPTX标题, $PPTX作者, $页面页码, $页面标题) { 207 | //print_R($指定页面JSON);exit; 208 | //替换首页信息 209 | //$Page['children'][0]['children'][0]['children'][0]['text'] = "PPT标题"; 210 | //$Page['children'][1]['children'][0]['children'][0]['text'] = "汇报人"; 211 | $PageChildren = (array)$指定页面JSON['children']; 212 | $Counter = 0; 213 | for($i=0;$i"; 218 | } 219 | else if($PageChildren[$i]['type'] == 'text' && $PageChildren[$i]['children'][0]['children'][0]['text']!="" && $Counter == 1) { 220 | $PageChildren[$i]['children'][0]['children'][0]['text'] = $PPTX作者; 221 | $Counter += 1; 222 | //print $PageChildrenItem['children'][0]['children'][0]['text']."
"; 223 | } 224 | //print_R($PageChildren[$i]['children'][0]['children'][0]['text']); 225 | } 226 | $指定页面JSON['children'] = $PageChildren; 227 | $指定页面JSON['title'] = $页面标题; 228 | $指定页面JSON['page'] = $页面页码; 229 | //print_R($指定页面JSON); 230 | return $指定页面JSON; 231 | } 232 | 233 | function 替换目录页($指定页面JSON, $目录LIST) { 234 | //print_R($指定页面JSON);exit; 235 | //替换首页信息 236 | //$Page['children'][0]['children'][0]['children'][0]['text'] = "PPT标题"; 237 | //$Page['children'][1]['children'][0]['children'][0]['text'] = "汇报人"; 238 | $Page数据信息 = []; 239 | $PageChildren = (array)$指定页面JSON['children']; 240 | for($i=0;$i"; 248 | //除以10表示用于兼容处理细微的布局差异 249 | $X = intval($PageChildren[$i]['point'][0]/5) + 10000; 250 | $Y = intval($PageChildren[$i]['point'][1]/5) + 10000; 251 | if($PageChildren[$i]['children'][0]['children'][0]['text']!="" && $PageChildren[$i]['children'][0]['children'][0]['text']!="CONTENTS") { 252 | $Page数据信息[$Y."_".$X] = ['title'=>trim($PageChildren[$i]['children'][0]['children'][0]['text']), 'id'=>$i]; 253 | } 254 | } 255 | } 256 | ksort($Page数据信息); 257 | $标题列表 = []; 258 | foreach($Page数据信息 as $KEY => $Title_Id) { 259 | if(strlen($Title_Id['title'])>5) { 260 | $标题列表[] = $Title_Id; 261 | } 262 | } 263 | 264 | //把当前页面参数转为TEXT,然后做替换,最后再转化为JSON 265 | $指定页面JSONText = json_encode($指定页面JSON); 266 | for($i=0;$i"; 334 | //除以10表示用于兼容处理细微的布局差异 335 | $X = intval($PageChildren[$i]['point'][0]/5) + 10000; 336 | $Y = intval($PageChildren[$i]['point'][1]/5) + 10000; 337 | if($PageChildren[$i]['children'][0]['children'][0]['text']!="" && $PageChildren[$i]['children'][0]['children'][0]['text']!="CONTENTS") { 338 | $Page数据信息[$Y."_".$X] = ['title'=>trim($PageChildren[$i]['children'][0]['children'][0]['text']), 'id'=>$i]; 339 | } 340 | } 341 | } 342 | ksort($Page数据信息); 343 | //print_R($Page数据信息);//exit; 344 | $标题列表 = []; 345 | foreach($Page数据信息 as $KEY => $Title_Id) { 346 | if(strlen($Title_Id['title'])>5) { 347 | $标题列表[] = $Title_Id; 348 | } 349 | } 350 | 351 | return $标题列表; 352 | } 353 | 354 | function 替换内容页($指定页面JSON, $章节小节名称, $章节小节内容, $页面页码) { 355 | //print_R($章节小节名称);exit; 356 | //替换首页信息 357 | //$Page['children'][0]['children'][0]['children'][0]['text'] = "PPT标题"; 358 | //$Page['children'][1]['children'][0]['children'][0]['text'] = "汇报人"; 359 | $Page数据信息 = []; 360 | $PageChildren = (array)$指定页面JSON['children']; 361 | for($i=0;$i"; 379 | //除以10表示用于兼容处理细微的布局差异 380 | $X = intval($PageChildren[$i]['point'][0]/5) + 10000; 381 | $Y = intval($PageChildren[$i]['point'][1]/5) + 10000; 382 | if($PageChildren[$i]['children'][0]['children'][0]['text']!="" && $PageChildren[$i]['children'][0]['children'][0]['text']!="CONTENTS") { 383 | $Page数据信息[$Y."_".$X] = ['title'=>trim($PageChildren[$i]['children'][0]['children'][0]['text']), 'id'=>$i]; 384 | } 385 | } 386 | } 387 | ksort($Page数据信息); 388 | $标题列表 = []; 389 | foreach($Page数据信息 as $KEY => $Title_Id) { 390 | if(strlen($Title_Id['title'])>5) { 391 | $标题列表[] = $Title_Id; 392 | } 393 | } 394 | //对标题和内容再次过滤,防止有颠倒的情况发生 不能使用FOR 情况特殊 395 | if(strlen($标题列表[2]['title']) < 50 && strlen($标题列表[3]['title']) > 50) { 396 | $TempValue = $标题列表[2]; 397 | $标题列表[2] = $标题列表[3]; 398 | $标题列表[3] = $TempValue; 399 | } 400 | 401 | //判断是否是前三个都是标题,后三个都是内容的情况 402 | if(sizeof($标题列表)==7) { 403 | if(strlen($标题列表[1]['title']) < strlen($标题列表[4]['title']) && strlen($标题列表[2]['title']) < strlen($标题列表[5]['title']) && strlen($标题列表[3]['title']) < strlen($标题列表[6]['title']) ) { 404 | //需要转换为标题,内容,标题,内容,标题,内容的形式 405 | $标题列表NEW = []; 406 | $标题列表NEW[0] = $标题列表[0]; 407 | $标题列表NEW[1] = $标题列表[1]; 408 | $标题列表NEW[2] = $标题列表[4]; 409 | $标题列表NEW[3] = $标题列表[2]; 410 | $标题列表NEW[4] = $标题列表[5]; 411 | $标题列表NEW[5] = $标题列表[3]; 412 | $标题列表NEW[6] = $标题列表[6]; 413 | $标题列表 = $标题列表NEW; 414 | //print_R(array_values($标题列表NEW));exit; 415 | } 416 | } 417 | //print_R($标题列表);exit; 418 | 419 | //print_R($标题列表);print_R($章节小节名称);print_R($章节小节内容); //exit; 420 | //把当前页面参数转为TEXT,然后做替换,最后再转化为JSON 421 | array_unshift($章节小节内容, $章节小节名称); 422 | for($i=0;$i $章节小节列表) { 549 | $章节序号 += 1; 550 | $最终输出页面数据[$StartPage] = 替换首页或尾页($章节标题页, $章节名称, $章节序号<10 ? "0".$章节序号 : $章节序号, $StartPage+1, $章节名称); 551 | $StartPage += 1; 552 | foreach($章节小节列表 as $章节小节名称 => $章节小节内容) { 553 | //二组标题和内容 554 | if(sizeof($章节小节内容) == 4 && isset($得到所有的内容明细页面Data[5]) ) { 555 | $内容页 = array_shift($得到所有的内容明细页面Data[5]); 556 | $最终输出页面数据[$StartPage] = 替换内容页($内容页, $章节小节名称, $章节小节内容, $StartPage+1); 557 | $StartPage += 1; 558 | } 559 | //三组标题和内容 560 | else if(sizeof($章节小节内容) == 6 && isset($得到所有的内容明细页面Data[7]) ) { 561 | $内容页 = array_shift($得到所有的内容明细页面Data[7]); 562 | $最终输出页面数据[$StartPage] = 替换内容页($内容页, $章节小节名称, $章节小节内容, $StartPage+1); 563 | $StartPage += 1; 564 | } 565 | //四组标题和内容 566 | else if(sizeof($章节小节内容) == 8 && isset($得到所有的内容明细页面Data[9]) ) { 567 | $内容页 = array_shift($得到所有的内容明细页面Data[9]); 568 | $最终输出页面数据[$StartPage] = 替换内容页($内容页, $章节小节名称, $章节小节内容, $StartPage+1); 569 | $StartPage += 1; 570 | } 571 | //四组标题和内容 - 但是没有找到对应的四组模板进行匹配,就使用三组的模板 572 | else if(sizeof($章节小节内容) == 8 && !isset($得到所有的内容明细页面Data[9]) ) { 573 | $内容页 = array_shift($得到所有的内容明细页面Data[7]); 574 | $最终输出页面数据[$StartPage] = 替换内容页($内容页, $章节小节名称, $章节小节内容, $StartPage+1); 575 | $StartPage += 1; 576 | } 577 | } 578 | } 579 | 580 | if($Finished == true) { 581 | $最终输出页面数据[$StartPage] = 替换首页或尾页($尾页, $个性化信息['LastPageText'], $个性化信息['Author'], $StartPage+1, $个性化信息['LastPageText']); 582 | } 583 | 584 | $JsonData['pages2'] = $最终输出页面数据; 585 | $OutPutLastPageId = intval($OutPutLastPageId); 586 | //$OutPutLastPageId > 0 时, 只显示这个值以后的所有页面 587 | if($OutPutLastPageId > 3) { 588 | $最终输出页面数据 = array_slice($最终输出页面数据, $OutPutLastPageId, null, true); 589 | } 590 | 591 | $JsonData['pages'] = $最终输出页面数据; 592 | 593 | return $JsonData; 594 | 595 | } 596 | 597 | function 根据大纲得到PPTX页码($outlineMarkdown) { 598 | $TotalPages = []; 599 | $TotalPages[] = ['type'=>'Content', 'content'=>'Content']; 600 | $outlineMarkdownArray = explode("\\n", $outlineMarkdown); 601 | if(sizeof($outlineMarkdownArray)==1) { 602 | $outlineMarkdownArray = explode("\n", $outlineMarkdown); 603 | } 604 | foreach($outlineMarkdownArray as $Item) { 605 | if(substr(trim($Item), 0, 2) == "# ") { 606 | $TotalPages[] = ['type'=>'Cover', 'content'=>substr(trim($Item), 2, strlen($Item))]; 607 | } 608 | if(substr(trim($Item), 0, 3) == "## ") { 609 | $TotalPages[] = ['type'=>'Chapter', 'content'=>substr(trim($Item), 3, strlen($Item))]; 610 | } 611 | if(substr(trim($Item), 0, 4) == "### ") { 612 | $TotalPages[] = ['type'=>'Page', 'content'=>substr(trim($Item), 4, strlen($Item))]; 613 | } 614 | } 615 | $TotalPages[] = ['type'=>'Thank', 'content'=>'Thank']; 616 | $TotalPagesNumber = sizeof($TotalPages); 617 | 618 | return $TotalPagesNumber; 619 | } 620 | ?> 621 | -------------------------------------------------------------------------------- /AiToPPTX/lib/AiToPptx_DrawGroupObject.php: -------------------------------------------------------------------------------- 1 | formatOutput = true; 23 | //print_R($childrenItem);//exit; 24 | // 创建 节点 25 | $grpSp = $dom->createElement('p:grpSp'); 26 | 27 | // 创建 节点 28 | $nvGrpSpPr = $dom->createElement('p:nvGrpSpPr'); 29 | 30 | // 创建 节点,并设置属性 31 | $cNvPr = $dom->createElement('p:cNvPr'); 32 | $cNvPr->setAttribute('name', 'Group '. $SharpCounter++); 33 | $cNvPr->setAttribute('id', $SharpCounter++); 34 | 35 | // 创建 节点 36 | $cNvGrpSpPr = $dom->createElement('p:cNvGrpSpPr'); 37 | $nvPr = $dom->createElement('p:nvPr'); 38 | 39 | // 将 , , 添加到 40 | $nvGrpSpPr->appendChild($cNvPr); 41 | $nvGrpSpPr->appendChild($cNvGrpSpPr); 42 | $nvGrpSpPr->appendChild($nvPr); 43 | 44 | // 创建 节点 45 | $grpSpPr = $dom->createElement('p:grpSpPr'); 46 | 47 | // 创建 节点及其子节点 48 | $xfrm = $dom->createElement('a:xfrm'); 49 | if($flipVertical == 1) { 50 | $xfrm->setAttribute('flipV', 'true'); 51 | } 52 | if($flipHorizontal == 1) { 53 | $xfrm->setAttribute('flipH', 'true'); 54 | } 55 | if($rotation != "") { 56 | $xfrm->setAttribute('rot', $rotation * 60000); 57 | } 58 | 59 | $off = $dom->createElement('a:off'); 60 | $off->setAttribute('x', strval(intval($anchor[0] * 12700))); 61 | $off->setAttribute('y', strval(intval($anchor[1] * 12700))); 62 | 63 | $ext = $dom->createElement('a:ext'); 64 | $ext->setAttribute('cx', strval(intval($anchor[2] * 12700))); 65 | $ext->setAttribute('cy', strval(intval($anchor[3] * 12700))); 66 | 67 | $chOff = $dom->createElement('a:chOff'); 68 | $chOff->setAttribute('x', strval(intval($interiorAnchor[0] * 12700))); 69 | $chOff->setAttribute('y', strval(intval($interiorAnchor[1] * 12700))); 70 | 71 | $chExt = $dom->createElement('a:chExt'); 72 | $chExt->setAttribute('cx', strval(intval($interiorAnchor[2] * 12700))); 73 | $chExt->setAttribute('cy', strval(intval($interiorAnchor[3] * 12700))); 74 | 75 | // 将子节点添加到 76 | $xfrm->appendChild($off); 77 | $xfrm->appendChild($ext); 78 | $xfrm->appendChild($chOff); 79 | $xfrm->appendChild($chExt); 80 | 81 | // 将 添加到 82 | $grpSpPr->appendChild($xfrm); 83 | 84 | if ($groupFillStyle['type'] == 'color') { 85 | // 创建 节点 86 | $a_solidFill = $dom->createElement('a:solidFill'); 87 | $grpSpPr->appendChild($a_solidFill); 88 | 89 | // 创建 节点并设置属性 90 | if($groupFillStyle['color']['scheme'] != "") { 91 | $a_schemeClr = $dom->createElement('a:schemeClr'); 92 | $a_schemeClr->setAttribute('val', $groupFillStyle['color']['scheme']); 93 | $a_solidFill->appendChild($a_schemeClr); 94 | if($groupFillStyle['color']['alpha'] != "") { 95 | $a_alpha = $dom->createElement('a:alpha'); 96 | $a_alpha->setAttribute('val', $groupFillStyle['color']['alpha']); 97 | $a_schemeClr->appendChild($a_alpha); 98 | } 99 | if($groupFillStyle['color']['lumMod'] != "") { 100 | $lumMod = $dom->createElement('a:lumMod'); 101 | $lumMod->setAttribute('val', $groupFillStyle['color']['lumMod']); 102 | $a_schemeClr->appendChild($lumMod); 103 | } 104 | if($groupFillStyle['color']['lumOff'] != "") { 105 | $lumOff = $dom->createElement('a:lumOff'); 106 | $lumOff->setAttribute('val', $groupFillStyle['color']['lumOff']); 107 | $a_schemeClr->appendChild($lumOff); 108 | } 109 | } 110 | 111 | if($groupFillStyle['color']['realColor'] != '' && $groupFillStyle['color']['scheme'] == '') { 112 | $srgbClr = $dom->createElement('a:srgbClr'); 113 | if($groupFillStyle['color']['color'] == '-1') { 114 | $srgbClr->setAttribute('val', 'FFFFFF'); 115 | } 116 | else { 117 | $srgbClr->setAttribute('val', AiToPptx_NumberToColor($groupFillStyle['color']['color'])); 118 | } 119 | if($groupFillStyle['color']['alpha'] != "" && $groupFillStyle['color']['scheme'] == "") { 120 | $a_alpha = $dom->createElement('a:alpha'); 121 | $a_alpha->setAttribute('val', $groupFillStyle['color']['alpha']); 122 | $srgbClr->appendChild($a_alpha); 123 | } 124 | if($groupFillStyle['color']['lumMod'] != "" && $groupFillStyle['color']['scheme'] == "") { 125 | $lumMod = $dom->createElement('a:lumMod'); 126 | $lumMod->setAttribute('val', $groupFillStyle['color']['lumMod']); 127 | $srgbClr->appendChild($lumMod); 128 | } 129 | if($groupFillStyle['color']['lumOff'] != "" && $groupFillStyle['color']['scheme'] == "") { 130 | $lumOff = $dom->createElement('a:lumOff'); 131 | $lumOff->setAttribute('val', $groupFillStyle['color']['lumOff']); 132 | $srgbClr->appendChild($lumOff); 133 | } 134 | $a_solidFill->appendChild($srgbClr); 135 | } 136 | 137 | } 138 | 139 | if ($groupFillStyle['type'] == 'gradient') { 140 | // 创建 根节点 141 | $gradFill = $dom->createElement('a:gradFill'); 142 | $dom->appendChild($gradFill); 143 | 144 | // 创建 节点 145 | $gsLst = $dom->createElement('a:gsLst'); 146 | $gradFill->appendChild($gsLst); 147 | 148 | // 遍历 colors 数组并生成 节点 149 | foreach ($groupFillStyle['gradient']['colors'] as $index => $color) { 150 | $gs = $dom->createElement('a:gs'); 151 | $pos = $groupFillStyle['gradient']['fractions'][$index] * 100000; // 将比例转换为整数形式 152 | $gs->setAttribute('pos', (string)$pos); 153 | $gsLst->appendChild($gs); 154 | 155 | // 创建 节点并设置颜色 156 | $srgbClr = $dom->createElement('a:srgbClr'); 157 | $srgbClr->setAttribute('val', strtoupper(dechex($color['color'] & 0xFFFFFF))); // 将颜色转换为十六进制格式 158 | $gs->appendChild($srgbClr); 159 | 160 | // 如果存在 lumMod 和 lumOff,添加这些节点 161 | if (isset($color['alpha'])) { 162 | $alpha = $dom->createElement('a:alpha'); 163 | $alpha->setAttribute('val', (string)$color['alpha']); 164 | $srgbClr->appendChild($alpha); 165 | } 166 | 167 | if (isset($color['lumMod'])) { 168 | $lumMod = $dom->createElement('a:lumMod'); 169 | $lumMod->setAttribute('val', (string)$color['lumMod']); 170 | $srgbClr->appendChild($lumMod); 171 | } 172 | 173 | if (isset($color['lumOff'])) { 174 | $lumOff = $dom->createElement('a:lumOff'); 175 | $lumOff->setAttribute('val', (string)$color['lumOff']); 176 | $srgbClr->appendChild($lumOff); 177 | } 178 | } 179 | 180 | // 创建 节点并设置角度 181 | $lin = $dom->createElement('a:lin'); 182 | $angle = $groupFillStyle['gradient']['angle'] * 60000; // 将角度转换为 EMU 单位(1° = 60000 EMU) 183 | $lin->setAttribute('ang', (string)$angle); 184 | $gradFill->appendChild($lin); 185 | 186 | $grpSpPr->appendChild($gradFill); 187 | } 188 | 189 | if ($groupFillStyle['type'] == 'groupFill') { 190 | // 创建 节点 191 | $grpFill = $dom->createElement('a:grpFill'); 192 | $grpSpPr->appendChild($grpFill); 193 | } 194 | 195 | if ($groupFillStyle['type'] == 'noFill') { 196 | // 创建 节点 197 | $noFill = $dom->createElement('a:noFill'); 198 | $grpSpPr->appendChild($noFill); 199 | } 200 | 201 | // 将 添加到 202 | $grpSp->appendChild($nvGrpSpPr); 203 | $grpSp->appendChild($grpSpPr); 204 | 205 | $childrenList = $childrenItem['children']; 206 | foreach($childrenList as $children) { 207 | $Type = $children['type']; 208 | $realType = $children['extInfo']['property']['realType']; 209 | $rotation = $children['extInfo']['property']['rotation']; 210 | $groupFillStyle = $children['extInfo']['property']['groupFillStyle']; 211 | if($realType == "Group") { 212 | //print_R($childrenItem); 213 | $绘制元素RESULT = AiToPptx_DrawGroupObject($children, $DirPath); 214 | $importedNode = $dom->importNode($绘制元素RESULT, true); // 深度导入整个节点及其子节点 215 | $grpSp->appendChild($importedNode); 216 | } 217 | else { 218 | $绘制元素RESULT = AiToPptx_DrawSingleObject($children, $DirPath); 219 | $importedNode = $dom->importNode($绘制元素RESULT, true); 220 | $grpSp->appendChild($importedNode); 221 | } 222 | } 223 | 224 | // 将 添加到 DOM 的根节点 225 | //$dom->appendChild($grpSp); print_R($dom->saveXML());//exit; 226 | 227 | // 输出生成的 XML 结构 228 | //$绘制元素RESULT = $dom->saveXML(); 229 | 230 | if(strval(intval($anchor[0] * 12700)) == '549425') { 231 | //print_R($childrenItem); 232 | //print_R($绘制元素RESULT->saveXML()); 233 | } 234 | //print $绘制元素RESULT; 235 | 236 | return $grpSp; 237 | } 238 | 239 | 240 | ?> 241 | -------------------------------------------------------------------------------- /AiToPPTX/lib/AiToPptx_MakeContentTypesXml.php: -------------------------------------------------------------------------------- 1 | formatOutput = true; // 格式化输出 15 | $dom->xmlStandalone = true; // 设置 standalone="yes" 16 | 17 | // 创建根节点 并设置命名空间 18 | $types = $dom->createElementNS( 19 | 'http://schemas.openxmlformats.org/package/2006/content-types', 20 | 'Types' 21 | ); 22 | 23 | // 添加 节点的数据数组 24 | $defaultTypes = [ 25 | ['Extension' => 'jpeg', 'ContentType' => 'image/jpeg'], 26 | ['Extension' => 'rels', 'ContentType' => 'application/vnd.openxmlformats-package.relationships+xml'], 27 | ['Extension' => 'xml', 'ContentType' => 'application/xml'] 28 | ]; 29 | 30 | // 创建并添加 节点 31 | foreach ($defaultTypes as $default) { 32 | $defaultElement = $dom->createElement('Default'); 33 | $defaultElement->setAttribute('Extension', $default['Extension']); 34 | $defaultElement->setAttribute('ContentType', $default['ContentType']); 35 | $types->appendChild($defaultElement); 36 | } 37 | 38 | // 添加 节点的数据数组 39 | $overrideTypes = [ 40 | ['PartName' => '/docProps/app.xml', 'ContentType' => 'application/vnd.openxmlformats-officedocument.extended-properties+xml'], 41 | ['PartName' => '/docProps/core.xml', 'ContentType' => 'application/vnd.openxmlformats-package.core-properties+xml'], 42 | ['PartName' => '/ppt/presentation.xml', 'ContentType' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml'], 43 | ['PartName' => '/ppt/presProps.xml', 'ContentType' => 'application/vnd.openxmlformats-officedocument.presentationml.presProps+xml'], 44 | ['PartName' => '/ppt/tableStyles.xml', 'ContentType' => 'application/vnd.openxmlformats-officedocument.presentationml.tableStyles+xml'], 45 | ['PartName' => '/ppt/viewProps.xml', 'ContentType' => 'application/vnd.openxmlformats-officedocument.presentationml.viewProps+xml'], 46 | ['PartName' => '/ppt/theme/theme1.xml', 'ContentType' => 'application/vnd.openxmlformats-officedocument.theme+xml'], 47 | ['PartName' => '/ppt/slideMasters/slideMaster1.xml', 'ContentType' => 'application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml'], 48 | ]; 49 | 50 | $slideLayoutIndex = 0; 51 | $slideLayouts = (array)$JsonData['slideMasters'][0]['slideLayouts']; 52 | foreach($slideLayouts as $slideLayout) { 53 | $slideLayoutIndex ++; 54 | $overrideTypes[] = ['PartName' => '/ppt/slideLayouts/slideLayout'.$slideLayoutIndex.'.xml', 'ContentType' => 'application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml']; 55 | } 56 | $pages = $JsonData['pages']; 57 | for($i=0;$i '/ppt/slides/slide'.($i+1).'.xml', 'ContentType' => 'application/vnd.openxmlformats-officedocument.presentationml.slide+xml']; 59 | } 60 | 61 | // 创建并添加 节点 62 | foreach ($overrideTypes as $override) { 63 | $overrideElement = $dom->createElement('Override'); 64 | $overrideElement->setAttribute('PartName', $override['PartName']); 65 | $overrideElement->setAttribute('ContentType', $override['ContentType']); 66 | $types->appendChild($overrideElement); 67 | } 68 | 69 | // 将根节点添加到DOM对象 70 | $dom->appendChild($types); 71 | 72 | // 输出XML内容 73 | $dom->save($写入文件目录."/[Content_Types].xml"); 74 | 75 | } 76 | 77 | 78 | ?> 79 | -------------------------------------------------------------------------------- /AiToPPTX/lib/AiToPptx_MakeMasterXml.php: -------------------------------------------------------------------------------- 1 | formatOutput = true; // 格式化输出 25 | 26 | // 创建根元素并添加命名空间 27 | $sldMaster = $dom->createElementNS('http://schemas.openxmlformats.org/presentationml/2006/main', 'p:sldMaster'); 28 | $sldMaster->setAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main'); 29 | $sldMaster->setAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); 30 | $dom->appendChild($sldMaster); 31 | 32 | // 添加 元素 33 | $cSld = $dom->createElement('p:cSld'); 34 | $sldMaster->appendChild($cSld); 35 | 36 | // 添加 元素 37 | $bg = $dom->createElement('p:bg'); 38 | $cSld->appendChild($bg); 39 | 40 | // 添加 元素 41 | $pBgPr = $dom->createElement('p:bgPr'); 42 | $bg->appendChild($pBgPr); 43 | 44 | $DirPathMedia .= "/ppt/media"; 45 | 46 | //print_R($slideMasters[0]['background']);exit; 47 | $fillStyle = $slideMasters[0]['background']['fillStyle']; 48 | $pBgPr = 渲染fillStyle($dom, $fillStyle, $pBgPr, $DirPathMedia); 49 | $strokeStyle = $slideMasters[0]['background']['strokeStyle']; 50 | $pBgPr = 渲染strokeStyle($dom, $strokeStyle, $pBgPr, $DirPathMedia); 51 | 52 | // 添加 元素 暂时不启用 53 | //$srgbClr = $dom->createElement('a:srgbClr'); 54 | //$srgbClr->setAttribute('val', 'FFFFFF'); 55 | //$solidFill->appendChild($srgbClr); 56 | 57 | // 添加 元素 58 | $spTree = $dom->createElement('p:spTree'); 59 | $cSld->appendChild($spTree); 60 | 61 | // 添加 元素 62 | $nvGrpSpPr = $dom->createElement('p:nvGrpSpPr'); 63 | $spTree->appendChild($nvGrpSpPr); 64 | 65 | // 添加 元素 66 | $cNvPr = $dom->createElement('p:cNvPr'); 67 | $cNvPr->setAttribute('id', '1'); 68 | $cNvPr->setAttribute('name', ''); 69 | $nvGrpSpPr->appendChild($cNvPr); 70 | 71 | // 添加 元素 72 | $cNvGrpSpPr = $dom->createElement('p:cNvGrpSpPr'); 73 | $nvGrpSpPr->appendChild($cNvGrpSpPr); 74 | 75 | // 添加 元素 76 | $nvPr = $dom->createElement('p:nvPr'); 77 | $nvGrpSpPr->appendChild($nvPr); 78 | 79 | // 添加 元素 80 | $grpSpPr = $dom->createElement('p:grpSpPr'); 81 | $spTree->appendChild($grpSpPr); 82 | 83 | // 添加 元素 84 | $xfrm = $dom->createElement('a:xfrm'); 85 | $grpSpPr->appendChild($xfrm); 86 | 87 | // 添加 元素 88 | $off = $dom->createElement('a:off'); 89 | $off->setAttribute('x', '0'); 90 | $off->setAttribute('y', '0'); 91 | $xfrm->appendChild($off); 92 | 93 | // 添加 元素 94 | $ext = $dom->createElement('a:ext'); 95 | $ext->setAttribute('cx', '0'); 96 | $ext->setAttribute('cy', '0'); 97 | $xfrm->appendChild($ext); 98 | 99 | // 添加 元素 100 | $chOff = $dom->createElement('a:chOff'); 101 | $chOff->setAttribute('x', '0'); 102 | $chOff->setAttribute('y', '0'); 103 | $xfrm->appendChild($chOff); 104 | 105 | // 添加 元素 106 | $chExt = $dom->createElement('a:chExt'); 107 | $chExt->setAttribute('cx', '0'); 108 | $chExt->setAttribute('cy', '0'); 109 | $xfrm->appendChild($chExt); 110 | 111 | $childrenList = $slideMasters[0]['children']; 112 | foreach ($childrenList as $childrenItem) { 113 | $Type = $childrenItem['type']; 114 | $realType = $childrenItem['extInfo']['property']['realType']; 115 | $rotation = $childrenItem['extInfo']['property']['rotation']; 116 | $groupFillStyle = $childrenItem['extInfo']['property']['groupFillStyle']; 117 | if($realType == "Group") { 118 | //print_R($childrenItem); 119 | $绘制元素RESULT = AiToPptx_DrawGroupObject($childrenItem, $DirPath); 120 | } 121 | else { 122 | $绘制元素RESULT = AiToPptx_DrawSingleObject($childrenItem, $DirPath); 123 | } 124 | $importedNode = $dom->importNode($绘制元素RESULT, true); // 深度导入整个节点及其子节点 125 | $spTree->appendChild($importedNode); 126 | } 127 | 128 | 129 | // 创建 元素并设置属性 130 | $themeMap = $slideMasters[0]['theme']; 131 | $clrMap = $dom->createElement('p:clrMap'); 132 | if(isset($themeMap['colors']['lt1'])) $clrMap->setAttribute('bg1', 'lt1'); 133 | if(isset($themeMap['colors']['lt2'])) $clrMap->setAttribute('bg2', 'lt2'); 134 | if(isset($themeMap['colors']['dk1'])) $clrMap->setAttribute('tx1', 'dk1'); 135 | if(isset($themeMap['colors']['dk2'])) $clrMap->setAttribute('tx2', 'dk2'); 136 | if(isset($themeMap['colors']['accent1'])) $clrMap->setAttribute('accent1', 'accent1'); 137 | if(isset($themeMap['colors']['accent2'])) $clrMap->setAttribute('accent2', 'accent2'); 138 | if(isset($themeMap['colors']['accent3'])) $clrMap->setAttribute('accent3', 'accent3'); 139 | if(isset($themeMap['colors']['accent4'])) $clrMap->setAttribute('accent4', 'accent4'); 140 | if(isset($themeMap['colors']['accent5'])) $clrMap->setAttribute('accent5', 'accent5'); 141 | if(isset($themeMap['colors']['accent6'])) $clrMap->setAttribute('accent6', 'accent6'); 142 | if(isset($themeMap['colors']['hlink'])) $clrMap->setAttribute('hlink', 'hlink'); 143 | if(isset($themeMap['colors']['folHlink'])) $clrMap->setAttribute('folHlink', 'folHlink'); 144 | $sldMaster->appendChild($clrMap); 145 | 146 | // 创建 元素 147 | $sldLayoutIdLst = $dom->createElement('p:sldLayoutIdLst'); 148 | 149 | // 定义幻灯片布局 ID 和 r:id 的数组 150 | $slideLayouts = (array)$slideMasters[0]['slideLayouts']; 151 | $layouts = []; 152 | $slideMasterContent = []; 153 | $slideMasterContent[] = ''; 154 | $slideMasterContent[] = ''; 155 | foreach($slideLayouts as $slideLayout) { 156 | $slideLayoutIndex ++; 157 | $slideMasterContent[] = ''; 158 | $layouts[] = ['id' => 10000+$slideLayoutIndex, 'r:id' => 'rId'.$slideLayoutIndex]; 159 | } 160 | $slideLayoutIndex ++; 161 | $slideMasterContent[] = ''; 162 | //$layouts[] = ['id' => 10000+$slideLayoutIndex, 'r:id' => 'rId'.$slideLayoutIndex]; 163 | 164 | //加入图片映射 165 | foreach($关系引用ID值列表SlideLayout as $关系引用ID值列表SlideLayoutItem) { 166 | if($关系引用ID值列表SlideLayoutItem!="") { 167 | $slideMasterContent[] = $关系引用ID值列表SlideLayoutItem; 168 | } 169 | } 170 | 171 | $slideMasterContent[] = ''; 172 | 173 | foreach ($layouts as $layout) { 174 | $sldLayoutId = $dom->createElement('p:sldLayoutId'); 175 | $sldLayoutId->setAttribute('id', $layout['id']); 176 | $sldLayoutId->setAttribute('r:id', $layout['r:id']); 177 | $sldLayoutIdLst->appendChild($sldLayoutId); 178 | } 179 | $sldMaster->appendChild($sldLayoutIdLst); 180 | 181 | $dom->appendChild($sldMaster); 182 | 183 | //print $dom->saveXML(); exit; 184 | 185 | //写入文件 186 | $FilePath = $DirPath."/ppt/slideMasters/slideMaster1.xml"; 187 | $dom->save($FilePath); 188 | 189 | //生成slideMaster的relation文件 190 | $slideMasterPath = $DirPath."/ppt/slideMasters/_rels/slideMaster1.xml.rels"; 191 | $slideMasterContentString = join("\n", $slideMasterContent); 192 | file_put_contents($slideMasterPath, $slideMasterContentString); 193 | 194 | return $dom->saveXML(); 195 | 196 | } 197 | 198 | ?> 199 | -------------------------------------------------------------------------------- /AiToPPTX/lib/AiToPptx_MakePresentationXml.php: -------------------------------------------------------------------------------- 1 | formatOutput = true; // 格式化输出,便于阅读 15 | 16 | // 创建 根元素,并设置命名空间 17 | $presentation = $dom->createElementNS('http://schemas.openxmlformats.org/presentationml/2006/main', 'p:presentation'); 18 | $presentation->setAttribute('saveSubsetFonts', '1'); 19 | $presentation->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main'); 20 | $presentation->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); 21 | 22 | // 节点 23 | $sldMasterIdLst = $dom->createElement('p:sldMasterIdLst'); 24 | $sldMasterId = $dom->createElement('p:sldMasterId'); 25 | $sldMasterId->setAttribute('id', '2147483648'); 26 | $sldMasterId->setAttribute('r:id', 'rId1'); 27 | $sldMasterIdLst->appendChild($sldMasterId); 28 | $presentation->appendChild($sldMasterIdLst); 29 | 30 | // 节点 31 | $sldIdLst = $dom->createElement('p:sldIdLst'); 32 | 33 | // 创建 子节点 34 | $pages = $JsonData['pages']; 35 | for($i=0;$icreateElement('p:sldId'); 37 | $sldIdItem->setAttribute('id', 255 + ($i+1)); 38 | $sldIdItem->setAttribute('r:id', 'rId'.($i+6)); 39 | $sldIdLst->appendChild($sldIdItem); 40 | } 41 | 42 | $presentation->appendChild($sldIdLst); 43 | 44 | $幻灯片的尺寸 = [1280, 720]; 45 | $备注页的尺寸 = [1280, 720]; 46 | 47 | // 节点 48 | $sldSz = $dom->createElement('p:sldSz'); 49 | $sldSz->setAttribute('cx', $幻灯片的尺寸[0] * 9525); 50 | $sldSz->setAttribute('cy', $幻灯片的尺寸[1] * 9525); 51 | $presentation->appendChild($sldSz); 52 | 53 | // 节点 54 | $notesSz = $dom->createElement('p:notesSz'); 55 | $notesSz->setAttribute('cx', $备注页的尺寸[0] * 9525); 56 | $notesSz->setAttribute('cy', $备注页的尺寸[1] * 9525); 57 | $presentation->appendChild($notesSz); 58 | 59 | // 节点 60 | $defaultTextStyle = $dom->createElement('p:defaultTextStyle'); 61 | $presentation->appendChild($defaultTextStyle); 62 | 63 | // 将根元素添加到DOM对象 64 | $dom->appendChild($presentation); 65 | 66 | // 输出XML内容 67 | // print $写入文件目录."/ppt/presentation.xml"; 68 | $dom->save($写入文件目录."/ppt/presentation.xml"); 69 | 70 | } 71 | 72 | 73 | ?> 74 | -------------------------------------------------------------------------------- /AiToPPTX/lib/AiToPptx_MakePresentationXmlRelations.php: -------------------------------------------------------------------------------- 1 | '; 16 | } 17 | $MakePresentationXmlContent = ' 18 | 19 | 20 | 21 | 22 | 23 | 24 | '.join("\n",$MakePresentationXmlList).' 25 | '; 26 | file_put_contents($写入文件目录."/ppt/_rels/presentation.xml.rels", $MakePresentationXmlContent); 27 | } 28 | 29 | 30 | ?> 31 | -------------------------------------------------------------------------------- /AiToPPTX/lib/AiToPptx_MakeRootRelations.php: -------------------------------------------------------------------------------- 1 | formatOutput = true; // 格式化输出 15 | $dom->xmlStandalone = true; // 设置 standalone="yes" 16 | 17 | // 创建根节点 并设置命名空间 18 | $relationships = $dom->createElementNS( 19 | 'http://schemas.openxmlformats.org/package/2006/relationships', 20 | 'Relationships' 21 | ); 22 | 23 | // 创建关系数据数组 24 | $relationshipsData = [ 25 | ['Id' => 'rId1', 'Target' => 'ppt/presentation.xml', 'Type' => 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument'], 26 | ['Id' => 'rId2', 'Target' => 'docProps/thumbnail.jpeg', 'Type' => 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail'], 27 | ['Id' => 'rId3', 'Target' => 'docProps/core.xml', 'Type' => 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties'], 28 | ['Id' => 'rId4', 'Target' => 'docProps/app.xml', 'Type' => 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties'], 29 | ]; 30 | 31 | $slideLayoutIndex = 0; 32 | $slideLayouts = (array)$JsonData['slideMasters'][0]['slideLayouts']; 33 | foreach($slideLayouts as $slideLayout) { 34 | $slideLayoutIndex ++; 35 | $relationshipsData[] = ['Id' => 'rId'.($slideLayoutIndex+4), 'Target' => 'ppt/slideLayouts/slideLayout'.($slideLayoutIndex+4).'.xml', 'Type' => 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout']; 36 | } 37 | 38 | // 遍历关系数据并创建 节点 39 | foreach ($relationshipsData as $data) { 40 | $relationship = $dom->createElement('Relationship'); 41 | $relationship->setAttribute('Id', $data['Id']); 42 | $relationship->setAttribute('Target', $data['Target']); 43 | $relationship->setAttribute('Type', $data['Type']); 44 | $relationships->appendChild($relationship); 45 | } 46 | 47 | // 将根节点添加到DOM对象 48 | $dom->appendChild($relationships); 49 | 50 | // 输出XML内容 51 | //print $写入文件目录."/_rels/.rels"; 52 | $dom->save($写入文件目录."/_rels/.rels"); 53 | 54 | } 55 | 56 | 57 | 58 | ?> 59 | -------------------------------------------------------------------------------- /AiToPPTX/lib/AiToPptx_MakeSingleSlide.php: -------------------------------------------------------------------------------- 1 | formatOutput = true; // 格式化输出 25 | 26 | // 创建根元素 并添加命名空间 27 | $pSld = $dom->createElementNS( 28 | 'http://schemas.openxmlformats.org/presentationml/2006/main', 29 | 'p:sld' 30 | ); 31 | $pSld->setAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main'); 32 | $pSld->setAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); 33 | 34 | // 创建 元素及其子元素 35 | $clrMapOvr = $dom->createElement('p:clrMapOvr'); 36 | $masterClrMapping = $dom->createElement('a:masterClrMapping'); 37 | $clrMapOvr->appendChild($masterClrMapping); 38 | 39 | // 创建 元素 40 | $cSld = $dom->createElement('p:cSld'); 41 | 42 | // 创建 元素及其子元素 43 | $pBg = $dom->createElement('p:bg'); 44 | $pBgPr = $dom->createElement('p:bgPr'); 45 | /* 46 | $solidFill = $dom->createElement('a:solidFill'); 47 | if($extInfo['background']['realType']=="Background" && $extInfo['background']['fillStyle']['type']=="color") { 48 | if($extInfo['background']['fillStyle']['color']['scheme']!="") { 49 | $schemeClr = $dom->createElement('a:schemeClr'); 50 | $schemeClr->setAttribute('val', $extInfo['background']['fillStyle']['color']['scheme']); 51 | 52 | if($extInfo['background']['fillStyle']['color']['alpha']) { 53 | $alpha = $dom->createElement('a:alpha'); 54 | $alpha->setAttribute('val', $extInfo['background']['fillStyle']['color']['alpha']); 55 | $schemeClr->appendChild($alpha); 56 | } 57 | if($extInfo['background']['fillStyle']['color']['lumMod']) { 58 | $lumMod = $dom->createElement('a:lumMod'); 59 | $lumMod->setAttribute('val', $extInfo['background']['fillStyle']['color']['lumMod']); 60 | $schemeClr->appendChild($lumMod); 61 | } 62 | if($extInfo['background']['fillStyle']['color']['lumOff']) { 63 | $lumOff = $dom->createElement('a:lumOff'); 64 | $lumOff->setAttribute('val', $extInfo['background']['fillStyle']['color']['lumOff']); 65 | $schemeClr->appendChild($lumOff); 66 | } 67 | 68 | $solidFill->appendChild($schemeClr); 69 | } 70 | if($extInfo['background']['fillStyle']['color']['color']!="") { 71 | $srgbClr = $dom->createElement('a:srgbClr'); 72 | if($extInfo['background']['fillStyle']['color']['color'] == '-1') { 73 | $srgbClr->setAttribute('val', 'FFFFFF'); 74 | } 75 | else { 76 | $srgbClr->setAttribute('val', AiToPptx_NumberToColor($extInfo['background']['fillStyle']['color']['color'])); 77 | } 78 | $solidFill->appendChild($srgbClr); 79 | } 80 | } 81 | $pBgPr->appendChild($solidFill); 82 | */ 83 | 84 | //得到图片路径信息 85 | $得到图片路径信息 = explode('/', $FilePath); 86 | array_pop($得到图片路径信息); 87 | array_pop($得到图片路径信息); 88 | $得到图片路径信息[] = 'media'; 89 | $DirPath = join('/', $得到图片路径信息); 90 | //print $DirPath." AiToPptx_MakeSingleSlide \n"; 91 | 92 | $fillStyle = $PageData['extInfo']['background']['fillStyle']; 93 | $pBgPr = 渲染fillStyle($dom, $fillStyle, $pBgPr, $DirPath); 94 | $strokeStyle = $PageData['extInfo']['background']['strokeStyle']; 95 | $pBgPr = 渲染strokeStyle($dom, $strokeStyle, $pBgPr, $DirPath); 96 | 97 | $pBg->appendChild($pBgPr); 98 | 99 | // 将 添加到 100 | $cSld->appendChild($pBg); 101 | 102 | // 创建 元素 103 | $spTree = $dom->createElement('p:spTree'); 104 | 105 | // 创建 及其子元素 106 | $nvGrpSpPr = $dom->createElement('p:nvGrpSpPr'); 107 | $cNvPr = $dom->createElement('p:cNvPr'); 108 | $cNvPr->setAttribute('id', $SharpCounter++); 109 | $cNvPr->setAttribute('name', ''); 110 | 111 | $cNvGrpSpPr = $dom->createElement('p:cNvGrpSpPr'); 112 | $nvPr = $dom->createElement('p:nvPr'); 113 | 114 | // 构建 层级关系 115 | $nvGrpSpPr->appendChild($cNvPr); 116 | $nvGrpSpPr->appendChild($cNvGrpSpPr); 117 | $nvGrpSpPr->appendChild($nvPr); 118 | 119 | // 创建 及其子元素 120 | $grpSpPr = $dom->createElement('p:grpSpPr'); 121 | $xfrm = $dom->createElement('a:xfrm'); 122 | 123 | // 创建位置信息元素 124 | $off = $dom->createElement('a:off'); 125 | $off->setAttribute('x', '0'); 126 | $off->setAttribute('y', '0'); 127 | 128 | $ext = $dom->createElement('a:ext'); 129 | $ext->setAttribute('cx', '0'); 130 | $ext->setAttribute('cy', '0'); 131 | 132 | $chOff = $dom->createElement('a:chOff'); 133 | $chOff->setAttribute('x', '0'); 134 | $chOff->setAttribute('y', '0'); 135 | 136 | $chExt = $dom->createElement('a:chExt'); 137 | $chExt->setAttribute('cx', '0'); 138 | $chExt->setAttribute('cy', '0'); 139 | 140 | // 构建 层级关系 141 | $xfrm->appendChild($off); 142 | $xfrm->appendChild($ext); 143 | $xfrm->appendChild($chOff); 144 | $xfrm->appendChild($chExt); 145 | $grpSpPr->appendChild($xfrm); 146 | 147 | // 将 添加到 148 | $spTree->appendChild($nvGrpSpPr); 149 | $spTree->appendChild($grpSpPr); 150 | 151 | // 添加 152 | // 遍历 childrenList 并处理每个元素 153 | $SharpCounter = 0; 154 | foreach ($childrenList as $childrenItem) { 155 | $Type = $childrenItem['type']; 156 | $realType = $childrenItem['extInfo']['property']['realType']; 157 | $rotation = $childrenItem['extInfo']['property']['rotation']; 158 | $groupFillStyle = $childrenItem['extInfo']['property']['groupFillStyle']; 159 | if($realType == "Group") { 160 | //print_R($childrenItem); 161 | $绘制元素RESULT = AiToPptx_DrawGroupObject($childrenItem, $DirPath); 162 | } 163 | else { 164 | $绘制元素RESULT = AiToPptx_DrawSingleObject($childrenItem, $DirPath); 165 | } 166 | $importedNode = $dom->importNode($绘制元素RESULT, true); // 深度导入整个节点及其子节点 167 | $spTree->appendChild($importedNode); 168 | } 169 | 170 | // 将 添加到 171 | $cSld->appendChild($spTree); 172 | 173 | // 将所有主要部分添加到 174 | $pSld->appendChild($clrMapOvr); 175 | $pSld->appendChild($cSld); 176 | 177 | // 将 作为根节点添加到文档 178 | $dom->appendChild($pSld); 179 | 180 | //写入文件 181 | $dom->save($FilePath); 182 | 183 | //写入Relation文件 184 | $slideLayoutIdx = $PageData['extInfo']['slideLayoutIdx']; 185 | $RelationContent = ' 186 | 187 | 188 | '.join('', $关系引用ID值列表SlideLayout).' 189 | '; 190 | file_put_contents($RelationPath, $RelationContent); 191 | 192 | //print $dom->saveXML(); print_R($PageData); exit; 193 | return $dom->saveXML(); 194 | } 195 | 196 | 197 | ?> 198 | -------------------------------------------------------------------------------- /AiToPPTX/lib/AiToPptx_MakeSlideLayout.php: -------------------------------------------------------------------------------- 1 | '; 16 | 17 | // 创建DOM对象并设置XML版本和编码 18 | $dom = new DOMDocument('1.0', 'UTF-8'); 19 | $dom->formatOutput = true; 20 | //print_R($Layout); 21 | // 创建根元素 22 | $sldLayout = $dom->createElementNS( 23 | 'http://schemas.openxmlformats.org/presentationml/2006/main', 24 | 'p:sldLayout' 25 | ); 26 | if($Layout['type'] == "BLANK") { 27 | $sldLayout->setAttribute('type', 'blank'); 28 | $sldLayout->setAttribute('preserve', '1'); 29 | } 30 | if($Layout['type'] == "TITLE_AND_CONTENT") { 31 | $sldLayout->setAttribute('type', 'obj'); 32 | $sldLayout->setAttribute('preserve', '1'); 33 | } 34 | if($Layout['type'] == "SECTION_HEADER") { 35 | $sldLayout->setAttribute('type', 'secHead'); 36 | $sldLayout->setAttribute('preserve', '1'); 37 | } 38 | if($Layout['type'] == "CUST") { 39 | $sldLayout->setAttribute('preserve', '1'); 40 | $sldLayout->setAttribute('userDrawn', '1'); 41 | } 42 | if($Layout['noMaster'] == "1") { 43 | $sldLayout->setAttribute('showMasterSp', 'false'); 44 | } 45 | 46 | // 注册命名空间前缀 47 | $sldLayout->setAttributeNS( 48 | 'http://www.w3.org/2000/xmlns/', 'xmlns:a', 49 | 'http://schemas.openxmlformats.org/drawingml/2006/main' 50 | ); 51 | $sldLayout->setAttributeNS( 52 | 'http://www.w3.org/2000/xmlns/', 'xmlns:r', 53 | 'http://schemas.openxmlformats.org/officeDocument/2006/relationships' 54 | ); 55 | $sldLayout->setAttributeNS( 56 | 'http://www.w3.org/2000/xmlns/', 'xmlns:p', 57 | 'http://schemas.openxmlformats.org/presentationml/2006/main' 58 | ); 59 | 60 | // 创建子元素 并附加到根元素 61 | $cSld = $dom->createElement('p:cSld'); 62 | $cSld->setAttribute('name', $Layout['name']); 63 | 64 | // 创建 元素及其子元素 65 | $bg = $dom->createElement('p:bg'); 66 | $bgPr = $dom->createElement('p:bgPr'); 67 | /* 68 | $solidFill = $dom->createElement('a:solidFill'); 69 | if($Layout['background']['realType']=="Background" && $Layout['background']['fillStyle']['type']=="color") { 70 | if($Layout['background']['fillStyle']['color']['scheme']!="") { 71 | $schemeClr = $dom->createElement('a:schemeClr'); 72 | $schemeClr->setAttribute('val', $Layout['background']['fillStyle']['color']['scheme']); 73 | 74 | if($Layout['background']['fillStyle']['color']['alpha']) { 75 | $alpha = $dom->createElement('a:alpha'); 76 | $alpha->setAttribute('val', $Layout['background']['fillStyle']['color']['alpha']); 77 | $schemeClr->appendChild($alpha); 78 | } 79 | if($Layout['background']['fillStyle']['color']['lumMod']) { 80 | $lumMod = $dom->createElement('a:lumMod'); 81 | $lumMod->setAttribute('val', $Layout['background']['fillStyle']['color']['lumMod']); 82 | $schemeClr->appendChild($lumMod); 83 | } 84 | if($Layout['background']['fillStyle']['color']['lumOff']) { 85 | $lumOff = $dom->createElement('a:lumOff'); 86 | $lumOff->setAttribute('val', $Layout['background']['fillStyle']['color']['lumOff']); 87 | $schemeClr->appendChild($lumOff); 88 | } 89 | 90 | $solidFill->appendChild($schemeClr); 91 | } 92 | if($Layout['background']['fillStyle']['color']['color']!="") { 93 | $srgbClr = $dom->createElement('a:srgbClr'); 94 | if($Layout['background']['fillStyle']['color']['color'] == '-1') { 95 | $srgbClr->setAttribute('val', 'FFFFFF'); 96 | } 97 | else { 98 | $srgbClr->setAttribute('val', AiToPptx_NumberToColor($Layout['background']['fillStyle']['color']['color'])); 99 | } 100 | $solidFill->appendChild($srgbClr); 101 | } 102 | } 103 | $bgPr->appendChild($solidFill); 104 | */ 105 | 106 | //得到图片路径信息 107 | $得到图片路径信息 = explode('/', $FilePath); 108 | array_pop($得到图片路径信息); 109 | array_pop($得到图片路径信息); 110 | $得到图片路径信息[] = 'media'; 111 | $DirPath = join('/', $得到图片路径信息); 112 | //print $DirPath." AiToPptx_MakeSlideLayout \n"; 113 | 114 | $fillStyle = $Layout['background']['fillStyle']; 115 | $bgPr = 渲染fillStyle($dom, $fillStyle, $bgPr, $DirPath); 116 | $strokeStyle = $Layout['background']['strokeStyle']; 117 | $bgPr = 渲染strokeStyle($dom, $strokeStyle, $bgPr, $DirPath); 118 | 119 | // 组装 树 120 | $bg->appendChild($bgPr); 121 | $cSld->appendChild($bg); 122 | 123 | // 创建 结构 124 | $spTree = $dom->createElement('p:spTree'); 125 | $nvGrpSpPr = $dom->createElement('p:nvGrpSpPr'); 126 | $cNvPr = $dom->createElement('p:cNvPr'); 127 | $cNvPr->setAttribute('id', '1'); 128 | $cNvPr->setAttribute('name', ''); 129 | $cNvGrpSpPr = $dom->createElement('p:cNvGrpSpPr'); 130 | $nvPr = $dom->createElement('p:nvPr'); 131 | 132 | // 组装 的非可视属性部分 133 | $nvGrpSpPr->appendChild($cNvPr); 134 | $nvGrpSpPr->appendChild($cNvGrpSpPr); 135 | $nvGrpSpPr->appendChild($nvPr); 136 | $spTree->appendChild($nvGrpSpPr); 137 | 138 | // 创建 及其变换属性 139 | $grpSpPr = $dom->createElement('p:grpSpPr'); 140 | $xfrm = $dom->createElement('a:xfrm'); 141 | $off = $dom->createElement('a:off'); 142 | $off->setAttribute('x', '0'); 143 | $off->setAttribute('y', '0'); 144 | $ext = $dom->createElement('a:ext'); 145 | $ext->setAttribute('cx', '0'); 146 | $ext->setAttribute('cy', '0'); 147 | $chOff = $dom->createElement('a:chOff'); 148 | $chOff->setAttribute('x', '0'); 149 | $chOff->setAttribute('y', '0'); 150 | $chExt = $dom->createElement('a:chExt'); 151 | $chExt->setAttribute('cx', '0'); 152 | $chExt->setAttribute('cy', '0'); 153 | 154 | // 组装 155 | $xfrm->appendChild($off); 156 | $xfrm->appendChild($ext); 157 | $xfrm->appendChild($chOff); 158 | $xfrm->appendChild($chExt); 159 | $grpSpPr->appendChild($xfrm); 160 | $spTree->appendChild($grpSpPr); 161 | 162 | // 组装 163 | 164 | foreach ($Layout['children'] as $childrenItem) { 165 | $Type = $childrenItem['type']; 166 | $realType = $childrenItem['extInfo']['property']['realType']; 167 | $rotation = $childrenItem['extInfo']['property']['rotation']; 168 | $groupFillStyle = $childrenItem['extInfo']['property']['groupFillStyle']; 169 | if($realType == "Group") { 170 | //print_R($childrenItem); 171 | $绘制元素RESULT = AiToPptx_DrawGroupObject($childrenItem, $DirPath); 172 | $importedNode = $dom->importNode($绘制元素RESULT, true); // 深度导入整个节点及其子节点 173 | $spTree->appendChild($importedNode); 174 | } 175 | else { 176 | $绘制元素RESULT = AiToPptx_DrawSingleObject($childrenItem, $DirPath); 177 | $importedNode = $dom->importNode($绘制元素RESULT, true); // 深度导入整个节点及其子节点 178 | $spTree->appendChild($importedNode); 179 | } 180 | } 181 | 182 | //print_R($关系引用ID值列表SlideLayout); 183 | //写入Relation文件 184 | $RelationContent = ' 185 | 186 | '.join('', $关系引用ID值列表SlideLayout).' 187 | '; 188 | file_put_contents($RelationPath, $RelationContent); 189 | 190 | // Add spTree 191 | $cSld->appendChild($spTree); 192 | 193 | // 创建 及其子元素 194 | $clrMapOvr = $dom->createElement('p:clrMapOvr'); 195 | $clrMap = $Layout['clrMap']; 196 | if($clrMap) { 197 | $overrideClrMapping = $dom->createElement('a:overrideClrMapping'); 198 | $overrideClrMapping->setAttribute('accent1', $clrMap['accent1']); 199 | $overrideClrMapping->setAttribute('accent2', $clrMap['accent2']); 200 | $overrideClrMapping->setAttribute('accent3', $clrMap['accent3']); 201 | $overrideClrMapping->setAttribute('accent4', $clrMap['accent4']); 202 | $overrideClrMapping->setAttribute('accent5', $clrMap['accent5']); 203 | $overrideClrMapping->setAttribute('accent6', $clrMap['accent6']); 204 | $overrideClrMapping->setAttribute('bg1', $clrMap['bg1']); 205 | $overrideClrMapping->setAttribute('bg2', $clrMap['bg2']); 206 | $overrideClrMapping->setAttribute('tx1', $clrMap['tx1']); 207 | $overrideClrMapping->setAttribute('tx2', $clrMap['tx2']); 208 | $overrideClrMapping->setAttribute('hlink', $clrMap['hlink']); 209 | $overrideClrMapping->setAttribute('folHlink', $clrMap['folHlink']); 210 | $clrMapOvr->appendChild($overrideClrMapping); 211 | } 212 | else { 213 | $masterClrMapping = $dom->createElement('a:masterClrMapping'); 214 | $clrMapOvr->appendChild($masterClrMapping); 215 | } 216 | 217 | // 将所有子元素附加到根元素 218 | $sldLayout->appendChild($cSld); 219 | $sldLayout->appendChild($clrMapOvr); 220 | 221 | // 将根元素附加到DOM对象 222 | $dom->appendChild($sldLayout); 223 | 224 | //写入文件 225 | $dom->save($FilePath); 226 | 227 | //print $dom->saveXML();print_R($Layout);exit; 228 | 229 | return $dom->saveXML(); 230 | 231 | } 232 | 233 | 234 | ?> 235 | -------------------------------------------------------------------------------- /AiToPPTX/lib/AiToPptx_MakeThemeXml.php: -------------------------------------------------------------------------------- 1 | formatOutput = true; // 格式化输出 19 | $dom->preserveWhiteSpace = false; // 忽略不必要的空白 20 | // 加载theme模板文件 21 | $dom->load(__DIR__.'/../xml/theme.xml'); 22 | 23 | $theme = $slideMasters[0]['theme']; 24 | $colorsThemeList = (array)$theme['colors']; 25 | $clrScheme = $dom->createElement('a:clrScheme'); 26 | $clrScheme->setAttribute('name', "Office"); 27 | foreach($colorsThemeList as $key => $value) { 28 | $keyElement = $dom->createElement('a:'.$key); 29 | $srgbClr = $dom->createElement('a:srgbClr'); 30 | $srgbClr->setAttribute('val', AiToPptx_NumberToColor($value)); 31 | $keyElement->appendChild($srgbClr); 32 | $clrScheme->appendChild($keyElement); 33 | } 34 | 35 | // 使用 DOMXPath 解析带有命名空间的 XML 36 | $xpath = new DOMXPath($dom); 37 | // 注册命名空间:前缀 'a' 和它在XML中的URI一致 38 | $xpath->registerNamespace('a', 'http://schemas.openxmlformats.org/drawingml/2006/main'); 39 | // 使用 XPath 查询带有命名空间的节点 40 | $wantToReplaceNodeList = $xpath->query('//a:clrScheme'); 41 | if ($wantToReplaceNodeList->length > 0) { 42 | $wantToReplaceNode = $wantToReplaceNodeList->item(0); // 获取第一个 clrScheme 节点 43 | $parent = $wantToReplaceNode->parentNode; // 获取父节点 44 | $parent->replaceChild($clrScheme, $wantToReplaceNode); // 替换节点 45 | } 46 | 47 | //写入文件 48 | $FilePath = $DirPath."/ppt/theme/theme1.xml"; 49 | $dom->save($FilePath); 50 | 51 | } 52 | 53 | 54 | ?> 55 | -------------------------------------------------------------------------------- /AiToPPTX/lib/functions.inc.php: -------------------------------------------------------------------------------- 1 | open($destination, ZipArchive::CREATE | ZipArchive::OVERWRITE)) { 61 | return false; 62 | } 63 | 64 | $source = realpath($source); 65 | 66 | // 如果是文件夹,递归添加其中的文件和文件夹 67 | if (is_dir($source)) { 68 | $iterator = new RecursiveIteratorIterator( 69 | new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS), 70 | RecursiveIteratorIterator::SELF_FIRST 71 | ); 72 | foreach ($iterator as $file) { 73 | $filePath = realpath($file); 74 | $relativePath = substr($filePath, strlen($source) + 1); 75 | 76 | if (is_dir($filePath)) { 77 | $zip->addEmptyDir($relativePath); 78 | } else if (is_file($filePath)) { 79 | $zip->addFile($filePath, $relativePath); 80 | } 81 | } 82 | } 83 | else if (is_file($source)) { 84 | // 如果是单个文件,直接添加 85 | $zip->addFile($source, basename($source)); 86 | } 87 | 88 | $zip->close(); 89 | 90 | //删除缓存的过程文件 91 | global $AiToPptx_DeleteCacheDirectory_Status; 92 | if($AiToPptx_DeleteCacheDirectory_Status) { 93 | AiToPptx_DeleteCacheDirectory($source); 94 | } 95 | 96 | return true; 97 | } 98 | 99 | function AiToPptx_NumberToColor($color) { 100 | // 提取 RGB 部分 101 | $realColor = $color & 0xFFFFFF; // 获取 RGB 部分 102 | 103 | // 提取红色、绿色和蓝色通道 104 | $r = ($realColor >> 16) & 0xFF; // 红色通道 105 | $g = ($realColor >> 8) & 0xFF; // 绿色通道 106 | $b = $realColor & 0xFF; // 蓝色通道 107 | 108 | // 格式化为两位十六进制并连接 109 | $hexColor = sprintf("%02X%02X%02X", $r, $g, $b); 110 | 111 | return $hexColor; 112 | } 113 | 114 | ?> 115 | -------------------------------------------------------------------------------- /AiToPPTX/xml/app.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 0 5 | 0 6 | Microsoft Office PowerPoint 7 | 全屏显示(4:3) 8 | 0 9 | 0 10 | 0 11 | 0 12 | 0 13 | false 14 | 15 | 16 | 17 | 已用的字体 18 | 19 | 20 | 1 21 | 22 | 23 | 主题 24 | 25 | 26 | 1 27 | 28 | 29 | 幻灯片标题 30 | 31 | 32 | 0 33 | 34 | 35 | 36 | 37 | 38 | Arial 39 | Office Theme 40 | 41 | 42 | 43 | false 44 | false 45 | false 46 | 16.0000 47 | -------------------------------------------------------------------------------- /AiToPPTX/xml/core.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 2024-09-20T00:00:00Z 7 | Ai to pptx 8 | 2024-09-20T00:00:00Z 9 | 2 10 | -------------------------------------------------------------------------------- /AiToPPTX/xml/presProps.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /AiToPPTX/xml/tableStyles.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /AiToPPTX/xml/theme.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | -------------------------------------------------------------------------------- /AiToPPTX/xml/viewProps.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /BusinessLicense/AI-TO-PPTX 软件商业授权协议.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmartSchoolAI/ai-to-pptx-backend/80cd92aa48493a632f8f8f8191b2a0cf6bc07378/BusinessLicense/AI-TO-PPTX 软件商业授权协议.docx -------------------------------------------------------------------------------- /BusinessLicense/AI-TO-PPTX 软件商业授权协议.md: -------------------------------------------------------------------------------- 1 | ## AI-TO-PPTX 软件商业授权协议 2 | 3 | **授权方**(以下简称“甲方”):郑州单点科技软件有限公司 4 | **被授权方**(以下简称“乙方”):____________________ 5 | **授权软件**:AI-TO-PPTX 6 | **授权日期**:2025-02-10 7 | 8 | ### **1. 授权范围** 9 | 10 | 1.1 甲方授予乙方一项**非独占、不可转让、不可再授权**的许可,以使用 AI-TO-PPTX 软件(以下简称“本软件”)用于合法的商业用途。 11 | 12 | 1.2 本软件授权范围包括但不限于: 13 | - 以本软件为基础,经过二次开发,制作最终产品并提供给客户或合作伙伴; 14 | - 增加,修改或删除版权人信息; 15 | - 自由选择开源或闭源; 16 | - 经过二次开发以后的新软件的全部知识产权归乙方所有。 17 | 18 | 1.3 **禁止行为**:乙方不得进行以下行为: 19 | - 不对本软件做二次开发,直接使用本软件销售给客户; 20 | 21 | ### **2. 授权期限** 22 | 23 | 2.1 **授权起始日期**:本协议自签署之日起生效。 24 | 25 | 2.2 **授权截止日期**:**永久有效**。 26 | 27 | 2.3 **终止条款**:若乙方违反本协议1.3条款,甲方有权终止本授权,且不予退款。 28 | 29 | ### **3. 授权费用与支付** 30 | 31 | 3.1 乙方应按以下方式向甲方支付授权费用: 32 | - **授权模式**:商业授权 33 | - **费用金额**:¥20000(人民币: 贰万元整) 34 | - **支付周期**:签约时一次性支付 35 | - **支付方式**:银行转账 36 | - **支付账户**: 37 | 单位名称:郑州单点科技软件有限公司 38 | 账户名称:1702100209200051714 39 | 开户银行:中国工商银行郑州经济技术开发区支行 40 | 41 | 3.2 授权费用支付后,甲方给乙方开具国家正规发票。 42 | 43 | ### **4. 责任限制** 44 | 45 | 4.1 **软件可用性**:甲方将尽力保持本软件的稳健性,升级或是修复必要的BUG,乙方可以**永久且无偿**获得最新的代码。 46 | 47 | 4.2 **责任范围**:在任何情况下,甲方对乙方因使用本软件造成的直接或间接损失(包括但不限于业务损失、数据丢失、利润损失)不承担责任。 48 | 49 | ### **5. 知识产权** 50 | 51 | 5.1 本软件的所有权、著作权、商标权及其他知识产权均归甲方所有。本协议仅授予乙方**有限的使用权**,不构成对本软件任何知识产权的转让或让渡。 52 | 53 | ### **6. 争议解决** 54 | 55 | 6.1 本协议适用**中国法律**,不适用其法律冲突规则。 56 | 57 | 6.2 若因本协议产生争议,双方应尽量友好协商解决。如协商不成,双方同意由甲方所在地法院管辖并裁决。 58 | 59 | 60 | **甲方**(盖章):_________ 61 | 授权代表(签名):_________ 62 | 日期:_________ 63 | 64 | **乙方**(盖章):_________ 65 | 授权代表(签名):_________ 66 | 日期:_________ -------------------------------------------------------------------------------- /DockerMaker: -------------------------------------------------------------------------------- 1 | sudo docker login 2 | chatbookai 3 | password 4 | 5 | sudo docker build -t chatbookai/ai-to-pptx:0.2 . 6 | 7 | sudo docker push chatbookai/ai-to-pptx:0.2 8 | 9 | sudo docker rm 22cc2dece268 10 | 11 | sudo docker ps -a 12 | 13 | sudo docker stop 22cc2dece268 14 | 15 | sudo docker pull chatbookai/ai-to-pptx:0.2 16 | 17 | sudo docker run -p 8080:80 chatbookai/ai-to-pptx:0.2 18 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # 构建Ai-To-PPTX项目 2 | # 把前端项目编译为静态文件, 目录为: /var/www/html , 同时在前端中把后端地址修改为 /aipptx/ 3 | # 把后端项目的PHP文件放到 /var/www/html/aipptx 目录 4 | # 安装Redis服务器端和PHP的Redis扩展 5 | # /var/www/html/aipptx/cache 和 /var/www/html/aipptx/output 两个目录要求可写 6 | 7 | 8 | # 使用官方的 PHP 8.2 镜像,并包含 Apache 9 | FROM php:8.2-apache 10 | 11 | # 安装所需的 PHP 扩展 12 | RUN apt-get update && apt-get install -y \ 13 | libzip-dev \ 14 | libcurl4-openssl-dev \ 15 | unzip \ 16 | redis \ 17 | && docker-php-ext-install zip curl pdo_mysql 18 | 19 | # 安装 PHP 的 Redis 扩展 20 | RUN pecl install redis && docker-php-ext-enable redis 21 | 22 | # 启用 Apache 的 rewrite 模块 23 | RUN a2enmod rewrite 24 | 25 | # 设置工作目录 26 | RUN mkdir -p /var/www/html/aipptx 27 | WORKDIR /var/www/html/aipptx 28 | 29 | # 复制代码到容器中 30 | COPY . . 31 | 32 | # 需要修改在config.inc.php修改你自己的DeepSeek的API的KEY 33 | 34 | RUN mkdir -p /var/www/html/aipptx/cache && \ 35 | chown -R www-data:www-data /var/www/html/aipptx/cache && \ 36 | chmod -R 775 /var/www/html/aipptx/cache 37 | 38 | RUN mkdir -p /var/www/html/aipptx/output && \ 39 | chown -R www-data:www-data /var/www/html/aipptx/output && \ 40 | chmod -R 775 /var/www/html/aipptx/output 41 | 42 | 43 | # 安装 git Node.js 和 npm, 主要用于安装和编译前端项目 44 | RUN apt-get update && apt-get install -y git nodejs npm 45 | 46 | # 克隆 ai-to-pptx 项目到 /var/www/html/ai-to-pptx 47 | RUN mkdir -p /var/www/html/ai-to-pptx 48 | RUN git clone https://github.com/chatbookai/ai-to-pptx.git /var/www/html/ai-to-pptx 49 | 50 | # 修改 Config.ts 文件中的 BackendApi 值 51 | # 源代码中是后端的演示地址, 需要在前端中修改为DOCKER中本地镜像中的地址. 52 | # 因为前端项目编译为静态的HTML和CSS文件以后,和后端的项目是在同一个Webroot下面,所以路径只需要写为 /aipptx/ , 如果你的后端是一个独立的URL地址, 则需要写完整的地址. 53 | 54 | RUN sed -i 's|export const BackendApi = .*|export const BackendApi = "/aipptx/";|' /var/www/html/ai-to-pptx/src/views/AiPPTX/Config.ts 55 | 56 | # 安装 ai-to-pptx 项目的依赖 57 | WORKDIR /var/www/html/ai-to-pptx 58 | RUN npm install 59 | RUN npm run build 60 | RUN mv /var/www/html/ai-to-pptx/webroot/* /var/www/html 61 | 62 | # 暴露端口 80(Apache 默认端口)和 6379(Redis 默认端口) 63 | EXPOSE 80 64 | 65 | # 启动 Apache 和 Redis 66 | CMD ["sh", "-c", "redis-server --daemonize yes && apache2-foreground"] 67 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published 637 | by the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Ai-To-PPTX 后端项目说明 2 | 1 Ai-To-PPTX的私有化部署后端版本. 3 | 2 要求PHP和REDIS环境, 和当前目录下面的文件写入权限. 4 | 3 目前内置4套PPTX模板, 你也可以按要求自己增加新的模板. 5 | 4 如果你自己的模板, 在遇到导出为PPTX的时候, 有一些特性没有支持, 导致导出的PPTX的显示有不完整的地方, 可以联系我们. 6 | 5 使用DeepSeek模型. 7 | 8 | # Ai-To-PPTX 如何部署 9 | 1 直接下载当前仓库代码到服务器 10 | 2 要求使用PHP >= 7.4 和 REDIS, 可以在 config.inc.php 中修改这个端口号 11 | 3 要求安装Redis服务器端和PHP的Redis扩展和Zip扩展 12 | 3 配置好URL以后, 在前端项目的config.ts文件, 把项目后端URL修改为你自己的URL 13 | 4 系统使用DeepSeek模型, 在 config.inc.php 中修改Deepseek的Key 14 | 5 ./cache 和 ./output 两个目录要求可写 15 | 6 如果你部署失败, 可以参考 Dockerfile 文件里面的部署过程 16 | 17 | # Ai-To-PPTX Dockerfile部署说明 18 | 1 把前端项目编译为静态文件, 目录为: /var/www/html , 同时在前端中把后端地址修改为 /aipptx/ 19 | 2 把后端项目的PHP文件放到 /var/www/html/aipptx 目录 20 | 3 安装Redis服务器端和PHP的Redis扩展 21 | 4 /var/www/html/aipptx/cache 和 /var/www/html/aipptx/output 两个目录要求可写 22 | 23 | # Ai-To-PPTX Docker使用说明 24 | 1 下载镜像: docker pull chatbookai/ai-to-pptx:0.2 25 | 2 启动镜像: docker run -p 8080:80 chatbookai/ai-to-pptx:0.2 26 | 3 开始使用: 在浏览器里面输入: http://localhost:8080 27 | 4 列出镜像: docker ps -a 28 | 5 进入镜像: docker exec -it /bin/bash 29 | 6 如果是在Docker Desktop中, 可以在Docker Hub中搜索 chatbookai/ai-to-pptx 就可以看到镜像, 下载以后, 启动的时候, 需要指定本地的端口为8080, 然后就可以在浏览器打开 http://localhost:8080 30 | 7 注意: Docker的镜像中已经同时包含了前端和后端项目 31 | 32 | # Ai-To-PPTX 开源协议 33 | 1 本项目发行协议: [AGPL-3.0 License] 34 | 2 根据GPL协议的内容, 您只有在修改了本系统代码的时候, 需要公开的代码仓库如Github上面, 开放你的修改内容. 35 | 3 如果你不想公开代码的修改内容, 请联系我们取得商业授权. 36 | 4 如果没有修改本系统的代码, 那么你一直可以使用, 在GPL授权协议下面使用本软件. 37 | 5 你的系统需要对所有用户开放的你的源代码, 你修改后的代码也必须要采用GPL协议. 38 | 6 如何你修改了本系统的代码, 你需要在代码和正式使用的系统中标记你使用的哪部分代码是我们的, 哪部分代码是你们自己开发的.你们自己开发的代码也需要采用GPL协议. 39 | 7 GPL协议允许修改软件代码, 但没有允许你修改本系统的著作权人信息, 所以像版权归我们所有之类的标记, 不能去除. 40 | 41 | # Ai-To-PPTX 开源版本限制性 42 | 1 没有会员功能,不能让用户注册,计费和充值功能. 但是增加这些功能不难, 相信大家都会. 43 | 2 目前只支持在PPTX的详细页面里面, 输出三个小节的情况, 如果是两个或是四个小节的情况, 暂时还没有做充分测试, 所以目前先保持三个小节的情况. 44 | 3 没有移动端功能. 45 | 4 更多特性,可以考虑采购商业版本. 46 | 47 | # Ai-To-PPTX 交流群组 48 | QQ群: 186411255 49 | 50 | # Ai-To-PPTX 商业用途 51 | 开源商用: 无需联系,可以直接使用,需要在您官网页面底部增加您的开源库的URL(根据开源协议你需要公开你的源代码),GPL协议授权你可以修改代码,并共享你修改以后的代码,但没有授权你可以修改版权信息,所以版权信息不能修改. GPL协议允许修改软件代码, 但没有允许你修改本系统的著作权人信息, 所以像版权归我们所有之类的标记, 不能去除. 52 | 闭源商用: 需要联系,额外取得商业授权,根据商业授权协议的内容,来决定你是否可以合法的修改版权信息. 53 | 商业授权: 请单独联系. 允许购买商业授权的用户开展SAAS等会员收费业务,以及自用. 但是禁止以系统的方式出售给其它用户,即禁止二次销售. 54 | 模板开发: 如果计划购买商业授权的用户自已开发出一些特有的PPTX模板,可以共享给我们,经过审核收录以后,可以充抵一定的商业授权费用. 55 | 技术服务: 可选项目,每年支付一次,主要用于软件二次开发商做二次开发的时候的技术咨询和服务,其它业务场景则不需要支付此费用,具体请咨询. 56 | 额外说明: 本系统指的是计算机软件代码,系统里面带的模板并不是开源项目的一部分.虽然系统会自带四套模板供大家免费使用,但更多模板需要购买模板的授权. 57 | 58 | # Ai-To-PPTX 商用版本 59 | 1 暂时停止了商用版本的开发 60 | 2 何时重新启动, 另行通知 61 | -------------------------------------------------------------------------------- /asyncPptInfo.php: -------------------------------------------------------------------------------- 1 | hGet("PPTX_CONTENT_".date('Ymd'), $pptId); 40 | $OutPutLastPageId = $redis->hGet("PPTX_CurrentPage_".date('Ymd'), $pptId); 41 | $MarkdownDataJson = json_decode($MarkdownData, true); 42 | 43 | $outlineMarkdown = $redis->hGet("PPTX_OUTLINE_".date('Ymd'), $pptId); 44 | if($MarkdownDataJson['data']=="") { 45 | $MarkdownDataJson['current'] = 1; 46 | $TotalPagesNumber = 根据大纲得到PPTX页码($outlineMarkdown); 47 | $MarkdownDataJson['total'] = $TotalPagesNumber; 48 | } 49 | 50 | //Markdown转Json Data 51 | $Markdown_To_JsonData_Data = Markdown_To_JsonData($outlineMarkdown, $MarkdownDataJson['data'], $JsonData, $MarkdownDataJson['current']==$MarkdownDataJson['total']?true:false, $个性化信息, $OutPutLastPageId); 52 | 53 | 54 | if($MarkdownDataJson['current'] == $MarkdownDataJson['total']) { 55 | //Json Data转Zip格式 56 | //当是最后一页的时候,需要把pages变量修改为全部页面, 然后存储数据,供下载文件的时候使用 57 | $Markdown_To_JsonData_Data['pages'] = $Markdown_To_JsonData_Data['pages2']; 58 | $Markdown_To_JsonData_Data['pages2'] = []; 59 | $pptxProperty = base64_encode(gzencode(json_encode($Markdown_To_JsonData_Data))); 60 | $redis->hSet("PPTX_DOWNLOAD_".date('Ymd'), $pptId, $pptxProperty); 61 | $LastPagePPTX = 1; 62 | } 63 | else { 64 | //Json Data转Zip格式 65 | //当非最后一页的时候,只输出增量的部分 66 | $pptxProperty = base64_encode(gzencode(json_encode($Markdown_To_JsonData_Data))); 67 | $LastPagePPTX = 0; 68 | } 69 | $redis->hSet("PPTX_CurrentPage_".date('Ymd'), $pptId, $currentId); 70 | 71 | $RS = []; 72 | $RS['code'] = 0; 73 | $RS['message'] = 'ok'; 74 | $RS['data']['current'] = $MarkdownDataJson['current']; 75 | $RS['data']['total'] = $MarkdownDataJson['total']; 76 | $RS['data']['markdown'] = $MarkdownDataJson['data']; 77 | $RS['data']['pptxProperty'] = $pptxProperty; 78 | $RS['data']['LastPagePPTX'] = $LastPagePPTX; 79 | 80 | $RS['data']['outlineMarkdown'] = $outlineMarkdown; 81 | $RS['data']['JsonData'] = $JsonData; 82 | $RS['data']['OutPutLastPageId'] = $OutPutLastPageId; 83 | $RS['data']['json'] = $Markdown_To_JsonData_Data; 84 | 85 | print_R(json_encode($RS)); 86 | ?> 87 | -------------------------------------------------------------------------------- /config.inc.php: -------------------------------------------------------------------------------- 1 | connect('127.0.0.1', 6379); 19 | 20 | $API_URL = $redis->get("API_URL"); 21 | $API_MODE = $redis->get("API_MODE"); 22 | $API_KEY = $redis->get("API_KEY"); 23 | 24 | $Global_Templates = [ 25 | [ 26 | "id" => "0", 27 | "subject" => "课程学习汇报" 28 | ], 29 | [ 30 | "id" => "1", 31 | "subject" => "读书分享演示" 32 | ], 33 | [ 34 | "id" => "2", 35 | "subject" => "蓝色通用商务" 36 | ], 37 | [ 38 | "id" => "3", 39 | "subject" => "蓝色工作汇报总结" 40 | ] 41 | ]; 42 | 43 | 44 | function FilterString($input) { 45 | return preg_replace('/[^a-zA-Z0-9_]/', '', $input); 46 | } 47 | 48 | 49 | ?> 50 | -------------------------------------------------------------------------------- /downloadPptx.php: -------------------------------------------------------------------------------- 1 | hGet("PPTX_DOWNLOAD_".date('Ymd'), $pptId); 16 | $gzData = base64_decode($pptxProperty); 17 | $jsonData = gzdecode($gzData); 18 | $originalData = json_decode($jsonData, true); 19 | 20 | $TargetCacheDir = realpath("./cache"); 21 | $TargetPptxFilePath = './output/'.$pptId.'.pptx'; 22 | 23 | if($originalData) { 24 | AiToPptx_MakePptx($originalData, $TargetCacheDir, $TargetPptxFilePath); 25 | $fileUrl = 'downloadPptxFile.php?id=' . $pptId; 26 | echo json_encode(['success' => true, 'data' => ['fileUrl' => $fileUrl]]); 27 | } 28 | 29 | exit; 30 | 31 | ?> 32 | -------------------------------------------------------------------------------- /downloadPptxFile.php: -------------------------------------------------------------------------------- 1 | hGet("PPTX_DOWNLOAD_".date('Ymd'), $pptId); 16 | $gzData = base64_decode($pptxProperty); 17 | $jsonData = gzdecode($gzData); 18 | $originalData = json_decode($jsonData, true); 19 | 20 | if($originalData == NULL) { 21 | die("PPTX内容不存在"); 22 | exit; 23 | } 24 | 25 | $TargetCacheDir = realpath("./cache"); 26 | $TargetPptxFilePath = './output/'.$pptId.'.pptx'; 27 | 28 | if (!file_exists($TargetPptxFilePath)) { 29 | AiToPptx_MakePptx($originalData, $TargetCacheDir, $TargetPptxFilePath); 30 | } 31 | 32 | // 检查文件是否存在 33 | if (!file_exists($TargetPptxFilePath)) { 34 | die("PPTX文件不存在"); 35 | } 36 | 37 | // 获取文件名 38 | $fileName = basename($TargetPptxFilePath); 39 | 40 | // 设置 HTTP 头 41 | header('Content-Description: File Transfer'); 42 | header('Content-Type: application/vnd.openxmlformats-officedocument.presentationml.presentation'); 43 | header('Content-Disposition: attachment; filename="' . $fileName . '"'); 44 | header('Expires: 0'); 45 | header('Cache-Control: must-revalidate'); 46 | header('Pragma: public'); 47 | header('Content-Length: ' . filesize($TargetPptxFilePath)); 48 | 49 | // 读取并输出文件内容 50 | readfile($TargetPptxFilePath); 51 | exit; 52 | ?> 53 | -------------------------------------------------------------------------------- /example/generate_pptx_from_json.php: -------------------------------------------------------------------------------- 1 | 28 | -------------------------------------------------------------------------------- /example/markdown_to_pptx_content_json.php: -------------------------------------------------------------------------------- 1 | 20 | -------------------------------------------------------------------------------- /example/redis.php: -------------------------------------------------------------------------------- 1 | hGetAll("PPTX_DOWNLOAD_".date('Ymd')); 5 | print_R($Data); 6 | 7 | exit; 8 | 9 | require_once('../config.inc.php'); 10 | 11 | for ($i = 0; $i < 130; $i++) { 12 | $date = date('Ymd', strtotime("-$i day")); 13 | 14 | $result = $redis->del("PPTX_CONTENT_" . $date); 15 | $result = $redis->del("PPTX_OUTLINE_" . $date); 16 | 17 | if ($result) { 18 | echo "键 PPTX_CONTENT_$date 已成功删除。\n"; 19 | } else { 20 | echo "键 PPTX_CONTENT_$date 不存在或删除失败。\n"; 21 | } 22 | } 23 | 24 | 25 | 26 | ?> 27 | -------------------------------------------------------------------------------- /generateContent.php: -------------------------------------------------------------------------------- 1 | del("PPTX_CONTENT_" . $date); 21 | $result = $redis->del("PPTX_OUTLINE_" . $date); 22 | $result = $redis->del("PPTX_DOWNLOAD_" . $date); 23 | $result = $redis->del("PPTX_CurrentPage_" . $date); 24 | 25 | //把 Application/json的payload data 转为 _POST 26 | $_POST = json_decode(file_get_contents("php://input"), true); 27 | 28 | $_POST['asyncGenPptx'] = true; 29 | 30 | if($_POST['asyncGenPptx'] == true) { 31 | $pptId = date("Ymd_His_").rand("1111",9999); 32 | 33 | $outlineMarkdown = $_POST['outlineMarkdown']; 34 | 35 | //此变量为测试时候使用, 正式发布以后, 则没有使用 36 | $outlineMarkdown_TEST_MODE = '# 实时生成PPT行业总结性报告 37 | 38 | ## 1. 实时生成PPT技术概述 39 | ### 1.1 技术定义与背景 40 | 1.1.1 实时生成PPT的基本概念。 41 | 1.1.2 技术的发展历程。 42 | 1.1.3 当前市场的主要应用场景。 43 | 44 | ### 1.2 技术原理与架构 45 | 1.2.1 实时生成PPT的核心技术。 46 | 1.2.2 系统架构与工作流程。 47 | 1.2.3 数据处理与算法优化。 48 | 49 | ### 1.3 技术优势与挑战 50 | 1.3.1 实时生成PPT的主要优势。 51 | 1.3.2 技术实现中的关键挑战。 52 | 1.3.3 未来技术发展趋势。 53 | 54 | ## 2. 实时生成PPT市场分析 55 | ### 2.1 市场规模与增长 56 | 2.1.1 全球市场规模与增长率。 57 | 2.1.2 主要地区市场分析。 58 | 2.1.3 市场驱动因素与制约因素。 59 | 60 | ### 2.2 竞争格局与主要玩家 61 | 2.2.1 主要竞争者的市场份额。 62 | 2.2.2 竞争者的技术优势与劣势。 63 | 2.2.3 新兴竞争者与市场机会。 64 | 65 | ### 2.3 用户需求与行为分析 66 | 2.3.1 用户需求的主要特点。 67 | 2.3.2 用户行为模式与偏好。 68 | 2.3.3 用户反馈与改进建议。 69 | 70 | ## 3. 实时生成PPT应用案例 71 | ### 3.1 企业应用案例 72 | 3.1.1 大型企业的应用场景。 73 | 3.1.2 中小企业的应用案例。 74 | 3.1.3 企业应用的效果评估。 75 | 76 | ### 3.2 教育领域应用案例 77 | 3.2.1 在线教育平台的应用。 78 | 3.2.2 学校与培训机构的应用。 79 | 3.2.3 教育应用的效果分析。 80 | 81 | ### 3.3 其他行业应用案例 82 | 3.3.1 医疗行业的应用。 83 | 3.3.2 政府与公共部门的应用。 84 | 3.3.3 其他行业的创新应用。 85 | 86 | ## 4. 实时生成PPT技术发展趋势 87 | ### 4.1 技术创新与突破 88 | 4.1.1 人工智能与机器学习的应用。 89 | 4.1.2 云计算与边缘计算的结合。 90 | 4.1.3 数据安全与隐私保护技术。 91 | 92 | ### 4.2 行业标准与规范 93 | 4.2.1 行业标准的制定与推广。 94 | 4.2.2 技术规范与最佳实践。 95 | 4.2.3 国际合作与标准化进程。 96 | 97 | ### 4.3 未来市场预测 98 | 4.3.1 未来市场规模预测。 99 | 4.3.2 技术发展趋势预测。 100 | 4.3.3 市场机会与风险分析。 101 | 102 | ## 5. 实时生成PPT的挑战与解决方案 103 | ### 5.1 技术挑战 104 | 5.1.1 实时性与准确性的平衡。 105 | 5.1.2 数据处理与存储的挑战。 106 | 5.1.3 系统稳定性与可靠性。 107 | 108 | ### 5.2 市场挑战 109 | 5.2.1 市场竞争与价格压力。 110 | 5.2.2 用户教育与市场推广。 111 | 5.2.3 法规与政策的影响。 112 | 113 | ### 5.3 解决方案与策略 114 | 5.3.1 技术优化与创新策略。 115 | 5.3.2 市场定位与差异化竞争。 116 | 5.3.3 用户支持与服务提升。 117 | 118 | ## 6. 实时生成PPT的未来展望 119 | ### 6.1 技术未来发展方向 120 | 6.1.1 智能化与自动化趋势。 121 | 6.1.2 跨平台与多设备支持。 122 | 6.1.3 个性化与定制化服务。 123 | 124 | ### 6.2 市场未来发展趋势 125 | 6.2.1 新兴市场的潜力与机会。 126 | 6.2.2 行业整合与并购趋势。 127 | 6.2.3 用户需求的变化与应对。 128 | 129 | ### 6.3 社会与经济影响 130 | 6.3.1 对工作效率的提升。 131 | 6.3.2 对教育与培训的影响。 132 | 6.3.3 对社会创新的推动作用。'; 133 | 134 | $result = $redis->hSet("PPTX_OUTLINE_".date('Ymd'), $pptId, $outlineMarkdown); 135 | 136 | $promptText = " 137 | 你是一位PPTX大纲的编写人员, 需要根据以下要求对PPTX大纲结构进行解释和扩充. 138 | 139 | PPTX大纲结构规则: 140 | 1 # 开头的表示PPTX的标题 141 | 2 ## 开头的表示PPTX的某个章节 142 | 3 ### 开头的表示的是某个章节下面的小节 143 | 4 类似于这样'1.1.1'开头的是PPTX小节的内容项 144 | 145 | 你的任务: 146 | 1 以# ## ###开头的标题,章节或是小节,则不需要做任何修改,直接按原有结构返回即可. 147 | 2 把类似于这样'1.1.1'开头的是PPTX小节的内容项进行解释和扩充, 形成1.1.1.1的内容, 扩充后的内容要求在20 - 50个字之间. 148 | 149 | 示例输入: 150 | ### 1.1 AI生成PPTX的定义与背景 151 | 1.1.1 定义AI生成PPTX的概念。 152 | 1.1.2 介绍AI在办公自动化中的应用背景。 153 | 1.1.3 分析PPTX格式在现代办公中的重要性。 154 | 155 | 示例输出: 156 | ### 1.1 AI生成PPTX的定义与背景 157 | 1.1.1 定义AI生成PPTX的概念。 158 | AI生成PPTX是指利用人工智能技术自动创建演示文稿文件(PPTX)。这项技术结合自然语言处理和机器学习等领域,通过输入主题或文本,生成结构化和视觉化的演示内容,旨在提升用户的工作效率和创造力。 159 | 1.1.2 介绍AI在办公自动化中的应用背景。 160 | 在现代办公自动化中,AI技术被广泛应用于数据分析、文档生成、自动化流程等领域。诸如自然语言处理、图像识别等AI功能,极大地提高了工作效率,降低了繁琐的手动操作,使得办公软件能够更智能化地支持用户。 161 | 1.1.3 分析PPTX格式在现代办公中的重要性。 162 | PPTX格式是Microsoft PowerPoint使用的演示文稿格式,被广泛用于商务会议、学术报告及教育培训中。其多媒体支持、丰富的动画效果和易操作的界面,使得PPTX成为信息传递的重要工具,能有效增强沟通效果与信息吸引力。 163 | 164 | 注意事项: 165 | 1 请注意: 本次要求只是对原有内容的内容项做扩充, 不需要对PPTX的大纲结构做任何修改. 166 | 2 只输出必要的数据,不需要输出跟大纲无关的内容,输出的结果以Markdown的格式输出。 167 | 3 不需要输出总结性的文本。 168 | 4 '1.1.1 定义AI生成PPTX的概念。'前面不要加 ### 169 | 170 | 以下是需要处理的文本: 171 | $outlineMarkdown 172 | "; 173 | 174 | //对原始数据进行分页后统计,得到总有多少页 175 | //输出的时候,第一页和第二页不需要做扩充,所以可以直接输出 176 | //依赖于AI的部分是从第三页开始 177 | $TotalPagesNumber = 根据大纲得到PPTX页码($outlineMarkdown); 178 | 179 | $curl = curl_init(); 180 | 181 | $messages = []; 182 | $messages[] = ['content'=> $promptText, 'role'=>'user']; 183 | 184 | //删除昨天的记录数据 185 | $result = $redis->del("PPTX_CONTENT_".date('Ymd', strtotime('-1 day'))); 186 | 187 | $redis->hSet("PPTX_CONTENT_".date('Ymd'), $pptId, json_encode(['data'=>'', 'total'=>0, 'current'=>0, 'finished'=>false])); 188 | print 'data: {"current":1, "pptId":"'.$pptId.'", "status":3, "text":"", "total":'.$TotalPagesNumber.'}'."\n\n"; 189 | 190 | $CURLOPT_POSTFIELDS = [ 191 | "model" => $API_MODE, 192 | "messages" => $messages, 193 | "frequency_penalty" => 0, 194 | "max_tokens" => 2048, 195 | "presence_penalty" => 0, 196 | "response_format" => [ 197 | "type" => "text" 198 | ], 199 | "stream" => true, 200 | "temperature" => 0, 201 | "top_p" => 1, 202 | "tool_choice" => "none", 203 | "logprobs" => false, 204 | ]; 205 | $CURLOPT_POSTFIELDS = json_encode($CURLOPT_POSTFIELDS, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); 206 | $FullResponeText = ''; 207 | $分段结构输出情况 = []; 208 | curl_setopt_array($curl, array( 209 | CURLOPT_URL => $API_URL . '/chat/completions', 210 | CURLOPT_RETURNTRANSFER => false, 211 | CURLOPT_WRITEFUNCTION => function($curl, $data) use (&$FullResponeText, &$分段结构输出情况, &$pptId, &$TotalPagesNumber, &$redis) { 212 | static $buffer = ''; // 用于存储不完整的数据块 213 | $buffer .= $data; // 将当前数据块追加到缓冲区 214 | 215 | // 检查是否包含结束标记 [DONE] 216 | if (strpos($buffer, '[DONE]') !== false) { 217 | // 输出最终的 FullResponeText 218 | //print "Final FullResponeText: $FullResponeText\n"; 219 | $Result = []; 220 | $Result['result'] = Markdown_To_Generate_Content_Json($FullResponeText); 221 | print 'data: {"current":'.$TotalPagesNumber.', "pptId":"'.$pptId.'", "status":3, "text":"## ", "total":'.$TotalPagesNumber.'}'."\n\n"; 222 | print "data: ".json_encode($Result, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)."\n\n"; 223 | $redis->hSet("PPTX_CONTENT_".date('Ymd'), $pptId, json_encode(['data'=>$FullResponeText, 'total'=>$TotalPagesNumber, 'current'=>$TotalPagesNumber, 'finished'=>true])); 224 | //$redis->hSet("PPTX_CurrentPage_".date('Ymd'), $pptId, $CurrentPage); 225 | return strlen($data); 226 | } 227 | 228 | while (preg_match('/"content":"([^"]*)"/', $buffer, $matches)) { 229 | $outputData = $matches[1]; 230 | $FullResponeText .= $outputData; 231 | //echo $outputData; 232 | echo 'data: {"status":3,"text":"'.$outputData.'"}'."\n\n"; 233 | $FullResponeTextArray = explode("\\n", $FullResponeText); 234 | $FullResponeTextArrayNotNullLine = []; 235 | foreach($FullResponeTextArray as $Item) { 236 | if(trim($Item)!="") { 237 | $FullResponeTextArrayNotNullLine[] = trim($Item); 238 | } 239 | } 240 | $LastElement1 = array_pop($FullResponeTextArrayNotNullLine); 241 | if($LastElement1 && substr($LastElement1, 0, 3) == '## ') { 242 | //print_R($LastElement1); 243 | //print_R($FullResponeTextArrayNotNullLine); 244 | //分段结构只需要输出一次即可, 为实现这个目标, 需要加一个输出标记 245 | $LastElement2 = array_pop($FullResponeTextArrayNotNullLine); 246 | $分段结构标记 = md5($LastElement2); 247 | if(!in_array($分段结构标记, $分段结构输出情况)) { 248 | $CurrentPage = sizeof($分段结构输出情况) + 2; 249 | print 'data: {"current":'.$CurrentPage.', "pptId":"'.$pptId.'", "status":3, "text":"## ", "total":'.$TotalPagesNumber.'}'."\n\n"; 250 | $分段结构输出情况[] = $分段结构标记; 251 | $redis->hSet("PPTX_CONTENT_".date('Ymd'), $pptId, json_encode(['data'=>$FullResponeText, 'total'=>$TotalPagesNumber, 'current'=>$CurrentPage, 'finished'=>false])); 252 | //$redis->hSet("PPTX_CurrentPage_".date('Ymd'), $pptId, $CurrentPage); 253 | } 254 | } 255 | if($LastElement1 && substr($LastElement1, 0, 4) == '### ') { 256 | //print_R($LastElement1); 257 | $LastElement2 = array_pop($FullResponeTextArrayNotNullLine); 258 | if($LastElement2 && substr($LastElement2, 0, 3) == '## ') { 259 | //上一个元素是一个二级标题 当前是一个大的章节的第一个页面时 260 | //分段结构只需要输出一次即可, 为实现这个目标, 需要加一个输出标记 261 | $分段结构标记 = md5($LastElement2); 262 | if(!in_array($分段结构标记, $分段结构输出情况)) { 263 | $CurrentPage = sizeof($分段结构输出情况) + 2; 264 | print 'data: {"current":'.$CurrentPage.', "pptId":"'.$pptId.'", "status":3, "text":"### ", "total":'.$TotalPagesNumber.'}'."\n\n"; 265 | $分段结构输出情况[] = $分段结构标记; 266 | $redis->hSet("PPTX_CONTENT_".date('Ymd'), $pptId, json_encode(['data'=>$FullResponeText, 'total'=>$TotalPagesNumber, 'current'=>$CurrentPage, 'finished'=>false])); 267 | //$redis->hSet("PPTX_CurrentPage_".date('Ymd'), $pptId, $CurrentPage); 268 | } 269 | } 270 | else { 271 | //需要得到上一个结构是什么 272 | $所有内容的结构信息 = []; 273 | $上一个结构信息 = []; 274 | foreach($FullResponeTextArrayNotNullLine as $Item) { 275 | if(substr($Item, 0, 4) == '### ') { 276 | if(sizeof($上一个结构信息)>0) { 277 | $所有内容的结构信息[] = $上一个结构信息; 278 | } 279 | $上一个结构信息 = []; 280 | } 281 | elseif(substr($Item, 0, 2) != '# ') { //非首行记录 282 | $上一个结构信息[] = $Item; 283 | } 284 | } 285 | if(sizeof($上一个结构信息)>0) { 286 | //分段结构只需要输出一次即可, 为实现这个目标, 需要加一个输出标记 287 | $分段结构标记 = md5(serialize($上一个结构信息)); 288 | if(!in_array($分段结构标记, $分段结构输出情况)) { 289 | //print "上一个结构信息:"; 290 | //print_R($上一个结构信息); 291 | $CurrentPage = sizeof($分段结构输出情况) + 2; 292 | print 'data: {"current":'.$CurrentPage.', "pptId":"'.$pptId.'", "status":3, "text":"", "total":'.$TotalPagesNumber.'}'."\n\n"; 293 | $分段结构输出情况[] = $分段结构标记; 294 | $redis->hSet("PPTX_CONTENT_".date('Ymd'), $pptId, json_encode(['data'=>$FullResponeText, 'total'=>$TotalPagesNumber, 'current'=>$CurrentPage, 'finished'=>false])); 295 | //$redis->hSet("PPTX_CurrentPage_".date('Ymd'), $pptId, $CurrentPage); 296 | } 297 | } 298 | } 299 | //print_R($FullResponeTextArrayNotNullLine); 300 | } 301 | //后续需要实现统计出有多少页PPTX, 然后需要标记当前页码, 从而实现实时渲染 302 | //print "\n"; print_R($FullResponeTextArrayNotNullLine); print "\n"; 303 | if(ob_get_level() > 0) ob_flush(); 304 | flush(); 305 | // 从缓冲区中移除已处理的部分 306 | $buffer = substr($buffer, strpos($buffer, $matches[0]) + strlen($matches[0])); 307 | } 308 | 309 | return strlen($data); 310 | }, 311 | CURLOPT_ENCODING => '', 312 | CURLOPT_MAXREDIRS => 10, 313 | CURLOPT_TIMEOUT => 0, 314 | CURLOPT_FOLLOWLOCATION => true, 315 | CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, 316 | CURLOPT_CUSTOMREQUEST => 'POST', 317 | CURLOPT_POSTFIELDS => $CURLOPT_POSTFIELDS, 318 | CURLOPT_HTTPHEADER => array( 319 | 'Content-Type: application/json', 320 | 'Accept: application/json', 321 | 'Authorization: Bearer ' . $API_KEY 322 | ), 323 | )); 324 | curl_exec($curl); 325 | curl_close($curl); 326 | ob_flush(); 327 | flush(); 328 | 329 | } 330 | 331 | 332 | 333 | /* 334 | 335 | if($data != "[DONE]" && $data != "") { 336 | $Content = ''; 337 | try { 338 | $JsonArray = (array)json_decode($data, true); 339 | if (isset($JsonArray['choices']) && is_array($JsonArray['choices'])) { 340 | foreach ($JsonArray['choices'] as $Item) { 341 | if (isset($Item['delta']['content'])) { 342 | $Content .= $Item['delta']['content']; 343 | } 344 | } 345 | } 346 | $ContentArray = ['text' => $Content]; 347 | $Content = json_encode($ContentArray); 348 | } catch (Exception $Error) { 349 | error_log("Error processing JSON data: " . $Error->getMessage()); 350 | } 351 | echo $Content; 352 | ob_flush(); 353 | flush(); 354 | return strlen($Content); 355 | } 356 | 357 | */ 358 | ?> 359 | -------------------------------------------------------------------------------- /generateOutline.php: -------------------------------------------------------------------------------- 1 | $API_MODE, 55 | "messages" => [ 56 | [ 57 | "role" => "user", 58 | "content" => $promptText 59 | ] 60 | ], 61 | "frequency_penalty" => 0, 62 | "max_tokens" => 2048, 63 | "presence_penalty" => 0, 64 | "response_format" => [ 65 | "type" => "text" 66 | ], 67 | "stream" => true, 68 | "temperature" => 0, 69 | "top_p" => 1, 70 | "tool_choice" => "none", 71 | "logprobs" => false, 72 | ]; 73 | $CURLOPT_POSTFIELDS = json_encode($CURLOPT_POSTFIELDS, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); 74 | 75 | curl_setopt_array($curl, array( 76 | CURLOPT_URL => $API_URL . '/chat/completions', 77 | CURLOPT_RETURNTRANSFER => false, 78 | CURLOPT_WRITEFUNCTION => function($curl, $data) { 79 | echo $data; 80 | if(ob_get_level() > 0) ob_flush(); 81 | flush(); 82 | return strlen($data); 83 | }, 84 | CURLOPT_ENCODING => '', 85 | CURLOPT_MAXREDIRS => 10, 86 | CURLOPT_TIMEOUT => 0, 87 | CURLOPT_FOLLOWLOCATION => true, 88 | CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, 89 | CURLOPT_CUSTOMREQUEST => 'POST', 90 | CURLOPT_POSTFIELDS => $CURLOPT_POSTFIELDS, 91 | CURLOPT_HTTPHEADER => array( 92 | 'Content-Type: application/json', 93 | 'Accept: application/json', 94 | 'Authorization: Bearer ' . $API_KEY 95 | ), 96 | )); 97 | 98 | curl_exec($curl); 99 | curl_close($curl); 100 | ob_flush(); 101 | flush(); 102 | 103 | } 104 | 105 | /* 106 | CURLOPT_WRITEFUNCTION => function($curl, $data) use (&$FullResponeText) { 107 | // 使用正则表达式提取 "content":"..." 部分的内容 108 | if (preg_match('/"content":"([^"]*)"/', $data, $matches)) { 109 | $outputData = $matches[1]; 110 | $FullResponeText .= $outputData; 111 | echo 'data: {"status":3,"text":"'.$outputData.'"}'."\n\r"; 112 | ob_flush(); 113 | flush(); 114 | return strlen($data); 115 | } 116 | else { 117 | echo $FullResponeText; 118 | } 119 | return strlen($data); 120 | }, 121 | */ 122 | 123 | ?> 124 | -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /json/蓝色工作汇报总结.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmartSchoolAI/ai-to-pptx-backend/80cd92aa48493a632f8f8f8191b2a0cf6bc07378/json/蓝色工作汇报总结.png -------------------------------------------------------------------------------- /json/蓝色通用商务.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmartSchoolAI/ai-to-pptx-backend/80cd92aa48493a632f8f8f8191b2a0cf6bc07378/json/蓝色通用商务.png -------------------------------------------------------------------------------- /json/读书分享演示.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmartSchoolAI/ai-to-pptx-backend/80cd92aa48493a632f8f8f8191b2a0cf6bc07378/json/读书分享演示.png -------------------------------------------------------------------------------- /json/课程学习汇报.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmartSchoolAI/ai-to-pptx-backend/80cd92aa48493a632f8f8f8191b2a0cf6bc07378/json/课程学习汇报.png -------------------------------------------------------------------------------- /randomTemplates.php: -------------------------------------------------------------------------------- 1 | 19 | -------------------------------------------------------------------------------- /saveConfig.php: -------------------------------------------------------------------------------- 1 | set("API_URL", $_POST['aiApiUrl']); 30 | $redis->set("API_MODE", $_POST['aiModel']); 31 | $redis->set("API_KEY", $_POST['aiToken']); 32 | 33 | $RS = []; 34 | $RS['status'] = 'ok'; 35 | $RS['msg'] = '参数配置成功'; 36 | print json_encode($RS); 37 | } 38 | else { 39 | $RS = []; 40 | $RS['status'] = 'error'; 41 | $RS['msg'] = '三个参数都需要同时填写'; 42 | print json_encode($RS); 43 | } 44 | 45 | 46 | ?> 47 | --------------------------------------------------------------------------------