We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Don't show comments in pdf or html export

Goodmorning Aspose,


I have a document with a review comment in it, and I want to save the document as a pdf and as a html file without showing that comment.
Is there an options to remove the comment before I save the document as a pdf ?
I tried using the code below, on the document in the attachment, but it didn’t work. In the pdf I still see the comment.

PS testen in 16.12 and 17.2

Thank you,
Jeroen

<pre style=“background-color: rgb(255, 255, 255); font-family: “Courier New”;”>Document lDocument = new Document(lFileName);
//Remove review comments ONLY FOR PREVIEWS
RevisionOptions lRevisionOptions = lDocument.getLayoutOptions().getRevisionOptions();
lRevisionOptions.setShowRevisionMarks( false );
lRevisionOptions.setShowRevisionBars( false );
lRevisionOptions.setShowOriginalRevision( false );
lRevisionOptions.setRevisionBarsWidth( 0f );
lDocument.acceptAllRevisions();
lDocument.setTrackRevisions( false );
lDocument.updateFields();
lDocument.updatePageLayout();

lDocument.save(lSaveName);

Hi Jeroen,


Thanks for your inquiry. You can simply remove comments from document before saving to PDF.
<span style=“background-color: rgb(255, 255, 255); font-family: “Courier New”; font-size: 9pt;”>
<span style=“background-color: rgb(255, 255, 255); font-family: “Courier New”; font-size: 9pt;”>Document doc = <span style=“font-family: “Courier New”; font-size: 9pt; color: rgb(0, 0, 128); font-weight: bold;”>new <span style=“background-color: rgb(255, 255, 255); font-family: “Courier New”; font-size: 9pt;”>Document(<span style=“font-family: “Courier New”; font-size: 9pt; color: rgb(0, 128, 0); font-weight: bold;”>“D:<span style=“font-family: “Courier New”; font-size: 9pt; color: rgb(0, 0, 128); font-weight: bold;”>\<span style=“font-family: “Courier New”; font-size: 9pt; color: rgb(0, 128, 0); font-weight: bold;”>temp<span style=“font-family: “Courier New”; font-size: 9pt; color: rgb(0, 0, 128); font-weight: bold;”>\<span style=“font-family: “Courier New”; font-size: 9pt; color: rgb(0, 128, 0); font-weight: bold;”>wordDocComment.docx”<span style=“background-color: rgb(255, 255, 255); font-family: “Courier New”; font-size: 9pt;”>);
<pre style=“font-family: “Courier New”; font-size: 9pt;”>
NodeCollection col = doc.getChildNodes(NodeType.COMMENT, true);
col.clear();


doc.save(
“D:\temp\awjava-17.2.0.pdf”);

Best regards,