浏览代码

页数限制100

CrazyIter 5 年之前
父节点
当前提交
ba3d1c3ed4
共有 1 个文件被更改,包括 8 次插入7 次删除
  1. 8 7
      HiTeachCC.Service/Core/Implement/FileService.cs

+ 8 - 7
HiTeachCC.Service/Core/Implement/FileService.cs

@@ -43,14 +43,15 @@ namespace HiTeachCC.Service.Core.Implement
             }
             else if (FileType.GetExtention(file.FileName).ToLower().Equals("pdf"))
             {
-                //PdfDocument inputDocument = PdfSharpCore.Pdf.IO.PdfReader.Open(file.OpenReadStream(), PdfDocumentOpenMode.Import);
-                //int count = inputDocument.PageCount;
-                //int limit=   BaseConfigModel.Configuration.GetSection("HABOOKConfig:PDFLimit").Get<int>();
-                //if (count > limit) {
-                //    throw new BizException(500, "PDF file cannot exceed "+limit+" pages!");
-                //}
+                PdfDocument inputDocument = PdfSharpCore.Pdf.IO.PdfReader.Open(file.OpenReadStream(), PdfDocumentOpenMode.Import);
+                int count = inputDocument.PageCount;
+                int limit = BaseConfigModel.Configuration.GetSection("HABOOKConfig:PDFLimit").Get<int>();
+                if (count > limit)
+                {
+                    throw new BizException(500, "PDF file cannot exceed " + limit + " pages!");
+                }
                 await ProcessPDF(file, resdict);
-                resdict.Add("page", 1000);
+                resdict.Add("page", count);
                 return resdict;
             }
             else {