We are using report namespace to extract the Salesforce report data into csv using APEX. (There are no vf pages). Is there any way to write code in APEX to export the Salesforce report results into a pdf format.I am able to export the results only in CSV format.
In the below example, I tried to export a existing salesforce report data into csv, similar to this I am looking to export the results into a pdf format. (without using any apps or VF page render as option)
ApexPages.PageReference report = new ApexPages.PageReference('/reportid?csv=1');
Messaging.EmailFileAttachment attachment = new Messaging.EmailFileAttachment();
attachment.setFileName('report.csv');
attachment.setBody(report.getContent());
attachment.setContentType('text/csv');
System.debug('attachement==>'+ attachment);
Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
message.setFileAttachments(new Messaging.EmailFileAttachment[] { attachment } );
message.setSubject('Report');
message.setPlainTextBody('The report is attached.');
message.setToAddresses( new String[] { '[email protected]' } );
Messaging.sendEmail( new Messaging.SingleEmailMessage[] { message } );