Patch: fox:document-info
Hi all. I added an extension element that allows to set entries in the PDF document information map. The extenstion element is a root extension element and it has two attributes: document-info-key and document-info-value. A usage example is: fox:document-info document-info-key=CreationDate document-info-value=2003-03-19/ I hope someone has time to look on it and can commit it into the CVS. The supplied patch is taken from the current CVS (fop-0_20_2-maintain branch). --Stefan PS: The following diff is the same as in the attachment: Only in projekte/infotakt/vdp/xml-fop: build diff -x .nbattrs -ru fop/xml-fop/src/codegen/extproperties.xml projekte/infotakt/vdp/xml-fop/src/codegen/extproperties.xml --- fop/xml-fop/src/codegen/extproperties.xml Wed Mar 19 08:46:33 2003 +++ projekte/infotakt/vdp/xml-fop/src/codegen/extproperties.xml Wed Mar 19 09:27:48 2003 @@ -19,5 +19,17 @@ datatypeString/datatype default/default /property +property + namedocument-info-key/name + inheritedfalse/inherited + datatypeString/datatype + default/ +/property +property + namedocument-info-value/name + inheritedfalse/inherited + datatypeString/datatype + default/ +/property /generic-property-list /property-list diff -x .nbattrs -ru fop/xml-fop/src/codegen/foproperties.xml projekte/infotakt/vdp/xml-fop/src/codegen/foproperties.xml --- fop/xml-fop/src/codegen/foproperties.xmlWed Mar 19 08:46:33 2003 +++ projekte/infotakt/vdp/xml-fop/src/codegen/foproperties.xml Wed Mar 19 08:54:36 2003 @@ -1650,6 +1650,20 @@ datatypeString/datatype default/default /property +!-- property of document-info extension element -- +property + namedocument-info-key/name + inheritedfalse/inherited + datatypeString/datatype + default/ +/property +!-- property of document-info extension element -- +property + namedocument-info-value/name + inheritedfalse/inherited + datatypeString/datatype + default/ +/property property nameshow-destination/name inheritedfalse/inherited Only in projekte/infotakt/vdp/xml-fop/src/org/apache/fop/extensions: DocumentInfo.java diff -x .nbattrs -ru fop/xml-fop/src/org/apache/fop/extensions/ExtensionElementMapping.java projekte/infotakt/vdp/xml-fop/src/org/apache/fop/extensions/ExtensionElementMapping.java --- fop/xml-fop/src/org/apache/fop/extensions/ExtensionElementMapping.java Wed Mar 19 08:46:33 2003 +++ projekte/infotakt/vdp/xml-fop/src/org/apache/fop/extensions/ExtensionElementMapping.java Wed Mar 19 09:01:15 2003 @@ -70,6 +70,7 @@ foObjs.put(label, Label.maker()); foObjs.put(continued-label, ContinuedLabel.maker()); foObjs.put(destination, Destination.maker()); +foObjs.put(document-info, DocumentInfo.maker()); } } diff -x .nbattrs -ru fop/xml-fop/src/org/apache/fop/pdf/PDFDocument.java projekte/infotakt/vdp/xml-fop/src/org/apache/fop/pdf/PDFDocument.java --- fop/xml-fop/src/org/apache/fop/pdf/PDFDocument.java Wed Mar 19 08:46:33 2003 +++ projekte/infotakt/vdp/xml-fop/src/org/apache/fop/pdf/PDFDocument.java Wed Mar 19 09:08:25 2003 @@ -314,7 +314,11 @@ PDFInfo pdfInfo = new PDFInfo(++this.objectcount); // set the default producer pdfInfo.setProducer(org.apache.fop.apps.Version.getVersion()); -this.objects.add(pdfInfo); + +// The document info is a trailer object. Extension elements have +// a chance to add document info before it is rendered. +addTrailerObject(pdfInfo); + return pdfInfo; } @@ -1436,4 +1440,12 @@ root.getDestinations().add(obj); } +/** + * Sets an entry in the document information map. + * @param aKey (required). + * @param aValue (required). + */ +public void setInfoEntry(String aKey, String aValue) { +info.setEntry(aKey, aValue); +} } diff -x .nbattrs -ru fop/xml-fop/src/org/apache/fop/pdf/PDFInfo.java projekte/infotakt/vdp/xml-fop/src/org/apache/fop/pdf/PDFInfo.java --- fop/xml-fop/src/org/apache/fop/pdf/PDFInfo.java Wed Mar 19 08:46:33 2003 +++ projekte/infotakt/vdp/xml-fop/src/org/apache/fop/pdf/PDFInfo.java Wed Mar 19 09:26:39 2003 @@ -52,6 +52,7 @@ // Java import java.io.UnsupportedEncodingException; +import java.util.*; /** * class representing an /Info object @@ -59,10 +60,10 @@ public class PDFInfo extends PDFObject { /** - * the application producing the PDF + * Maps entry names (like CreationDate or Producer to string values. */ -protected String producer; - +private Map entries = new HashMap(); + /** * create an Info object * @@ -78,7 +79,7 @@ * @param producer the producer string */ public void setProducer(String producer) { -this.producer = producer; +setEntry(Producer, producer); }
Re: Named Destinations
Hi Ricardo, your additions seem right to me. Yet, I would recommend not to replace the #dest=-syntax by the the #nameddest-syntax but to add simply another option. In other words there would be the following options to specify named destinations: 1. .pdf#page= 2. .pdf#dest= 3. .pdf#nameddest= 4. .pdf# The syntax used inside FOP to describe named destination must not necessarily support only what Adobe suggests. --Stefan Hi all, I'm really glad to see that in 0.20.5 it will be possible to create named destinations in PDF. I have some small sugestions about this functionality. I'm using Acrobat Reader 5.1 and I was surprised to find out that the url syntax '.pdf#dest=NamedDest' wasn't working for me. I've looked deeper into http://www.adobe.com/products/acrobat/pdfs/c01acrotip.pdf#page=4 and I found a difference between the table (.pdf#dest=NamedDest) and the examples (.pdf#namedest=NamedDest). Helas the syntax '.pdf#namedest=NamedDest' also didn't work. Finally I've tried the syntax '.pdf#nameddest=NamedDest' and it worked. I've also tested the syntax '.pdf#NamedDest' and it also works fine. After some googling I found http://www.adobe.com/support/techdocs/a17e.htm and it looks like that the later form is really the one supported. If you believe it to be safe, the changes required to contemplate the working forms in pdf/PDFDocument.java would be: Change PDF urls with named destinations Diff for src/org/apache/fop/pdf/PDFDocument.java (rev 1.30.2.8) 1096c1096 } else if ((index = destination.indexOf(.pdf#dest=)) 0) { --- } else if ((index = destination.indexOf(.pdf#nameddest=)) 0) { 1098c1098,1106 String dest = destination.substring(index + 10); --- String dest = destination.substring(index + 15); PDFFileSpec fileSpec = new PDFFileSpec(++this.objectcount, file); this.objects.add(fileSpec); action = new PDFGoToRemote(++this.objectcount, fileSpec, dest); this.objects.add(action); link.setAction(action); } else if ((index = destination.indexOf(.pdf#)) 0) { String file = destination.substring(0, index + 4); String dest = destination.substring(index + 5); In my use of named destinations, I generate named destinations for every bookmark I have in my documents. The fact that the extension element fox:destination is only processed when used as a root element forces me to make and additional pass on my xml document just to generate the named destinations. If fox:destination was also processed whent it is used as a child of a fox:outline, I could avoid that additional pass. One way to achieve this, would be to add/change the following in extensions/Outline.java and render/pdf/PDFRenderer.java: Allow fox:destination as child of fox:outline Diff for src/org/apache/fop/extensions/Outline.java (maint rev 1.4.2.5) 63a64 private ArrayList _destinations = new ArrayList(); 119a121,122 } else if (obj instanceof Destination) { _destinations.add(obj); 142a146,149 } public ArrayList getDestinations() { return _destinations; Diff for src/org/apache/fop/render/pdf/PDFRenderer.java (maint rev 1.91.2.15) 986,987c986 Destination d = (Destination)ext; pdfDoc.addDestination(d.getDestinationName(), d.getInternalDestination()); --- renderDestination((Destination) ext); 1021a1021,1030 // handle sub destinations List vd = outline.getDestinations(); for (int i = 0; i vd.size(); i++) { renderDestination((Destination) vd.get(i)); } } private void renderDestination(Destination d) { pdfDoc.addDestination(d.getDestinationName(), d.getInternalDestination()); BTW, shouldn't the method getName in extensions/Outline.java return fox:outline instead of fop:outline? The constructor warning messages use fox:outline. This is probably not the best way to provide this kind of patches. If you need anything else, feel free to ask, I'll do my best. I try to follow the digest of this list, but it might be better to email me directly also. In the last few days I've also added some problems to Bugzilla. This is the first time I use Bugzilla and I've tried not to waste your time and be as effective as possible. I hope I didn't make anything wrong... Congratulations to you all for the excellent job you are doing, :-)) Ricardo Amador - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]
Re: patch for Fop-Ant-Task (maintainance branch)
Here is the patch again in the required format. In the meantime I improved the Fop-Task in two more ways: 1. If nested filesets are processed then the directory structure of the input files is preserved in the output. Without the changes the Fop-Task flattened the directory structure. 2. An additional property logFiles=true|false controls whether the names of the files that are processed are logged or not. --Stefan PS: I attach the complete Fop-Task file also in case that the diff is not up-to-date. Would you please resubmit that patch as a unified diff (cvs diff -u) and attach it as a file, not as inline text? Thanks. On 28.01.2003 16:00:19 Stefan.Wachter wrote: The fop Ant task (org.apache.fop.tools.anttasks.Fop) has a bug that causes that the log level is always info. The following patch corrects it. Maybe one of the commiters can apply the patch. Jeremias Maerki - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED] Fop.java.diff Description: Binary data Fop.java Description: Binary data - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]
patch for Fop-Ant-Task (maintainance branch)
Hi all. The fop Ant task (org.apache.fop.tools.anttasks.Fop) has a bug that causes that the log level is always info. The following patch corrects it. Maybe one of the commiters can apply the patch. --Stefan *** fop/xml-fop/src/org/apache/fop/tools/anttasks/Fop.java Mon Nov 18 15:37:46 2002 --- projekte/infotakt/vdp/fop/src/org/apache/fop/tools/anttasks/Fop.javaTue Jan 28 15:22:51 2003 *** *** 140,149 --- 140,153 messageType = Project.MSG_INFO; } else if (messageLevel.equalsIgnoreCase(verbose)) { messageType = Project.MSG_VERBOSE; } else if (messageLevel.equalsIgnoreCase(debug)) { messageType = Project.MSG_DEBUG; + } else if (messageLevel.equalsIgnoreCase(err) || messageLevel.equalsIgnoreCase(error)) { + messageType = Project.MSG_ERR; + } else if (messageLevel.equalsIgnoreCase(warn)) { + messageType = Project.MSG_WARN; } else { log(messagelevel set to unknown value \ + messageLevel + \, Project.MSG_ERR); throw new BuildException(unknown messagelevel); } *** *** 174,185 /** * Starts execution of this task */ public void execute() throws BuildException { try { ! Starter starter = new FOPTaskStarter(this); starter.run(); } catch (FOPException ex) { throw new BuildException(ex); } --- 178,199 /** * Starts execution of this task */ public void execute() throws BuildException { + int logLevel = ConsoleLogger.LEVEL_INFO; + switch (getMessageType()) { + case Project.MSG_DEBUG : logLevel = ConsoleLogger.LEVEL_DEBUG; break; + case Project.MSG_INFO : logLevel = ConsoleLogger.LEVEL_INFO; break; + case Project.MSG_WARN : logLevel = ConsoleLogger.LEVEL_WARN; break; + case Project.MSG_ERR: logLevel = ConsoleLogger.LEVEL_ERROR; break; + case Project.MSG_VERBOSE: logLevel = ConsoleLogger.LEVEL_DEBUG; break; + } + Logger log = new ConsoleLogger(logLevel); + MessageHandler.setScreenLogger(log); try { ! Starter starter = new FOPTaskStarter(this, log); starter.run(); } catch (FOPException ex) { throw new BuildException(ex); } *** *** 189,203 class FOPTaskStarter extends Starter { Fop task; Logger log; ! FOPTaskStarter(Fop task) throws FOPException { this.task = task; ! ! log = new ConsoleLogger(ConsoleLogger.LEVEL_INFO); ! MessageHandler.setScreenLogger(log); } private int determineRenderer(String format) { if ((format == null) || format.equalsIgnoreCase(application/pdf) || --- 203,215 class FOPTaskStarter extends Starter { Fop task; Logger log; ! FOPTaskStarter(Fop task, Logger aLogger) throws FOPException { this.task = task; ! log = aLogger; } private int determineRenderer(String format) { if ((format == null) || format.equalsIgnoreCase(application/pdf) || *** *** 219,229 format.equalsIgnoreCase(at) || format.equalsIgnoreCase(xml)) { return Driver.RENDER_XML; } else { String err = Couldn't determine renderer to use: +format; - log.error(err); throw new BuildException(err); } } private String determineExtension(int renderer) { --- 231,240 *** *** 240,250 return .txt; case Driver.RENDER_XML: return .xml; default: String err = Unknown renderer: +renderer; - log.error(err); throw new BuildException(err); } } private File replaceExtension(File file, String expectedExt, --- 251,260 *** *** 275,285 } } task.log(Using base directory: + Configuration.getValue(baseDir), Project.MSG_DEBUG); } catch (Exception e) { ! log.error(Error setting base directory,e); } int rint = determineRenderer(task.getFormat()); String newExtension = determineExtension(rint); --- 285,296 } } task.log(Using base directory: + Configuration.getValue(baseDir), Project.MSG_DEBUG); } catch (Exception e) { ! ! task.log(Error setting base directory: + e, Project.MSG_ERR); } int rint = determineRenderer(task.getFormat()); String newExtension = determineExtension(rint);
Bug in label-end()
Hi all. The eval method of the label-end-function (org.apache.fop.fo.expr.LabelEndFunction.eval()) does not work correctly. The problem is that the width of the content-rectangle of the reference-area into which the list-block is placed is erronously returned to be zero. Here is a quote from the spec: label-end() = width of the content-rectangle of the reference-area into which the list-block is placed - (the value of the provisional-distance-between-starts + the value of the start-indent + start-intrusion-adjustment - the value of the provisional-label-separation) of the closest ancestor fo:list-block. The effect of this bug is that the label-end() function returns much too small values. Using these values in fo:list-item-label end-indent=label-end().../fo:list-item-label has the effect that the label is much too wide. I recognized the problem when I wanted to right-justify labels: fo:list-item fo:list-item-label end-indent=label-end() fo:block text-align=rightlabel/fo:block /fo:list-item-label fo:list-item-body start-indent=body-start() fo:blockbody/fo:block /fo:list-item-body /fo:list-item The result is that the label is rendered right of the body :-). body label I started debugging the code but unfortunately I do not understand the FOP internals. However, here are some interesting lines from the eval() method: // Should be CONTAINING_REFAREA but that doesn't work LengthBase base = new LengthBase(item, pInfo.getPropertyList(), LengthBase.CONTAINING_BOX); PercentLength refWidth = new PercentLength(1.0, base); labelEnd.addTerm(1.0, refWidth); labelEnd.addTerm(-1.0, distance); labelEnd.addTerm(-1.0, startIndent); labelEnd.addTerm(1.0, separation); // make sure value gets calculated labelEnd.computeValue(); Someone already wrote a comment that suggest that something is wrong here :-). Yet, whatever LengthBase is used (CONTAINING_BOX or CONTAINING_REFAREA) the result is both times the same. The base is returned to have 0 length. --Stefan - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]
patch for BasicLink
Hi all. The external-destination attribute of the fo:basic-link-Element must be an uri-specification. Uri specifications are defined in the spec as follows: A sequence of characters that is url(, followed by optional white space, followed by an optional single quote (') or double quote () character, followed by a URI reference as defined in [RFC2396], followed by an optional single quote (') or double quote () character, followed by optional white space, followed by ). The two quote characters must be the same and must both be present or absent. If the URI reference contains a single quote, the two quote characters must be present and be double quotes. The current BasicLink implementation (in the maintainance branch) does not support the url()-syntax. The following patch should solve this. The patch allows also the former (incorrect) form of omitting the url() function. --Stefan *** fop/xml-fop/src/org/apache/fop/fo/flow/BasicLink.java Fri Nov 22 16:10:46 2002 --- projekte/infotakt/vdp/fop/src/org/apache/fop/fo/flow/BasicLink.java Wed Jan 22 13:06:02 2003 *** *** 84,89 --- 84,97 } else if (!(destination = this.properties.get(external-destination).getString()).equals()) { linkType = LinkSet.EXTERNAL; + if (destination.startsWith(url() destination.endsWith())) { + destination = destination.substring(4, destination.length() - 1).trim(); + if (destination.startsWith(\) destination.endsWith(\)) { + destination = destination.substring(1, destination.length() - 1); + } else if (destination.startsWith(') destination.endsWith(')) { + destination = destination.substring(1, destination.length() - 1); + } + } } else { throw new FOPException(internal-destination or external-destination must be specified in basic-link); } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]
Patch for Named Destinations
Hi all. I patched the fop-0_20_2-maintain branch (21-01-2003, approx. 20:00 CET) to have named destinations. The patch allows to link to other PDF-Documents by the following syntax: fo:basic-link external-destination=handbuch-fop.pdf#dest=xyzexternal link to named destination/fo:basic-link fo:basic-link external-destination=handbuch-fop.pdf#page=5external link to page/fo:basic-link This part is based on work by Bernd Brandstetter published recently in the fop-user-list. In addition, the patch allows to define named destinations by a new extension element with the following syntax: fox:destination xmlns:fox=http://xml.apache.org/fop/extensions; destination-name=xyz internal-destination=N40001A/ The destination-name attribute must correspond to the value used in the link (dest=xyz above). The fox:destination elements must be children of the fo:root element. In addition, they must not be the last children, i.e. they should be placed right after the fo:root element opened. (Otherwise they get not processed for whaterever reason this is). This part is based on work by Lloyed McKenzie that was published in the fop-dev-list in November 2001. Two additional classes are neccessary: 1. The destination extension element (org.apache.fop.extensions.Destination) 2. The PDF element for the destination (org.apache.fop.pdf.PDFDestination) --Stefan named-destinations.diff Description: Binary data Destination.java Description: Binary data PDFDestination.java Description: Binary data - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]
Named Destinations
Hi all. Reading the mailing list archives (developer and user) I found that the topic of named destinations was raised several times and it seems that many people would like / need this feature. Studiying the changes list I even found the entry # Linking to a specific page and a named destinations of an external PDF file. (see www.adobe.com/products/acrobat/pdfs/c01acrotip.pdf) (CG) Thanks to Bernd Brandstetter. # update Unfortunately the corresponding patch (submitted on the user-list) seems not to be integrated in the next release 0.20.5. However, I could patch FOP myself. In addition, in November 2001, Lloyd McKenzie submitted a patch in the developer list that allowed the definition of named destinations (i.e. targets one can link to). His patch is not integrated either and I fruitlessly tried to apply it manually on the current version. Now my kind plea is that some of the FOP gurus could take a look on it and integrate this functionality. I am sure that many users would appreciate it much. --Stefan - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]