PDF content decode
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
https://apimate.eu
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you need to extract text from a PDF, you can use the PDFBox library.
Here's an example of how to use PDFBox.
Alternatively, you can use the iTextPdf library.
https://apimate.eu
