lightpdf-aipdf-mcp 0.1.114__py3-none-any.whl → 0.1.116__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 +15 -3
- lightpdf_aipdf_mcp/server.py +1 -1
- {lightpdf_aipdf_mcp-0.1.114.dist-info → lightpdf_aipdf_mcp-0.1.116.dist-info}/METADATA +1 -1
- {lightpdf_aipdf_mcp-0.1.114.dist-info → lightpdf_aipdf_mcp-0.1.116.dist-info}/RECORD +6 -6
- {lightpdf_aipdf_mcp-0.1.114.dist-info → lightpdf_aipdf_mcp-0.1.116.dist-info}/WHEEL +0 -0
- {lightpdf_aipdf_mcp-0.1.114.dist-info → lightpdf_aipdf_mcp-0.1.116.dist-info}/entry_points.txt +0 -0
lightpdf_aipdf_mcp/converter.py
CHANGED
@@ -20,6 +20,7 @@ class InputFormat(str, Enum):
|
|
20
20
|
CAD = "dwg"
|
21
21
|
CAJ = "caj"
|
22
22
|
OFD = "ofd"
|
23
|
+
HTML = "html"
|
23
24
|
|
24
25
|
class OutputFormat(str, Enum):
|
25
26
|
"""支持的输出文件格式"""
|
@@ -46,6 +47,7 @@ INPUT_EXTENSIONS = {
|
|
46
47
|
".dwg": InputFormat.CAD,
|
47
48
|
".caj": InputFormat.CAJ,
|
48
49
|
".ofd": InputFormat.OFD,
|
50
|
+
".html": InputFormat.HTML,
|
49
51
|
}
|
50
52
|
|
51
53
|
# 输入格式到可用输出格式的映射
|
@@ -70,6 +72,7 @@ FORMAT_CONVERSION_MAP = {
|
|
70
72
|
InputFormat.CAD: {OutputFormat.PDF}, # CAD转PDF
|
71
73
|
InputFormat.CAJ: {OutputFormat.PDF}, # CAJ转PDF
|
72
74
|
InputFormat.OFD: {OutputFormat.PDF}, # OFD转PDF
|
75
|
+
InputFormat.HTML: {OutputFormat.PDF}, # HTML转PDF
|
73
76
|
}
|
74
77
|
|
75
78
|
# 扩展FileHandler类的方法
|
@@ -97,6 +100,7 @@ class Converter(BaseApiClient):
|
|
97
100
|
super().__init__(logger, file_handler)
|
98
101
|
api_endpoint = os.getenv("API_ENDPOINT", "techsz.aoscdn.com/api")
|
99
102
|
self.api_base_url = f"https://{api_endpoint}/tasks/document/conversion"
|
103
|
+
self.api_wkhtmltopdf_url = f"https://{api_endpoint}/tasks/document/wkhtmltopdf"
|
100
104
|
|
101
105
|
async def add_page_numbers(self, file_path: str, start_num: int = 1, position: str = "5", margin: int = 30, password: str = None, original_name: Optional[str] = None) -> ConversionResult:
|
102
106
|
"""为PDF文档添加页码
|
@@ -327,6 +331,14 @@ class Converter(BaseApiClient):
|
|
327
331
|
if extra_params:
|
328
332
|
data.update(extra_params)
|
329
333
|
|
334
|
+
api_url = self.api_base_url
|
335
|
+
# html转pdf特殊接口处理
|
336
|
+
if format == "pdf":
|
337
|
+
# 检查是否html输入
|
338
|
+
ext = self.file_handler.get_file_extension(file_path)
|
339
|
+
if ext == ".html":
|
340
|
+
api_url = self.api_wkhtmltopdf_url
|
341
|
+
|
330
342
|
# 检查是否为OSS路径
|
331
343
|
if self.file_handler.is_oss_id(file_path):
|
332
344
|
# OSS路径处理方式,与URL类似,但提取resource_id
|
@@ -334,7 +346,7 @@ class Converter(BaseApiClient):
|
|
334
346
|
# 使用JSON方式时添加Content-Type
|
335
347
|
headers["Content-Type"] = "application/json"
|
336
348
|
response = await client.post(
|
337
|
-
|
349
|
+
api_url,
|
338
350
|
json=data,
|
339
351
|
headers=headers
|
340
352
|
)
|
@@ -351,7 +363,7 @@ class Converter(BaseApiClient):
|
|
351
363
|
# 使用JSON方式时添加Content-Type
|
352
364
|
headers["Content-Type"] = "application/json"
|
353
365
|
response = await client.post(
|
354
|
-
|
366
|
+
api_url,
|
355
367
|
json=data,
|
356
368
|
headers=headers
|
357
369
|
)
|
@@ -360,7 +372,7 @@ class Converter(BaseApiClient):
|
|
360
372
|
with open(file_path, "rb") as f:
|
361
373
|
files = {"file": f}
|
362
374
|
response = await client.post(
|
363
|
-
|
375
|
+
api_url,
|
364
376
|
files=files,
|
365
377
|
data=data,
|
366
378
|
headers=headers
|
lightpdf_aipdf_mcp/server.py
CHANGED
@@ -419,7 +419,7 @@ async def handle_list_tools() -> list[types.Tool]:
|
|
419
419
|
return [
|
420
420
|
types.Tool(
|
421
421
|
name="convert_document",
|
422
|
-
description="Document format conversion tool.\n\nPDF can be converted to: DOCX/XLSX/PPTX/Images (including long images)/HTML/TXT (for text extraction)/CSV;\nOther formats can be converted to PDF: DOCX/XLSX/PPTX/Images/CAD/CAJ/OFD.\n\nDoes not support creating files from content.",
|
422
|
+
description="Document format conversion tool.\n\nPDF can be converted to: DOCX/XLSX/PPTX/Images (including long images)/HTML/TXT (for text extraction)/CSV;\nOther formats can be converted to PDF: DOCX/XLSX/PPTX/Images/CAD/CAJ/OFD/HTML.\n\nDoes not support creating files from content.",
|
423
423
|
inputSchema={
|
424
424
|
"type": "object",
|
425
425
|
"properties": {
|
@@ -1,11 +1,11 @@
|
|
1
1
|
lightpdf_aipdf_mcp/__init__.py,sha256=PPnAgpvJLYLVOTxnHDmJAulFnHJD6wuTwS6tRGjqq6s,141
|
2
2
|
lightpdf_aipdf_mcp/common.py,sha256=PhTf7Zg6mEgn1rTmJDHotXp-4xb2gWFf-Dy_t25qNdY,6660
|
3
|
-
lightpdf_aipdf_mcp/converter.py,sha256=
|
3
|
+
lightpdf_aipdf_mcp/converter.py,sha256=vAFB6XtDFt9NPS9yygKBuL4t43nZU--RqqKPC06Mvkg,16761
|
4
4
|
lightpdf_aipdf_mcp/create_pdf.py,sha256=oALIhOBo60D3Gu_li7d7FF0COhFfSTM-BJpc63r9iAs,2465
|
5
5
|
lightpdf_aipdf_mcp/editor.py,sha256=Ph_ZZNkDrsSMGarS8I625lgt0mEDOxr4AfDoSiG9Rvc,30000
|
6
|
-
lightpdf_aipdf_mcp/server.py,sha256=
|
6
|
+
lightpdf_aipdf_mcp/server.py,sha256=Lwl9kQHLKCQ1szQkkBhw1xcbC3MsWy6fm2_1vBNQGuE,65002
|
7
7
|
lightpdf_aipdf_mcp/translator.py,sha256=NbFDz-mZSD4qCNQVyV0W_0x6xXwbqs_7FiBU13JAxZs,4243
|
8
|
-
lightpdf_aipdf_mcp-0.1.
|
9
|
-
lightpdf_aipdf_mcp-0.1.
|
10
|
-
lightpdf_aipdf_mcp-0.1.
|
11
|
-
lightpdf_aipdf_mcp-0.1.
|
8
|
+
lightpdf_aipdf_mcp-0.1.116.dist-info/METADATA,sha256=YzPPjo3tOVo1pfA_4EI2FxtY3NtoPaPatJ7stiKpxBE,8120
|
9
|
+
lightpdf_aipdf_mcp-0.1.116.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
10
|
+
lightpdf_aipdf_mcp-0.1.116.dist-info/entry_points.txt,sha256=X7TGUe52N4sYH-tYt0YUGApeJgw-efQlZA6uAZmlmr4,63
|
11
|
+
lightpdf_aipdf_mcp-0.1.116.dist-info/RECORD,,
|
File without changes
|
{lightpdf_aipdf_mcp-0.1.114.dist-info → lightpdf_aipdf_mcp-0.1.116.dist-info}/entry_points.txt
RENAMED
File without changes
|