feat: [xps] implement export to PDF and save as XPS#212
Merged
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom Nov 21, 2025
Merged
feat: [xps] implement export to PDF and save as XPS#212deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
Conversation
Implement XPS document export to PDF using Cairo PDF surface with libgxps rendering. Support both XPS file copy and PDF export based on file extension in saveAs() method. Changes: - Add Cairo PDF surface support for XPS to PDF conversion - Implement saveAs() with format detection (.xps vs .pdf) - Update saveFilter() to return both XPS and PDF formats - Update DocSheet::filter() to show both format options in file dialog - Update DocSheet::saveAsData() to handle XPS format conversion - Use 1:1 coordinate mapping to preserve document dimensions - Enable best quality rendering with antialiasing The implementation renders each XPS page to Cairo PDF surface using gxps_page_render(), maintaining vector quality and supporting variable page sizes. Log: implement XPS export to PDF and save as XPS Task: https://pms.uniontech.com/task-view-383459.html
deepin pr auto review我来对这段代码进行审查:
bool XpsDocumentAdapter::saveAs(const QString &filePath) const
{
// 添加文件大小检查
const qint64 maxFileSize = 100 * 1024 * 1024; // 100MB
QFileInfo sourceInfo(m_filePath);
if (sourceInfo.size() > maxFileSize) {
qCWarning(appLog) << "XPS saveAs: source file too large:" << sourceInfo.size();
return false;
}
// 使用QFileInfo规范化路径
const QString normalizedPath = QFileInfo(filePath).absoluteFilePath();
if (normalizedPath.isEmpty()) {
qCWarning(appLog) << "XPS saveAs: invalid file path";
return false;
}
// 检查目标路径的写入权限
QFileInfo targetInfo(normalizedPath);
if (targetInfo.exists() && !targetInfo.isWritable()) {
qCWarning(appLog) << "XPS saveAs: target file is not writable:" << normalizedPath;
return false;
}
// ... 其余代码保持不变 ...
}
// 添加PDF导出配置结构
struct PdfExportConfig {
int quality = 100; // 导出质量 (0-100)
int dpi = 72; // 分辨率
bool compress = true; // 是否压缩
// 可以添加更多配置项
};
// 修改PDF导出方法签名
bool XpsDocumentAdapter::exportToPdf(const QString &filePath,
const PdfExportConfig& config = PdfExportConfig()) const;
这些改进可以提高代码的健壮性、可维护性和用户体验。 |
lzwind
approved these changes
Nov 21, 2025
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: LiHua000, lzwind The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Contributor
Author
|
/merge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implement XPS document export to PDF using Cairo PDF surface with libgxps rendering. Support both XPS file copy and PDF export based on file extension in saveAs() method.
Changes:
The implementation renders each XPS page to Cairo PDF surface using gxps_page_render(), maintaining vector quality and supporting variable page sizes.
Log: implement XPS export to PDF and save as XPS
Task: https://pms.uniontech.com/task-view-383459.html