We’re happy to announce the release of GroupDocs.Viewer for Python 26.9, available as of September 2026. This release upgrades the underlying GroupDocs.Viewer engine from 26.4 to 26.8, adds support for rendering Microsoft Project files on Linux and macOS, introduces page numbering and resolution controls for Word documents, removes the libgdiplus dependency on non-Windows platforms, and restores compatibility with Python 3.5–3.7. The embedded .NET runtime is updated to 10.0.12, and the Python API now includes full docstrings with code examples.
Những tính năng mới trong bản phát hành này
- [Feature] Thêm
WordProcessingOptions.page_number_locationvà enumWordsPageNumberLocationđể dán số trang lên tài liệu Word đã render (VIEWERPYTHON-153) - [Feature] Thêm
WordProcessingOptions.horizontal_resolution/vertical_resolutionđể đặt DPI của đầu ra PNG và JPEG cho tài liệu Word (VIEWERPYTHON-154) - [Feature] Thêm hỗ trợ render các tệp Microsoft Project (MPP, MPT, MPX) trên Linux và macOS (VIEWERPYTHON-155)
- [Enhancement] Cập nhật engine GroupDocs.Viewer từ 26.4 lên 26.8 (VIEWERPYTHON-156)
- [Enhancement] Cập nhật runtime .NET nhúng từ 10.0.0 lên 10.0.12 (VIEWERPYTHON-157)
- [Enhancement] Loại bỏ yêu cầu
libgdiplus/mono-libgdiplustrên Linux và macOS (VIEWERPYTHON-158) - [Enhancement] Cung cấp cùng một API Python trên mọi nền tảng — các gói Linux và macOS thêm
ProjectManagementOptionsvà các thành viênFileTypecho Project, Photoshop, Illustrator và OneNote (VIEWERPYTHON-159) - [Enhancement] Thêm docstrings với tóm tắt, tham số và ví dụ mã vào API Python (VIEWERPYTHON-160)
- [Enhancement] Thêm mục Hướng dẫn dành cho Nhà phát triển vào tài liệu tham khảo API (VIEWERPYTHON-161)
- [Fix] Không thể sử dụng gói trên Python 3.5 – 3.7 (VIEWERPYTHON-162)
- [Fix] pip cài đặt gói trên các phiên bản Linux và macOS không thể chạy được (VIEWERPYTHON-163)
Thay đổi API công cộng
Không có gì bị xóa hoặc đổi tên.
Kiểu mới
| Kiểu | Mô-đun | Mô tả |
|---|---|---|
WordsPageNumberLocation |
groupdocs.viewer.options |
Vị trí dán số trang trên tài liệu Word đã render: NOT_APPLY (mặc định), TOP_LEFT, TOP_CENTER, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_CENTER, BOTTOM_RIGHT |
Thành viên mới trên các lớp hiện có
| Lớp | Thành viên | Mô tả |
|---|---|---|
WordProcessingOptions |
page_number_location |
Đánh số trang áp dụng khi render (WordsPageNumberLocation) |
WordProcessingOptions |
horizontal_resolution |
DPI chiều ngang của đầu ra PNG / JPEG, 72 – 600 (mặc định 96) |
WordProcessingOptions |
vertical_resolution |
DPI chiều dọc của đầu ra PNG / JPEG, 72 – 600 (mặc định 96) |
Mới trên Linux và macOS
ProjectManagementOptions, BaseViewOptions.project_management_options và các thành viên FileType.MPP, MPT, MPX, PSD, PSB, AI, ONE đã có trên Windows và giờ đã có trong các gói Linux và macOS — xem One Python API on every platform.
Tính năng mới
Tệp Microsoft Project trên Linux và macOS
Các tệp MPP, MPT và MPX trước đây chỉ render được trên Windows; trên Linux và macOS chúng gây lỗi Failed to detect file type. Engine 26.8 render chúng trên mọi nền tảng, với cùng ProjectManagementOptions như trên Windows:
from groupdocs.viewer import Viewer
from groupdocs.viewer.options import HtmlViewOptions, TimeUnit
with Viewer("project.mpp") as viewer:
options = HtmlViewOptions.for_embedded_resources("page_{0}.html")
options.project_management_options.time_unit = TimeUnit.DAYS
viewer.view(options)
Trên Linux, hãy cài đặt Microsoft core fonts (ttf-mscorefonts-installer) trước: nếu không có chúng, việc render Project sẽ thất bại với lỗi Cannot find fallback font 'Generic Sans Serif', và các phông thay thế tương thích metric như Liberation không đáp ứng được yêu cầu này.
Số trang trên tài liệu Word đã render
WordProcessingOptions.page_number_location dán số trang lên tài liệu Word trong quá trình render, ngay cả khi tài liệu không có số trang. Chọn một trong sáu vị trí từ enum WordsPageNumberLocation mới; mặc định, NOT_APPLY, sẽ để tài liệu nguyên vẹn.
from groupdocs.viewer import Viewer
from groupdocs.viewer.options import PdfViewOptions, WordsPageNumberLocation
with Viewer("document.docx") as viewer:
options = PdfViewOptions("output.pdf")
options.word_processing_options.page_number_location = WordsPageNumberLocation.BOTTOM_CENTER
viewer.view(options)
Độ phân giải đầu ra PNG và JPEG cho tài liệu Word
WordProcessingOptions.horizontal_resolution và vertical_resolution đặt DPI cho các hình ảnh được render từ tài liệu Word. Mặc định là 96 DPI; các giá trị ngoài khoảng 72 – 600 DPI sẽ được giới hạn vào phạm vi này.
from groupdocs.viewer import Viewer
from groupdocs.viewer.options import PngViewOptions
with Viewer("document.docx") as viewer:
options = PngViewOptions("page_{0}.png")
options.word_processing_options.horizontal_resolution = 300
options.word_processing_options.vertical_resolution = 300
viewer.view(options)
Không còn libgdiplus
Các gói Linux và macOS render thông qua SkiaSharp và Aspose.Drawing, được đóng gói sẵn trong wheel. Chúng không bao giờ gọi libgdiplus: mọi ví dụ trong tài liệu đều chạy trong container Linux không có libgdiplus cũng như các phụ thuộc đồ họa của nó. Hãy loại bỏ libgdiplus / mono-libgdiplus khỏi các image và script provisioning của bạn.
Một API Python trên mọi nền tảng
Trước đây các gói Linux và macOS cung cấp API hạn chế hơn so với Windows. Phiên bản 26.9 cung cấp cùng một API trên mọi nền tảng, vì vậy mã viết dựa trên tài liệu sẽ chạy được trên mọi hệ thống. Các gói Linux và macOS thêm ProjectManagementOptions và các thành viên FileType.MPP, MPT và MPX, hiện đã hoạt động ở đó nữa.
Chúng cũng thêm FileType.PSD, PSB, AI và ONE. Các định dạng này vẫn chỉ hỗ trợ trên Windows, và trên Linux/macOS việc truy cập một trong các thành viên này sẽ gây ra lỗi GroupDocsViewerException: Member 'GroupDocs.Viewer.FileType.PSD' not found. Để quyết định tại thời điểm chạy một định dạng có thể render hay không, hãy kiểm tra FileType.get_supported_file_types(), hàm này trả về danh sách các loại file mà engine đang chạy hỗ trợ:
from groupdocs.viewer import FileType
supported = {file_type.extension for file_type in FileType.get_supported_file_types()}
print(".psd" in supported) # True trên Windows, False trên Linux và macOS
print(".mpp" in supported) # True ở mọi nơi
Ví dụ mã
Render một tệp Microsoft Project trên Linux hoặc macOS với đơn vị thời gian ngày:
from groupdocs.viewer import Viewer
from groupdocs.viewer.options import HtmlViewOptions, TimeUnit
with Viewer("project.mpp") as viewer:
options = HtmlViewOptions.for_embedded_resources("page_{0}.html")
options.project_management_options.time_unit = TimeUnit.DAYS
viewer.view(options)
Áp dụng đánh số trang cho tài liệu Word và render ra PDF:
from groupdocs.viewer import Viewer
from groupdocs.viewer.options import PdfViewOptions, WordsPageNumberLocation
with Viewer("document.docx") as viewer:
options = PdfViewOptions("output.pdf")
options.word_processing_options.page_number_location = WordsPageNumberLocation.BOTTOM_CENTER
viewer.view(options)
Cách nhận bản cập nhật
PyPI
Nâng cấp lên gói mới nhất qua PyPI:
pip install groupdocs-viewer-net==26.9.0
Tải trực tiếp
Tải các tệp wheel cho mọi nền tảng từ trang GroupDocs.Viewer for Python via .NET 26.9 .