Hi,
after flattenning pdf the links within document like TOC table stop working.
This is reproducible at least on aspose-pdf lib v 18.1 and 18.5
Sample code:
public class PdfClickableTOC {
private static final String SRC_DOC_PATH = “d:\temp\sampledocs\clickable toc\clickable_toc.pdf”;
public static void main(String[] args) {
try {
try (
InputStream is1 = new FileInputStream(SRC_DOC_PATH);
OutputStream os = new FileOutputStream("d:\\temp\\sampledocs\\clickable toc\\out-no flatten.pdf");
) {
Document doc = new Document(is1);
doc.save(os);
}
try (
InputStream is1 = new FileInputStream(SRC_DOC_PATH);
OutputStream os = new FileOutputStream("d:\\temp\\sampledocs\\clickable toc\\out-flatten.pdf");
) {
Document doc = new Document(is1);
doc.flatten();
doc.save(os);
}
try (
InputStream is1 = new FileInputStream(SRC_DOC_PATH);
OutputStream os = new FileOutputStream("d:\\temp\\sampledocs\\clickable toc\\out-flatten-settings.pdf");
) {
Document doc = new Document(is1);
FlattenSettings settings = new FlattenSettings();
settings.setUpdateAppearances(true);
settings.setCallEvents(true);
doc.flatten(settings);
doc.save(os);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
}
clickable_toc.pdf (38.8 KB)