MCPcopy Create free account
hub / github.com/LibPDF-js/core / upgradeVersion

Method upgradeVersion

src/api/pdf.ts:732–753  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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 {

Callers

nothing calls this directly

Calls 4

parseVersionFunction · 0.85
getDictMethod · 0.65
setMethod · 0.45
ofMethod · 0.45

Tested by

no test coverage detected