Revision details PDF compare

Hello I notice some problem with default save compared document to PDF.
It looks like PDF always export as “All markup” (compared to word). That produce some “first look” inconsistency like that:

To reproduce this you can use following code:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.writeln("paragraph1");
builder.writeln("paragraph2");

Document doc1 = new Document();
DocumentBuilder builder1 = new DocumentBuilder(doc1);
builder1.writeln("paragraph1 paragraph2");

doc.compare(doc1, "sd", new Date());
doc.save("a.docx");
doc.save("a.pdf");

Is there any option to control how PDF is generated?

@ANDREA.FARRIS Actually, revision appearance in MS Word is configured in MS Word not in the document. On my side, for example, MS Word is configured to show revisions in balloons. You can control how Aspose.Words renders revisions in PDF using RevisionOptions. For example see the following code:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.writeln("paragraph1");
builder.writeln("paragraph2");

Document doc1 = new Document();
DocumentBuilder builder1 = new DocumentBuilder(doc1);
builder1.writeln("paragraph1 paragraph2");

doc.compare(doc1, "sd", new Date());

doc.getLayoutOptions().getRevisionOptions().setShowInBalloons(ShowInBalloons.FORMAT_AND_DELETE);

doc.save("C:\\Temp\\a.docx");
doc.save("C:\\Temp\\a.pdf");

a.pdf (29.9 KB)

Hi Alexey. The problem is that final result between PDF and WORD outputs.
I am attaching image as example (on the left is PDF output and on right - Word output).

@dfinsolutions You can configure how revision look in PDF using RevisionOptions. Appearance of revisions in Word is configure in MS Word application:

Hi Alexey, can you please point which revision option makes output same as in word. I mean shows all the paragraphs as merged (as it is in revised document). Thank you.

@dfinsolutions Have you tried setting this options?

doc.getLayoutOptions().getRevisionOptions().setShowInBalloons(ShowInBalloons.FORMAT_AND_DELETE);

As I have mentioned, appearance of revisions depends on your MS Word settings and they might be shown differently on your and on my side.

Thank you Alexey, seems now working fine.

1 Like