Jump to content
We've recently updated our Privacy Statement, available here ×

Can we edit the JasperPrint object


2004 IR Help

Recommended Posts

By: Amad - afida

Can we edit the JasperPrint object

2005-02-20 16:16

It might sound little crazy but i have a requirement where I need to insert some text to JasperPrint, as after a user looks at the report, he/sge would approve it and I need to add "Approved" text to the report with the timestamp. I don't want to regenerate the report print as it could be differrent from what user has looked at so it has be the smae JasperPrint object. Is it possible?

 

Thanks

 

Amad

 

 

 

 

 

By: Philippe Damerval - damerval

RE: Can we edit the JasperPrint object

2005-02-20 16:39

I'm not sure what the JaserPrint object is made of, however instead of trying to edit it, you could store the data for the report as a Datasource object using some kind of persistence like Hibernate. Then you could use that to recreate the same report as the one that you submitted to the user, and use a parameter to identify whether a report was approved or not.

 

P.

 

 

 

 

By: Amad - afida

RE: Can we edit the JasperPrint object

2005-02-20 17:35

The problem is I need to edit the JasperPrint to indicate the approver's name and time of approval? I can save the report print thats not a problem, but I need to edit it before I save it...

 

 

 

 

 

 

By: Philippe Damerval - damerval

RE: Can we edit the JasperPrint object

2005-02-21 00:35

I am not suggesting you save the report print object, but rather, the Datasource object with which you fill the report. If you are using a live connection to a database, read about JDatasource in the API to find out how to obtain a JDatasource object from a database connection.

 

Another "trick" would consist of saving two versions of your report print object, one approved and one not approved, and establish the approved one as the "correct" copy in a data store of some kind.

 

P.

 

 

 

 

By: Amad - afida

RE: Can we edit the JasperPrint object

2005-02-21 02:08

Thanks Phil, I would do that but the issue is user can look at the report few times before approving it and I didn't want to persist it untill approved. May be I can write to a file as xml but i am not sure how to edit that print object once approved as it has to have the timestamp of approval.

 

 

 

 

By: Amad - afida

RE: Can we edit the JasperPrint object

2005-02-21 11:14

Anyone, I am still looking for some ideas!

 

Amad

 

 

 

 

By: Amad - afida

RE: Can we edit the JasperPrint object

2005-02-22 14:09

I guess there is no way to edit the JasperPrint. I must say I am little disappointed with this support forum, no one from Jasper team has even said " No you are crazy and its not possible"...

 

Amad

 

 

 

 

By: C-Box - c-box

RE: Can we edit the JasperPrint object

2005-02-22 22:55

Why don't you put a blank textfield on the report, give it a name like "approveText", make it's size as big as maximal could be and put it on the position it should appear. Then you show your report to the user...and store it as jrpxml-file (xml with embedded images)

 

If the user approved the report you could load again that jrpxml and parse it for your predefined textfield and put your real text "approved by XYZ at TODAY" in the CDATA-Element.

 

quite a lot of work and I've never tried... but I think worth to give it a try.

 

hth

C-Box

 

 

 

 

By: Amad - amadfida

RE: Can we edit the JasperPrint object

2005-03-22 16:36

Solution suggested by C-Box requires some work and I was wodnering if anyone else has some idea about modifying a JasperPrint object.

 

 

 

 

By: Amad - amadfida

RE: Can we edit the JasperPrint object

2005-03-22 17:04

In fact its quite painfull, for example if i have,

 

<text lineSpacingFactor="1.340332" leadingOffset="-2.6796875" textAlignment="Left" verticalAlignment="Top" rotation="None" runDirection="LTR" textHeight="0" lineSpacing="Single" isStyledText="false" hyperlinkType="None" hyperlinkTarget="Self">

<reportElement x="55" y="364" width="80" height="17" />

<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000" rightBorder="None" rightBorderColor="#FFFFFF" />

<font reportFont="normal" />

- <textContent>

- <![CDATA[ approveText

]]>

</textContent>

</text>

 

I can probably change the text but i will need to change the font color as well...

 

Please Please HELP me.

 

Amad

 

 

 

 

 

By: Amad - amadfida

RE: Can we edit the JasperPrint object

2005-03-22 17:41

One of thing i have just noticed that Jasperprint has this getAnchorIndexes() method, So I can define some dummy anchors for these approveText and then I can get this by text field by its anchor name and set its text?

 

Is is possible or am I dreaming...

 

 

 

 

By: alanHardwick - alan314

RE: Can we edit the JasperPrint object

2005-03-23 02:57

Not sure on the above or how to edit a existing object but...

 

How about adding a new Page to the Jasper Print object with the Approved text etc...

 

If so, you can get a good idea how to do it from PrintServiceApp.java program in the Jasper samples folder.

 

i.e. Dynamically create a page object using JRBasePrintPage and create a text object... add the Text (i.e. Approved/Rejected) to the Page and then add the whole lot to the Jasper Print using the JPrint addPage method..

 

 

 

 

 

By: Amad - amadfida

RE: Can we edit the JasperPrint object

2005-03-23 11:35

This will work, I think but I need to show this "Approve Text" on every page. Is it possible to merge pages in Jasper Print?

Link to comment
Share on other sites

  • 3 years later...
  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

// JasperPrint pr;
JRPrintPage currentPage = (JRPrintPage)pr.getPages().get(0);
JRBasePrintText ex;
ex = new JRBasePrintText(null);
ex.setX(36);
ex.setY(35);
ex.setWidth(100);
ex.setHeight(20);
ex.setText("Approved");
ex.setFontName("SansSerif");
ex.setFontSize(14);
currentPage.addElement(ex);
 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...