Skip to content

Commit

Permalink
chore: Add cover page placeholder after applying webhooks, to exclude…
Browse files Browse the repository at this point in the history
… possibility to break cover page logic

Refs: #91
  • Loading branch information
yurtsevich-sbb committed Aug 20, 2024
1 parent 8f86895 commit 883b416
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 3 additions & 0 deletions docs/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1389,6 +1389,9 @@
},
"watermark": {
"type": "boolean"
},
"webhooks": {
"type": "string"
}
},
"type": "object"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,13 @@ public byte[] convertToPdf(@NotNull ExportParams exportParams, @Nullable ExportM
metaInfoCallback.setLinkedWorkItems(WorkItemRefData.extractListFromHtml(htmlContent, exportParams.getProjectId()));
}
htmlContent = htmlProcessor.internalizeLinks(htmlContent);
htmlContent = applyWebooks(exportParams, htmlContent);
return htmlContent;
htmlContent = applyWebhooks(exportParams, htmlContent);

// Add a fake page which later will be replaced with cover page. This should be done post-webhooks not to break this approach.
return (exportParams.getCoverPage() != null ? "<div style='break-after:page'>page to be removed</div>" : "") + htmlContent;
}

private @NotNull String applyWebooks(@NotNull ExportParams exportParams, @NotNull String htmlContent) {
private @NotNull String applyWebhooks(@NotNull ExportParams exportParams, @NotNull String htmlContent) {
if (exportParams.getWebhooks() == null) {
return htmlContent;
}
Expand Down Expand Up @@ -219,7 +221,6 @@ String composeHtml(@NotNull String documentName,
@NotNull HtmlData htmlData,
@NotNull ExportParams exportParams) {
String content = htmlData.headerFooterContent
+ (exportParams.getCoverPage() != null ? "<div style='break-after:page'>page to be removed</div>" : "") //add fake page which later will be replaced with title
+ "<div class='content'>" + htmlData.documentContent + "</div>";
return pdfTemplateProcessor.processUsing(exportParams, documentName, htmlData.cssContent, content);
}
Expand Down

0 comments on commit 883b416

Please sign in to comment.