Accessing PDF data with xpath

Hi. I was wondering if there is a way to access the pdf base64 data returned from the get_report command using xpath. There is no tag for the data itself.

gmpReady_obj.get_report(report_id=‘a2ea755c-f41a-4ba8-8d72-2423ae6acc45’,report_format_id=‘c402cc3e-b531-11e1-9163-406186ea4fc5’,details=True)

typ<get_reports_response status="200" status_text="OK">
	<report id="a2ea755c-f41a-4ba8-8d72-2423ae6acc45" format_id="c402cc3e-b531-11e1-9163-406186ea4fc5" extension="pdf" content_type="application/pdf">
		<owner>
			<name>admin</name>
		</owner>
		<name>2022-04-12T08:19:10Z</name>
		<commen
t>
		</comment>
		<creation_time>2022-04-12T08:19:10Z</creation_time>
		<modification_time>2022-04-12T08:49:14Z</modification_time>
		<writable>0</writable>
		<in_use>0</in_use>
		<task id="de984b9c-6429-4906-bbcb-58d6bf06dce0">
			<name>testtask2</name>
		</task>
		<report_format id="c402cc3e-b531
-11e1-9163-406186ea4fc5">
			<name>PDF</name>
		</report_format>JVBERi0xLjUKJdDUxdgKNjUgMCBvYmoKPDwKL0xlbmd0aCAxMDYxICAgICAgCi9GaWx0ZXIgL0ZsYXRlRGVjb2RlCj4+e....pdf base 64 data

I am not sure if there is an XPath query for that. We are using the Python ETree API. See https://github.com/greenbone/gvm-tools/blob/main/scripts/export-pdf-report.gmp.py#L65

1 Like

Thank you for the link.

I have an issue running the code though.

I’m relatively new to python so I might be missing something.

there is a section in the code:

 report_element = response.find("report")
    print('rep element')
    print(report_element)
    #get the full content of the report element
    content = report_element.find("report_format").tail


report_element is an integer for the character pos. of ‘report’. It’s returning an error trying to run ‘find’ on an integer.