From b042283ebbf0206242c92fa9e5c1906a7138ac63 Mon Sep 17 00:00:00 2001 From: csh Date: Tue, 25 Jun 2024 16:57:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E8=B5=84=E6=BA=90=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=E6=94=B9=E4=B8=BA.cache?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TSDocxToPdf.tsf | 20 ++++++++++---------- range/TSPdfParagraphRange.tsf | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/TSDocxToPdf.tsf b/TSDocxToPdf.tsf index 8f78fd2..8dd1a1e 100644 --- a/TSDocxToPdf.tsf +++ b/TSDocxToPdf.tsf @@ -7,7 +7,7 @@ public function GetCurrentPage(): PdfPage; function GetCurrentPoint(): Point; - function GetTempPath(image_path: string): string; + function GetCachePath(image_path: string): string; function GetPdf(): PdfFile; function GetNextPage(page: PdfPage): PdfPage; function AddPage(sect_ware: TSSectWare): PdfPage; @@ -17,7 +17,7 @@ public private function InitDocxComponents(alias: string; file: string); - function InitTempPath(file: string); + function InitCachePath(file: string); function InitPdfEncoder(); function InitSectWare(); function AllocateElementsToSectWare(); @@ -31,7 +31,7 @@ private private pdf_: PdfFile; docx_components_: Components; // Components@DOCX - temp_path_: string; // 临时目录,用来存放临时文件 + cache_path_: string; // 临时目录,用来存放临时文件 sect_ware_array_: array of TSSectWare; // 页面布局组件数组 font_ware_: TSFontWare; // 字体部件 current_page_: PdfPage; @@ -45,7 +45,7 @@ begin pdf_ := new PdfFile(); self.InitPdfEncoder(); self.InitDocxComponents(alias, file); - self.InitTempPath(file); + self.InitCachePath(file); self.InitSectWare(); font_ware_ := new TSFontWare(pdf_); current_page_ := nil; @@ -56,7 +56,7 @@ end; function TSDocxToPdf.Destroy(); begin - removeDir("", temp_path_); + removeDir("", cache_path_); end; function TSDocxToPdf.SaveToFile(alias: string; file: string): integer; @@ -93,9 +93,9 @@ begin return point_; end; -function TSDocxToPdf.GetTempPath(image_path: string): string; +function TSDocxToPdf.GetCachePath(image_path: string): string; begin - return temp_path_ + extractFileName(image_path); + return cache_path_ + extractFileName(image_path); end; function TSDocxToPdf.GetPdf(): PdfFile; @@ -123,11 +123,11 @@ begin if err then raise "Create obejct 'TSDocxFile' failed."; end; -function TSDocxToPdf.InitTempPath(file: string); +function TSDocxToPdf.InitCachePath(file: string); begin path := format("%s_%s", extractFileName(file), formatDatetime("YYYYMMDDHHNNSSZZZ", now())); - temp_path_ := format("%s/funcext/WordToPdf/temp/%s/", extractFileDir(sysExecName()), path); - createDir("", temp_path_); + cache_path_ := format("%s/funcext/PdfConverter/.cache/%s/", extractFileDir(sysExecName()), path); + createDir("", cache_path_); end; function TSDocxToPdf.InitSectWare(); diff --git a/range/TSPdfParagraphRange.tsf b/range/TSPdfParagraphRange.tsf index 7249d39..af6afcb 100644 --- a/range/TSPdfParagraphRange.tsf +++ b/range/TSPdfParagraphRange.tsf @@ -246,7 +246,7 @@ begin image_path := "word/" + rel.Target; image := docx_components_.Zip().Get(image_path); data := image.Data(); - image_path := docx_to_pdf_.GetTempPath(image_path); + image_path := docx_to_pdf_.GetCachePath(image_path); writeFile(rwBinary(), "", image_path, 0, length(data)-1, data); image := nil; case self.GetImageFileType(data) of