*
* @return page number of this node
*/
- protected String getPageNumber()
+ public String getPageNumber()
{
return(pageNumber != -1)?new Integer(pageNumber).toString():null;
}
package org.apache.fop.datatypes;
import org.apache.fop.pdf.PDFGoTo;
+import org.apache.fop.layout.AreaContainer;
// Java
public void configureID(String id, Area area)
{
if ( id!=null && !id.equals("") ) {
- setPosition(id,area.getPage().getBody().getXPosition()-ID_PADDING,area.getPage().getBody().getYPosition() - area.getAbsoluteHeight()+ID_PADDING);
+ setPosition(id,area.getPage().getBody().getXPosition()+area.getTableCellXOffset()-ID_PADDING,area.getPage().getBody().getYPosition() - area.getAbsoluteHeight()+ID_PADDING);
setPageNumber(id,area.getPage().getNumber());
area.getPage().addToIDList(id);
}
IDReferences idReferences= area.getIDReferences();
String pageNumber=idReferences.getPageNumber(refId);
- String output = (pageNumber!=null)?pageNumber:"?";
-
int orig_start = this.marker;
- this.marker = ((BlockArea) area).addText(fs, red, green, blue, wrapOption, null, whiteSpaceTreatment, output.toCharArray(), 0, output.length());
+ if(pageNumber!=null) // if we already know the page number
+ {
+ String output=pageNumber;
+ this.marker = ((BlockArea) area).addText(fs, red, green, blue, wrapOption, null, whiteSpaceTreatment, output.toCharArray(), 0, output.length());
+ }
+ else // add pageNumberCitation to area to be resolved during rendering
+ {
+ this.marker = ((BlockArea) area).addPageNumberCitation(fs, red, green, blue, wrapOption, null, whiteSpaceTreatment, refId);
+ }
+
if ( this.marker == -1 )
{
}
}
+ public int addPageNumberCitation(FontState fontState, float red, float green,
+ float blue, int wrapOption, LinkSet ls,
+ int whiteSpaceTreatment, String refid) {
+
+ this.currentLineArea.changeFont(fontState);
+ this.currentLineArea.changeColor(red, green, blue);
+ this.currentLineArea.changeWrapOption(wrapOption);
+ this.currentLineArea.changeWhiteSpaceTreatment(whiteSpaceTreatment);
+
+ if (ls != null) {
+ this.currentLinkSet = ls;
+ ls.setYOffset(currentHeight);
+ }
+
+ this.currentLineArea.addPageNumberCitation(refid,ls);
+ this.hasLines = true;
+
+ return -1;
+
+ }
+
+Imaginary Buffer Line
public int addText(FontState fontState, float red, float green,
float blue, int wrapOption, LinkSet ls,
int whiteSpaceTreatment, char data[],
public class InlineArea extends Area {
private String text;
+ protected String pageNumberId=null;
private float red, green, blue;
public InlineArea(FontState fontState, float red, float green, float blue, String text, int width) {
public String getText() {
return this.text;
}
+
+ public String getPageNumberID() {
+ return pageNumberId;
+ }
}
import org.apache.fop.fo.properties.TextAlignLast; // for enumerated
// values
+import org.apache.fop.datatypes.IDNode;
+
public class LineArea extends Area {
protected int lineHeight;
renderer.renderLineArea(this);
}
+ public int addPageNumberCitation(String refid, LinkSet ls)
+ {
+
+ /* We should add code here to handle the case where the page number doesn't fit on the current line
+ */
+
+ //Space must be alloted to the page number, so currently we give it 3 spaces
+ int width= currentFontState.width(32) * 3;
+
+ PageNumberInlineArea pia = new PageNumberInlineArea(currentFontState,
+ this.red, this.green,
+ this.blue,
+ refid,
+ width);
+
+ pendingAreas.addElement(pia);
+ pendingWidth += width;
+ wordWidth = 0;
+
+ return -1;
+ }
+
+
public int addText(char odata[], int start, int end, LinkSet ls) {
boolean overrun = false;
* Renderer that renders areas to PDF
*/
public class PDFRenderer implements Renderer {
-
+
/** the PDF Document being created */
protected PDFDocument pdfDoc;
/** the /Resources object of the PDF document being created */
protected PDFResources pdfResources;
+ /** the IDReferences for this document */
+ protected IDReferences idReferences;
+
/** the current stream to add PDF commands to */
PDFStream currentStream;
public void render(AreaTree areaTree, PrintWriter writer)
throws IOException, FOPException {
MessageHandler.logln("rendering areas to PDF");
- IDReferences idReferences=areaTree.getIDReferences();
+ idReferences=areaTree.getIDReferences();
this.pdfResources = this.pdfDoc.getResources();
this.pdfDoc.setIDReferences(idReferences);
Enumeration e = areaTree.getPages().elements();
+(rx/1000f) + " " + (bl/1000f)
+ " Tm (");
- String s = area.getText();
+ String s;
+ if ( area.getPageNumberID()!=null ) { // this text is a page number, so resolve it
+ s = idReferences.getPageNumber(area.getPageNumberID());
+ }
+ else {
+ s = area.getText();
+ }
+
int l = s.length();
for (int i=0; i < l; i++) {