* Upgrade the PDF version. * * Sets the /Version entry in the catalog dictionary. This is the standard * way to upgrade PDF version in incremental updates since the header * cannot be modified. * * The version will only be upgraded if the new version is higher than * the current
(version: string)
| 730 | * ``` |
| 731 | */ |
| 732 | upgradeVersion(version: string): void { |
| 733 | // Parse versions for comparison |
| 734 | const parseVersion = (v: string): number => { |
| 735 | const [major, minor] = v.split(".").map(Number); |
| 736 | return major * 10 + (minor || 0); |
| 737 | }; |
| 738 | |
| 739 | const currentVersion = parseVersion(this.ctx.info.version); |
| 740 | const targetVersion = parseVersion(version); |
| 741 | |
| 742 | // Only upgrade, never downgrade |
| 743 | if (targetVersion <= currentVersion) { |
| 744 | return; |
| 745 | } |
| 746 | |
| 747 | // Set the version in the catalog |
| 748 | const catalog = this.ctx.catalog.getDict(); |
| 749 | catalog.set("Version", PdfName.of(version)); |
| 750 | |
| 751 | // Update internal version tracking |
| 752 | this.ctx.info.version = version; |
| 753 | } |
| 754 | |
| 755 | /** Whether the document is encrypted */ |
| 756 | get isEncrypted(): boolean { |
nothing calls this directly
no test coverage detected