Add a new page dynamically

Stimulsoft Reports.JAVA discussion
User avatar
rafaelwithoeft
Posts: 70
Joined: Thu Mar 05, 2015 8:26 pm

Re: Add a new page dynamically

Post by rafaelwithoeft »

Thank you, i will verify how that works
Ivan
Posts: 960
Joined: Thu Aug 10, 2006 1:37 am

Re: Add a new page dynamically

Post by Ivan »

Hello,

We are always glad to help you.
Let us know if you need any additional help.

Thank you.
User avatar
rafaelwithoeft
Posts: 70
Joined: Thu Mar 05, 2015 8:26 pm

Re: Add a new page dynamically

Post by rafaelwithoeft »

Hello, i tested the code and export directly to pdf works fine, as i needed.

But i have a function to edit the report if necessary and add the back page and return it to Viewer... the viewer not render the page :/
Where is my error?
Thank you...

Code: Select all

    //....another codes
    /*
     *add back page if necessary
     */
     if (json.has(this.IDENTIFICADOR_ADICIONAR_VERSO)) {
	    try {
		    String relatorioVersoString = json.getString(this.IDENTIFICADOR_ADICIONAR_VERSO);
		    if (!relatorioVersoString.isEmpty()) {
			    report = this.getMontarVersoRelatorio(report, relatorioVersoString);
		    }
	    } catch (JSONException e) {
		    //TODO 
	    } finally {
		    json.remove(this.IDENTIFICADOR_ADICIONAR_VERSO);
	    }
    }
}
report.render();

/*
* function to add back page
* *** (relatorioOriginal = original report)
* *** (nomeRelatorioPersonalizado = name of custom report (back page));
*/
private StiReport getMontarVersoRelatorio(StiReport relatorioOriginal, String nomeRelatorioPersonalizado) {
        StiReport outReport = StiReport.newInstance();
		try {
		        //more code...
                        //Code hidden to preserve the company, but his only get the custom xml report (backpage).
                        //more code...


			//get back page report
			InputStream stream = new ByteArrayInputStream(relatorioXmlString.getBytes(StandardCharsets.UTF_8));
			StiReport relatorioVerso = StiSerializeManager.deserializeReport(stream);

			relatorioOriginal.render(); // render main report
			relatorioVerso.render(); // render back page
			
			
	            outReport.setBookmark(relatorioOriginal.getBookmark());
	            outReport.getRenderedPages().clear();
	            for (StiPage page : relatorioOriginal.getRenderedPages()) {
	                outReport.getRenderedPages().add(page);
	                outReport.getRenderedPages().add((StiPage) relatorioVerso.getRenderedPages().get(0).clone());
	            }

                    //PDF WORKS FINE, that show main page + back page correctly, this code is test
	            StiExportManager.exportPdf(outReport, new FileOutputStream("C:\\temp\\out.pdf"));
                    //PDF WORKS FINE, that show main page + back page correctly, this code is test

		} catch (BancoDadosException | IOException | SAXException | StiDeserializationException | NullPointerException | StiException e) {
			e.printStackTrace();
			return relatorioOriginal; // if  catch error, return original report
		}
		return outReport; //otherwise, return edited report
	}
Vadim
Posts: 363
Joined: Tue Apr 23, 2013 11:23 am

Re: Add a new page dynamically

Post by Vadim »

Hello.
Just add

Code: Select all

outReport.setIsRendered(true);
User avatar
rafaelwithoeft
Posts: 70
Joined: Thu Mar 05, 2015 8:26 pm

Re: Add a new page dynamically

Post by rafaelwithoeft »

don't worked.. :cry:

---------------------
EDIT
---------------------


ohh, worked! Thank you...

There was a code "report.Render(false)" after edited to add back pages and it made does not work ...

Thank you again.
Best Regards
Vadim
Posts: 363
Joined: Tue Apr 23, 2013 11:23 am

Re: Add a new page dynamically

Post by Vadim »

We are always glad to help you.
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Add a new page dynamically

Post by HighAley »

Hello.

Please, set the isRendered property of the report2 to true.

Code: Select all

report2.isRendered = true;
Thank you.
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Add a new page dynamically

Post by HighAley »

Hello.

Please, send us your sample to support@stimulsoft.com.
We will analyze it and provide you a solution.

Thank you.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Add a new page dynamically

Post by Alex K. »

Hello,

Thank you. We will reply by email fast as possible.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Add a new page dynamically

Post by Alex K. »

Hello,

We have not yet received your request on mail. Please clarify on which email you send it.

Thank you.
Post Reply