| By Date: | <-- --> |
| By Thread: | <-- --> |
|
Hi Paulo, It is a simple fix that works
just for my example: I do not have the entire knowledge about the PDF format to
do more. The fixes are the following ones: -
For the method boormakDepth
(SimpleBoookmark class): Add the management of the _javascript_ Action {…} else if (PdfName.LAUNCH.equals(PdfReader.getPdfObject(myAction.get(PdfName.S))))
{ myMap.put("Action",
"Launch"); PdfObject
file = PdfReader.getPdfObject(myAction.get(PdfName.F)); if
(file == null) file
= PdfReader.getPdfObject(myAction.get(PdfName.WIN)); if
(file != null) { if
(file.isString()) { myMap.put("File",
((PdfString)file).toUnicodeString()); }
else if (file.isDictionary()) { file
= PdfReader.getPdfObject(((PdfDictionary)file).get(PdfName.F)); if
(file.isString()) { myMap.put("File",
((PdfString)file).toUnicodeString()); } } } } else if
(PdfName._javascript_.equals(PdfReader.getPdfObject(myAction.get(PdfName.S))))
{ PdfObject myJS = PdfReader.getPdfObject(myAction.get(PdfName.JS)); if
(myJS != null) { if
(myJS.isString()) { String myPage = myJS.toString().substring(myJS.toString().lastIndexOf('=')+1, myJS.toString().lastIndexOf(';')).trim(); myMap.put("Page", String.valueOf(Integer.parseInt(myPage)+1)); } } myMap.put("Action", "_javascript_"); } {…} -
For the method createOutlineAction {…}
else if ("Launch".equals(action)) {
String file = (String)map.get("File");
if (file != null) {
PdfDictionary dic = new PdfDictionary();
dic.put(PdfName.S, PdfName.LAUNCH);
dic.put(PdfName.F, new PdfString(file));
outline.put(PdfName.A, dic);
}
} // --- 2006-10-30: Add the
management of the _javascript_ Action else
if
("_javascript_".equals(action)) { String p; if
((p = (String)map.get("Named")) !=
null) { if
(namedAsNames) outline.put(PdfName.DEST, new
PdfName(p)); else outline.put(PdfName.DEST, new
PdfString(p, null)); } else
if
((p = (String)map.get("Page")) !=
null) { PdfArray ar =
new
PdfArray(); StringTokenizer tk = new StringTokenizer(p); int
n = Integer.parseInt(tk.nextToken()); ar.add(writer.getPageReference(n)); if
(!tk.hasMoreTokens())
{ ar.add(PdfName.XYZ); //My case concern this part of the code ar.add(new
float[]{0, 10000, 0}); } else
{ String fn =
tk.nextToken(); if
(fn.startsWith("/")) fn = fn.substring(1); ar.add(new
PdfName(fn)); for
(int
k = 0;
k < 4 &&
tk.hasMoreTokens(); ++k) { fn = tk.nextToken(); if
(fn.equals("null")) ar.add(PdfNull.PDFNULL); else ar.add(new
PdfNumber(fn)); } } outline.put(PdfName.DEST, ar); } } {…} As you can see it is a simple management of my case. If it can help you … Best Regards, Anne MUSSARD -----Message d'origine----- If you contribute the fix I'll include it in the next release. Paulo > -----Original Message----- > From: MUSSARD Anne [mailto:anne.mussard (at) infotel.com] > Sent: Monday, October 30, 2006 2:46 PM > To: itext-questions (at) lists.sourceforge.net > Cc: Paulo Soares > Subject: Outlines _javascript_ action > > Hi, > > > > You say on your site about the SimpleBookmark class the > following remarks: > > Bookmark processing in a simple way. It has some limitations, > mainly the only action types supported are GoTo, GoToR, URI > and Launch. > > The list structure is composed by a number of HashMap, keyed > by strings, one HashMap for each bookmark. The element values > are all strings with the exception of the key "Kids"
that has > another list for the child bookmarks. > > All the bookmarks have a "Title" with the bookmark title
and > optionally a "Style" that can be "bold",
"italic" or a > combination of both. They can also have a "Color" key
with a > value of three floats separated by spaces. The key
"Open" can > have the values "true" or "false" and signals
the open status > of the children. It's "true" by default. > > The actions and the parameters can be: > > * "Action" = "GoTo" - "Page"
| "Named" > > o "Page" = "3 XYZ 70 400 null" - page
number followed > by a destination (/XYZ is also accepted) > > o "Named" = "named_destination" > > * "Action" = "GoToR" -
"Page" | "Named" | "NamedN", > "File", ["NewWindow"] > > o "Page" = "3 XYZ 70 400 null" - page
number followed > by a destination (/XYZ is also accepted) > > o "Named" =
"named_destination_as_a_string" > > o "NamedN" =
"named_destination_as_a_name" > > o "File" - "the_file_to_open" > > o "NewWindow" - "true" or
"false" > > * "Action" = "URI" - "URI" > > o "URI" = "http://sf.net" - URI to jump
to > > * "Action" = "Launch" -
"File" > > o "File" -
"the_file_to_open_or_execute" > > As you can see in my following PDF example, the action is a > _javascript_ action. > > > > 109 0 obj<</Count 4/Type/Outlines/First 272 0 R/Last 278 0
R>> > > endobj > > 272 0 obj<</Parent 109 0 R/Next 274 0 R/Title(Bibliographic > data)/A 273 0 R>> > > endobj > > 273 0 obj<</S/_javascript_/JS(this.pageNum=0;)>> > > endobj > > 274 0 obj<</Parent 109 0 R/Next 276 0 R/Prev 272 0 > R/Title(Abstract)/A 275 0 R>> > > endobj > > 275 0 obj<</S/_javascript_/JS(this.pageNum=0;)>> > > endobj > > 276 0 obj<</Parent 109 0 R/Next 278 0 R/Prev 274 0 > R/Title(Description)/A 277 0 R>> > > endobj > > 277 0 obj<</S/_javascript_/JS(this.pageNum=1;)>> > > endobj > > 278 0 obj<</Parent 109 0 R/Prev 276 0 R/Title(Claims)/A 279
0 R>> > > endobj > > 279 0 obj<</S/_javascript_/JS(this.pageNum=2;)>> > > endobj > > > > Is it not possible to add this type of action to the > SimpleBookmark class? > > It does not seem to be very difficult: I did myself a fix > into the bookmarkDepth and createOutlineAction methods. > > But to have an adapted itext jar from you is more a solution I
think. > > > > Best regards, > > Anne MUSSARD > > > > > > > > Aviso Legal: Esta mensagem é destinada exclusivamente ao destinatário. Pode conter
informação confidencial ou legalmente protegida. A incorrecta transmissão desta
mensagem não significa a perca de confidencialidade. Se esta mensagem for
recebida por engano, por favor envie-a de volta para o remetente e apague-a do
seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de
usar, revelar ou distribuir qualquer parte desta mensagem. Disclaimer: This message is destined exclusively to the intended receiver. It may
contain confidential or legally protected information. The incorrect
transmission of this message does not mean the loss of its confidentiality. If
this message is received by mistake, please send it back to the sender and
delete it from your system immediately. It is forbidden to any person who is
not the intended receiver to use, distribute or copy any part of this message. |
------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________ iText-questions mailing list iText-questions (at) lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions