Skip to content

Conversation

@TCOTC
Copy link
Contributor

@TCOTC TCOTC commented Dec 7, 2025

桌面端导出 PDF 支持不分页 https://ld246.com/article/1764933918963

导出的 PDF 是这样的效果:

PixPin_2025-12-07_20-10-23

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for non-paginated PDF export in the desktop application, allowing users to export documents as single continuous-page PDFs. The feature is controlled by a new "paged" checkbox in the PDF export dialog that defaults to enabled (maintaining current paginated behavior).

Key changes:

  • Adds a "paged" toggle in the PDF export UI that controls whether the exported PDF uses standard pagination or continuous single-page layout
  • Implements dynamic page size calculation for non-paginated exports by measuring content height and adjusting PDF dimensions accordingly
  • Updates storage configuration to persist the user's pagination preference with backwards compatibility for legacy settings

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 5 comments.

File Description
app/src/protyle/export/index.ts Adds pagination toggle UI control and implements dual-mode export logic with dynamic page sizing for continuous exports
app/src/boot/onGetConfig.ts Updates PDF export handler to store pagination preference and conditionally render footer only for paginated exports
app/src/protyle/util/compatibility.ts Adds default "paged: true" setting to local storage configuration for PDF exports
app/appearance/langs/*.json Adds "paged" translation key across all 16 supported language files

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 618 to 625
const pageSizes = {
"A3": { width: 11.69, height: 16.54 },
"A4": { width: 8.27, height: 11.69 },
"A5": { width: 5.83, height: 8.27 },
"Legal": { width: 8.5, height: 14 },
"Letter": { width: 8.5, height: 11 },
"Tabloid": { width: 11, height: 17 },
};
Copy link

Copilot AI Dec 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The page size dimensions are hardcoded as magic numbers without explanation. For example, A4 is defined as width: 8.27, height: 11.69, but it's unclear what units these represent (they appear to be inches).

Consider:

  1. Adding a comment explaining these are dimensions in inches
  2. Extracting these to a constant at the module level or importing from a shared configuration
  3. Using more descriptive variable names like 'widthInches' and 'heightInches' in the object definition

This would improve code clarity and make it easier to maintain if page sizes need to be updated or added.

Copilot uses AI. Check for mistakes.
Copy link
Member

@Vanessa219 Vanessa219 Dec 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个和分页的大小看上去不太一样,这样是否导出就会导致 A4 的边距不一致?

Copy link
Contributor Author

@TCOTC TCOTC Dec 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

按照 electron 源码修改了,现在边距是完全一致的

@Vanessa219
Copy link
Member

这个没有修改

QQ_1766368114956

冲突需要解决一下

# Conflicts:
#	app/appearance/langs/de_DE.json
#	app/appearance/langs/he_IL.json
#	app/appearance/langs/it_IT.json
#	app/appearance/langs/pl_PL.json
#	app/appearance/langs/pt_BR.json
#	app/appearance/langs/ru_RU.json
@TCOTC
Copy link
Contributor Author

TCOTC commented Dec 22, 2025

  1. 没看懂还有哪里的代码重复
  2. 冲突解决了

@Vanessa219 Vanessa219 added this to the 3.5.2 milestone Dec 26, 2025
@Vanessa219 Vanessa219 merged commit cef8ca8 into siyuan-note:dev Dec 26, 2025
@Vanessa219 Vanessa219 self-assigned this Dec 26, 2025
Vanessa219 added a commit that referenced this pull request Dec 26, 2025
@TCOTC TCOTC deleted the feat/pagination branch December 27, 2025 09:40
@TCOTC
Copy link
Contributor Author

TCOTC commented Dec 28, 2025

@Vanessa219 我觉得不分页的时候底下不需要显示页码

PixPin_2025-12-28_20-31-47

@Vanessa219
Copy link
Member

如果不显示的话,配置成其他页脚就无法显示了。

@XinLi0111
Copy link

设置不分页,但是结果还是分页的,可能和引述块有关?测试过一个没有引述块的是正常不分页。两个有引述块的,哪怕长度不是很长也是两页。

@Vanessa219
Copy link
Member

好像和引述块没有关系,页面不够一页就会被分为很多小页面。

Vanessa219 added a commit that referenced this pull request Dec 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants