Page 2 of 3

Re: Add a new page dynamically

Posted: Thu Sep 24, 2015 1:12 pm
by rafaelwithoeft
Thank you, i will verify how that works

Re: Add a new page dynamically

Posted: Thu Sep 24, 2015 8:54 pm
by Ivan
Hello,

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

Thank you.

Re: Add a new page dynamically

Posted: Fri Sep 25, 2015 12:54 pm
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
	}

Re: Add a new page dynamically

Posted: Fri Sep 25, 2015 1:06 pm
by Vadim
Hello.
Just add

Code: Select all

outReport.setIsRendered(true);

Re: Add a new page dynamically

Posted: Fri Sep 25, 2015 1:26 pm
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

Re: Add a new page dynamically

Posted: Fri Sep 25, 2015 1:33 pm
by Vadim
We are always glad to help you.

Re: Add a new page dynamically

Posted: Tue Aug 30, 2016 9:06 am
by HighAley
Hello.

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

Code: Select all

report2.isRendered = true;
Thank you.

Re: Add a new page dynamically

Posted: Tue Aug 30, 2016 9:37 am
by HighAley
Hello.

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

Thank you.

Re: Add a new page dynamically

Posted: Tue Aug 30, 2016 11:06 am
by Alex K.
Hello,

Thank you. We will reply by email fast as possible.

Re: Add a new page dynamically

Posted: Thu Sep 01, 2016 6:02 am
by Alex K.
Hello,

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

Thank you.