Skip to content

Commit

Permalink
[pdf] Fix pdf assembly when some change was done in any form
Browse files Browse the repository at this point in the history
  • Loading branch information
KirillovIlya committed Sep 21, 2024
1 parent 9e5edfa commit 258b157
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 3 deletions.
9 changes: 7 additions & 2 deletions pdf/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,13 @@
};
}
};
PDFEditorApi.prototype["asc_nativeCalculateFile"] = function()
{
PDFEditorApi.prototype["asc_nativeCalculateFile"] = function() {

let pdfDoc = this.getPDFDoc();
if (!pdfDoc)
return;

pdfDoc.RecalculateAll();
};
PDFEditorApi.prototype["asc_nativePrintPagesCount"] = function()
{
Expand Down
45 changes: 44 additions & 1 deletion pdf/src/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,44 @@ var CPresentation = CPresentation || function(){};
this.Action = {};
}

CPDFDoc.prototype.RecalculateAll = function() {
let fontMap = {};

this.widgets.forEach(function(field) {
if (field.IsNeedDrawFromStream())
return;

let fontName = field.GetTextFontActual();
if (fontName)
fontMap[fontName] = true;
});

this.drawings.forEach(function(drawing) {
drawing.GetAllFonts(fontMap);
});

this.annots.forEach(function(annot) {
annot.GetAllFonts(fontMap);
});

this.checkFonts(Object.keys(fontMap), this._RecalculateAll.bind(this));
};
CPDFDoc.prototype._RecalculateAll = function() {
this.widgets.forEach(function(field) {
if (field.IsNeedDrawFromStream())
return;

field.Recalculate();
});

this.drawings.forEach(function(drawing) {
drawing.Recalculate();
});

this.annots.forEach(function(annot) {
annot.Recalculate();
});
};
CPDFDoc.prototype.UpdatePagesTransform = function() {
this.pagesTransform = [];

Expand Down Expand Up @@ -434,7 +472,12 @@ var CPresentation = CPresentation || function(){};
});
};
CPDFDoc.prototype.FillButtonsIconsOnOpen = function() {
let oViewer = editor.getDocumentRenderer();
let oViewer = editor.getDocumentRenderer();
if (window["NATIVE_EDITOR_ENJINE"]) {
oViewer.IsOpenFormsInProgress = false;
return;
}

let oDoc = this;

let aIconsToLoad = [];
Expand Down

0 comments on commit 258b157

Please sign in to comment.