Forum Discussion

danmit's avatar
danmit
Occasional Contributor
2 years ago

PDF content decode

Hello community! 

 

Is there a way to decode the pdf content file that comes as a response from the API? 

Did a groovy script on asserting the file presence and size but need to add  an assertion for the content of the file also.

4 Replies

  • richie's avatar
    richie
    Community Hero
    Hey danmit,

    I'm responding to this cos no one else has yet.

    I've had a look around for literature on using groovy or java to decode a pdf and i haven't found anything....everything seems to point to progressing a base64 encode to pdf.

    I'm sure you CAN do it, but i can't with my knowledge of groovy/java. Perhaps one of the java experts on this thing can be of more help?

    However, with my "Test Architect" hat on, i'd argue against trying to decode the pdf anyway. As you know the pdf is an image, but if you've asserted on filesize down to the specific byte size, i'd suggest it's overkill to even bother trying the decode, as even a single different character in the file would cause a byte size differential, surely?

    That's all i got i'm afraid!

    Cheers,

    Rich
  • KarelHusa's avatar
    KarelHusa
    Champion Level 2

    danmit,

    why do you need to decode the PDF? What is the content type (encoding) of the response?

     

    Or, do you get a plain PDF and need to extract and check the PDF content (e.g., texts) in your tests?

     

    Best regards,

    Karel

     

    • danmit's avatar
      danmit
      Occasional Contributor

      The API response contains a PDF file. The file contains a table with data gathered from several tables from the database. The need for a decode is sustained by the fact that the request send some parameters (eg: "roleCode": "<int>" and a date period.) and the response file contains the information needed. In order to validate the complete test, the file must be checked for the correct data corresponding to the certain parameter combination.