Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
abo
Contributor II
Contributor II

Jasperserver : get pdf output from reportExecutions

Hi everyone, i hope you're doing great. Couple years ago i didn't know how to use Talend, Jaspersoft. I have learned a lot by reading topics here. Thank you all =).

I am struggling with my JasperServer to export pdf.

I have a pdf output when i use Postman :

1 )i'm doing a post on my server :

http://jaspersoft.local/jasperserver/rest_v2/reportExecutions.

I get the result with requestId and exportId.

2) then i m doing a get to fetch the document :

http://jaspersoft.local/jasperserver/rest_v2/reportExecutions/

{{jasper_requestId}}

/exports/

{{jasper_exportId}}

/outputResource

=> attachment 1

Now i would like to do it with Talend.

I retrieve a string like this :

�# ��sDR�U=�9zĪ�7G�h��p��\�=fWm�X��]����z�# C��8����N,�# ��֑�q4DGf�a �9�k���X�# ߹&p=���f��,��\�]�m��z=��l�&�\K��Km�XZG��\K�f��s�9k��kv�f�j��z$X���5;���Q�PܦSu�m �

�����Q�;u��># ��tT�8XG&�# �j� ��o=p��JOm�������!�>/V�m�E:7D��`M`�=��=W��ݾ_���oH벧�n �F����> =M�Mj�C���z�f&�k

I don't know how to convert this into a readable pdf and of course how to output it.

I beg for your help =).

Kind regards.

1 Solution

Accepted Solutions
abo
Contributor II
Contributor II
Author

Hi Shong, i am gonna close this topic. I found a way by using the tFileFetch component and it's working just fine =).

 

Thank you again for your time.

 

Kind regards

View solution in original post

8 Replies
Anonymous
Not applicable

Hi

Can you show the response headers in postman?

 

Regards

Shong

abo
Contributor II
Contributor II
Author

Hi Shong, here the response.

 

Thanks.0695b00000fIwalAAC.png

Anonymous
Not applicable

I'm not sure whether the returned string is a Base64 string? Have a try to convert the base64 string to a PDF file on tJavaRow using these Java code.

abo
Contributor II
Contributor II
Author

Hi Shong, thank you for the reply, to be honest i am not used to work with java code. Should i create a routines from your code ? Can you explain me how plez ?

 

kind regards.

Anonymous
Not applicable

I tested the example provided in the page and it works, the pdf file is open and the content displays normally. see

0695b00000fJ54AAAS.pngcode on tJavaRow:

 File file = new File("d:/files/test.pdf");

 

  try ( FileOutputStream fos = new FileOutputStream(file); ) {

   // To be short I use a corrupted PDF string, so make sure to use a valid one if you want to preview the PDF file

   String b64 =input_row.line;

   byte[] decoder = Base64.getDecoder().decode(b64);

 

   fos.write(decoder);

   System.out.println("PDF File Saved");

  } catch (Exception e) {

   e.printStackTrace();

  }

 

in the advanced settings panel of tJavaRow, the import sections:

 

//import java.util.List;

import java.io.*;

import java.util.Base64;

 

 

In your case, the job looks like...

...tRestClient--main--tJavaRow

 

on tJavaRow, change this line

   String b64 =input_row.line;

to

  String b64 =input_row.string;

 

//string the column name on tRestClient, it stores the base64 string value.

 

Please try and let me know if you have any questions.

 

 

 

 

abo
Contributor II
Contributor II
Author

Thank you for the tip, i tried and here the return :

 

[statistics] connecting to socket on port 3621

[statistics] connected

java.lang.IllegalArgumentException: Illegal base64 character 25

at java.util.Base64$Decoder.decode0(Unknown Source)

at java.util.Base64$Decoder.decode(Unknown Source)

at java.util.Base64$Decoder.decode(Unknown Source)

at exploitation.copy_of_roadmap_post_report_0_1.Copy_of_roadmap_post_report.tWriteJSONField_1_InProcess(Copy_of_roadmap_post_report.java:3899)

at exploitation.copy_of_roadmap_post_report_0_1.Copy_of_roadmap_post_report$1ThreadXMLField_tWriteJSONField_1_Out.run(Copy_of_roadmap_post_report.java:723)

[statistics] disconnected

 

 

I created a dummy report, juste with one fiead "nb = 1". I extract the report output to give you the result ( it doesn't look like you base64 ).

 

You can find it here : https://uploadnow.io/f/lmXfG4h

 

kind regards

abo
Contributor II
Contributor II
Author

Hi Shong, i am gonna close this topic. I found a way by using the tFileFetch component and it's working just fine =).

 

Thank you again for your time.

 

Kind regards

Anonymous
Not applicable

Glad to hear that, thanks for your feedback!