jeudi 29 janvier 2015

Add anchor to pdf using itext java and html


Vote count:

0




I try generate pdf from html using IText java. I need create link anchor. The sample code below.


Java code:



String k = pdfService.all(request);
OutputStream os = response.getOutputStream();
Document document = new Document();
PdfWriter writer = PdfWriter.getInstance(document, os);
document.open();
InputStream is = new ByteArrayInputStream(k.getBytes());
XMLWorkerHelper.getInstance().parseXHtml(writer, document, is);
document.close();


Html code:



<?xml version="1.0" encoding="utf-8"?>
<html>
<head>
<meta charset="utf-8"/>
<title>title</title>
</head>
<body bgcolor="#ffffff">
<p><a href="#anccc" >GoTo</a></p>
... some code ...
<p id="anccc">anchor</p>
</body>
</html>


But in the end when you click on the link does not go to anchor


What am I doing wrong?



asked 35 secs ago







Add anchor to pdf using itext java and html

Aucun commentaire:

Enregistrer un commentaire