lightpdf-aipdf-mcp 0.1.54__py3-none-any.whl → 0.1.56__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- lightpdf_aipdf_mcp/converter.py +0 -10
- lightpdf_aipdf_mcp/editor.py +27 -0
- lightpdf_aipdf_mcp/server.py +44 -1
- {lightpdf_aipdf_mcp-0.1.54.dist-info → lightpdf_aipdf_mcp-0.1.56.dist-info}/METADATA +3 -5
- lightpdf_aipdf_mcp-0.1.56.dist-info/RECORD +9 -0
- lightpdf_aipdf_mcp-0.1.54.dist-info/RECORD +0 -9
- {lightpdf_aipdf_mcp-0.1.54.dist-info → lightpdf_aipdf_mcp-0.1.56.dist-info}/WHEEL +0 -0
- {lightpdf_aipdf_mcp-0.1.54.dist-info → lightpdf_aipdf_mcp-0.1.56.dist-info}/entry_points.txt +0 -0
lightpdf_aipdf_mcp/converter.py
CHANGED
@@ -17,8 +17,6 @@ class InputFormat(str, Enum):
|
|
17
17
|
JPG = "jpg"
|
18
18
|
JPEG = "jpeg"
|
19
19
|
PNG = "png"
|
20
|
-
BMP = "bmp"
|
21
|
-
GIF = "gif"
|
22
20
|
CAD = "dwg"
|
23
21
|
CAJ = "caj"
|
24
22
|
OFD = "ofd"
|
@@ -32,8 +30,6 @@ class OutputFormat(str, Enum):
|
|
32
30
|
JPG = "jpg"
|
33
31
|
JPEG = "jpeg"
|
34
32
|
PNG = "png"
|
35
|
-
BMP = "bmp"
|
36
|
-
GIF = "gif"
|
37
33
|
HTML = "html"
|
38
34
|
TEXT = "txt"
|
39
35
|
|
@@ -46,8 +42,6 @@ INPUT_EXTENSIONS = {
|
|
46
42
|
".jpg": InputFormat.JPG,
|
47
43
|
".jpeg": InputFormat.JPEG,
|
48
44
|
".png": InputFormat.PNG,
|
49
|
-
".bmp": InputFormat.BMP,
|
50
|
-
".gif": InputFormat.GIF,
|
51
45
|
".dwg": InputFormat.CAD,
|
52
46
|
".caj": InputFormat.CAJ,
|
53
47
|
".ofd": InputFormat.OFD,
|
@@ -62,8 +56,6 @@ FORMAT_CONVERSION_MAP = {
|
|
62
56
|
OutputFormat.JPG, # PDF转JPG
|
63
57
|
OutputFormat.JPEG, # PDF转JPEG
|
64
58
|
OutputFormat.PNG, # PDF转PNG
|
65
|
-
OutputFormat.BMP, # PDF转BMP
|
66
|
-
OutputFormat.GIF, # PDF转GIF
|
67
59
|
OutputFormat.HTML, # PDF转HTML
|
68
60
|
OutputFormat.TEXT, # PDF转文本
|
69
61
|
},
|
@@ -73,8 +65,6 @@ FORMAT_CONVERSION_MAP = {
|
|
73
65
|
InputFormat.JPG: {OutputFormat.PDF}, # JPG转PDF
|
74
66
|
InputFormat.JPEG: {OutputFormat.PDF}, # JPEG转PDF
|
75
67
|
InputFormat.PNG: {OutputFormat.PDF}, # PNG转PDF
|
76
|
-
InputFormat.BMP: {OutputFormat.PDF}, # BMP转PDF
|
77
|
-
InputFormat.GIF: {OutputFormat.PDF}, # GIF转PDF
|
78
68
|
InputFormat.CAD: {OutputFormat.PDF}, # CAD转PDF
|
79
69
|
InputFormat.CAJ: {OutputFormat.PDF}, # CAJ转PDF
|
80
70
|
InputFormat.OFD: {OutputFormat.PDF}, # OFD转PDF
|
lightpdf_aipdf_mcp/editor.py
CHANGED
@@ -19,6 +19,7 @@ class EditType(str, Enum):
|
|
19
19
|
ENCRYPT = "protect" # 加密PDF
|
20
20
|
DECRYPT = "unlock" # 解密PDF
|
21
21
|
ADD_WATERMARK = "watermark" # 添加水印
|
22
|
+
REMOVE_MARGIN = "edit" # 去除白边
|
22
23
|
|
23
24
|
@dataclass
|
24
25
|
class EditResult(BaseResult):
|
@@ -354,6 +355,32 @@ class Editor(BaseApiClient):
|
|
354
355
|
# 调用edit_pdf方法处理API请求
|
355
356
|
return await self.edit_pdf(file_path, EditType.ADD_WATERMARK, extra_params, password, original_name)
|
356
357
|
|
358
|
+
async def remove_margin(self, file_path: str, password: Optional[str] = None, original_name: Optional[str] = None) -> EditResult:
|
359
|
+
"""去除PDF文件的白边
|
360
|
+
|
361
|
+
Args:
|
362
|
+
file_path: 要去除白边的PDF文件路径
|
363
|
+
password: 文档密码,如果文档受密码保护,则需要提供(可选)
|
364
|
+
original_name: 原始文件名(可选)
|
365
|
+
|
366
|
+
Returns:
|
367
|
+
EditResult: 去除白边的结果
|
368
|
+
"""
|
369
|
+
# 验证输入文件是否为PDF
|
370
|
+
if not await self._validate_pdf_file(file_path):
|
371
|
+
return EditResult(success=False, file_path=file_path, error_message="非PDF文件", original_name=original_name)
|
372
|
+
|
373
|
+
# 记录操作描述
|
374
|
+
await self._log_operation("去除PDF文件白边")
|
375
|
+
|
376
|
+
# 构建API参数,按照固定格式传递
|
377
|
+
extra_params = {
|
378
|
+
"pages": [{"content": "autocrop", "range": 1, "size": ""}]
|
379
|
+
}
|
380
|
+
|
381
|
+
# 调用edit_pdf方法处理API请求
|
382
|
+
return await self.edit_pdf(file_path, EditType.REMOVE_MARGIN, extra_params, password, original_name)
|
383
|
+
|
357
384
|
async def edit_pdf(self, file_path: str, edit_type: EditType, extra_params: Dict[str, Any] = None, password: Optional[str] = None, original_name: Optional[str] = None) -> EditResult:
|
358
385
|
"""编辑PDF文件
|
359
386
|
|
lightpdf_aipdf_mcp/server.py
CHANGED
@@ -221,6 +221,13 @@ async def process_edit_file(
|
|
221
221
|
password=password,
|
222
222
|
original_name=original_name
|
223
223
|
)
|
224
|
+
elif edit_type == "remove_margin":
|
225
|
+
# 直接调用remove_margin方法,不需要额外参数
|
226
|
+
return await editor.remove_margin(
|
227
|
+
file_path=file_path,
|
228
|
+
password=password,
|
229
|
+
original_name=original_name
|
230
|
+
)
|
224
231
|
else:
|
225
232
|
return EditResult(
|
226
233
|
success=False,
|
@@ -362,7 +369,7 @@ async def handle_list_tools() -> list[types.Tool]:
|
|
362
369
|
"format": {
|
363
370
|
"type": "string",
|
364
371
|
"description": "目标格式",
|
365
|
-
"enum": ["pdf", "docx", "xlsx", "pptx", "jpg", "jpeg", "png", "
|
372
|
+
"enum": ["pdf", "docx", "xlsx", "pptx", "jpg", "jpeg", "png", "html", "txt"]
|
366
373
|
}
|
367
374
|
},
|
368
375
|
"required": ["files", "format"]
|
@@ -761,6 +768,38 @@ async def handle_list_tools() -> list[types.Tool]:
|
|
761
768
|
},
|
762
769
|
"required": ["files", "rotates"]
|
763
770
|
}
|
771
|
+
),
|
772
|
+
types.Tool(
|
773
|
+
name="remove_margin",
|
774
|
+
description="去除PDF文件的白边(页边距)。",
|
775
|
+
inputSchema={
|
776
|
+
"type": "object",
|
777
|
+
"properties": {
|
778
|
+
"files": {
|
779
|
+
"type": "array",
|
780
|
+
"items": {
|
781
|
+
"type": "object",
|
782
|
+
"properties": {
|
783
|
+
"path": {
|
784
|
+
"type": "string",
|
785
|
+
"description": "需要去除白边的PDF文件路径或URL"
|
786
|
+
},
|
787
|
+
"password": {
|
788
|
+
"type": "string",
|
789
|
+
"description": "PDF文档密码,如果文档受密码保护,则需要提供此参数"
|
790
|
+
},
|
791
|
+
"name": {
|
792
|
+
"type": "string",
|
793
|
+
"description": "文件的原始文件名"
|
794
|
+
}
|
795
|
+
},
|
796
|
+
"required": ["path"]
|
797
|
+
},
|
798
|
+
"description": "需要去除白边的PDF文件列表,每个文件包含路径和可选的密码"
|
799
|
+
}
|
800
|
+
},
|
801
|
+
"required": ["files"]
|
802
|
+
}
|
764
803
|
)
|
765
804
|
]
|
766
805
|
|
@@ -823,6 +862,10 @@ async def handle_call_tool(name: str, arguments: dict | None) -> list[types.Text
|
|
823
862
|
"edit_type": "rotate", # 编辑类型
|
824
863
|
"is_edit_operation": True, # 标记为编辑操作
|
825
864
|
"param_keys": ["rotates"] # 只需要rotates参数,移除对旧格式的支持
|
865
|
+
},
|
866
|
+
"remove_margin": {
|
867
|
+
"edit_type": "remove_margin", # 编辑类型
|
868
|
+
"is_edit_operation": True, # 标记为编辑操作
|
826
869
|
}
|
827
870
|
}
|
828
871
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: lightpdf-aipdf-mcp
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.56
|
4
4
|
Summary: MCP Server for LightPDF AI-PDF
|
5
5
|
Author: LightPDF Team
|
6
6
|
License: Proprietary
|
@@ -99,7 +99,7 @@ pip install lightpdf-aipdf-mcp
|
|
99
99
|
- Word (DOCX)
|
100
100
|
- Excel (XLSX)
|
101
101
|
- PowerPoint (PPTX)
|
102
|
-
- 图片 (JPG, JPEG, PNG
|
102
|
+
- 图片 (JPG, JPEG, PNG)
|
103
103
|
- HTML
|
104
104
|
- 文本 (TXT)
|
105
105
|
|
@@ -107,7 +107,7 @@ pip install lightpdf-aipdf-mcp
|
|
107
107
|
- Word (DOCX)
|
108
108
|
- Excel (XLSX)
|
109
109
|
- PowerPoint (PPTX)
|
110
|
-
- 图片 (JPG, JPEG, PNG
|
110
|
+
- 图片 (JPG, JPEG, PNG)
|
111
111
|
- CAD (DWG)
|
112
112
|
- CAJ
|
113
113
|
- OFD
|
@@ -192,8 +192,6 @@ pip install lightpdf-aipdf-mcp
|
|
192
192
|
- `pptx`: 转换为PowerPoint格式
|
193
193
|
- `jpg`/`jpeg`: 转换为JPG格式
|
194
194
|
- `png`: 转换为PNG格式
|
195
|
-
- `bmp`: 转换为BMP格式
|
196
|
-
- `gif`: 转换为GIF格式
|
197
195
|
- `html`: 转换为HTML格式
|
198
196
|
- `txt`: 转换为文本格式
|
199
197
|
|
@@ -0,0 +1,9 @@
|
|
1
|
+
lightpdf_aipdf_mcp/__init__.py,sha256=PPnAgpvJLYLVOTxnHDmJAulFnHJD6wuTwS6tRGjqq6s,141
|
2
|
+
lightpdf_aipdf_mcp/common.py,sha256=-7LU6gm-As_F8Ly68ssy15Vc9Zt_eNSnvDLEtVZDwlI,6633
|
3
|
+
lightpdf_aipdf_mcp/converter.py,sha256=d90pNUT8pQn93u1fJSlu4f2KyLDzhOdTrqyBkSTRFBE,14450
|
4
|
+
lightpdf_aipdf_mcp/editor.py,sha256=Lf0KYviNtuuDg1DGzlmvxhXD-igzCkQG25NA7iUkGSs,24736
|
5
|
+
lightpdf_aipdf_mcp/server.py,sha256=57oQ2wBOF6ajJs67q41w3MNjrIiYaOf3Z_LJ17OC7Ag,43306
|
6
|
+
lightpdf_aipdf_mcp-0.1.56.dist-info/METADATA,sha256=ILLjZYnIeGu8V4AvSAfDivShy8I-wbMs4aHNjA3Npik,7826
|
7
|
+
lightpdf_aipdf_mcp-0.1.56.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
8
|
+
lightpdf_aipdf_mcp-0.1.56.dist-info/entry_points.txt,sha256=X7TGUe52N4sYH-tYt0YUGApeJgw-efQlZA6uAZmlmr4,63
|
9
|
+
lightpdf_aipdf_mcp-0.1.56.dist-info/RECORD,,
|
@@ -1,9 +0,0 @@
|
|
1
|
-
lightpdf_aipdf_mcp/__init__.py,sha256=PPnAgpvJLYLVOTxnHDmJAulFnHJD6wuTwS6tRGjqq6s,141
|
2
|
-
lightpdf_aipdf_mcp/common.py,sha256=-7LU6gm-As_F8Ly68ssy15Vc9Zt_eNSnvDLEtVZDwlI,6633
|
3
|
-
lightpdf_aipdf_mcp/converter.py,sha256=QBwKcCg83FrGGDCy3IFyXjldIZg2hzej_zCH8nyOPak,14768
|
4
|
-
lightpdf_aipdf_mcp/editor.py,sha256=RuHxTMlyvUp2keh0Plue2g4vwGe4Vzv5mauJuncyM8o,23551
|
5
|
-
lightpdf_aipdf_mcp/server.py,sha256=mgCXhdPPusssVDQAFyFuSrfHr_PUffztpJSWsg9newY,41455
|
6
|
-
lightpdf_aipdf_mcp-0.1.54.dist-info/METADATA,sha256=082iWOLst2JL_k0HoKrp0PDeIz6IlswN14AZgaxaRuE,7906
|
7
|
-
lightpdf_aipdf_mcp-0.1.54.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
8
|
-
lightpdf_aipdf_mcp-0.1.54.dist-info/entry_points.txt,sha256=X7TGUe52N4sYH-tYt0YUGApeJgw-efQlZA6uAZmlmr4,63
|
9
|
-
lightpdf_aipdf_mcp-0.1.54.dist-info/RECORD,,
|
File without changes
|
{lightpdf_aipdf_mcp-0.1.54.dist-info → lightpdf_aipdf_mcp-0.1.56.dist-info}/entry_points.txt
RENAMED
File without changes
|