Using iText , we can easily change the zoom level for links. There is even a code snippet that does this for a GoTo destination type. To participate in the conference you will find below.
PdfReader reader = new PdfReader(src); PdfDictionary page = reader.getPageN(11); PdfArray annots = page.getAsArray(PdfName.ANNOTS); for (int i = 0; i < annots.size(); i++) { PdfDictionary annotation = annots.getAsDict(i); if (PdfName.LINK.equals(annotation.getAsName(PdfName.SUBTYPE))) { PdfArray d = annotation.getAsArray(PdfName.DEST); if (d != null && d.size() == 5 && PdfName.XYZ.equals(d.getAsName(1))) d.set(4, new PdfNumber(0)); } }
The code deals only with one of the destination types found in the PDF files. I am interested in zooming in on other types of destinations (they are listed in 32000-1 if anyone was wondering). In particular, I would like to change each destination to GoTo and indicate my own coordinates. I want the left coordinate to be the same as the page height of the page to navigate. To do this, I obviously need a page number. How to get it?
What have i done so far? The PdfArray d = annotation.getAsArray(PdfName.DEST) command PdfArray d = annotation.getAsArray(PdfName.DEST) gives a su array, where its first (0-based) element is a page link, not a page number, as Bruno Loudji explains in his iText in Action, 2nd edition, p. 202). The array looks like this: iText in Action, 2nd edition, p. 202). The array looks like this: iText in Action, 2nd edition, p. 202). The array looks like this: [1931 0 R, / XYZ, 0, 677, 0] `. I can not find the correct command to get the page number myself, so this is a message.
source share