+ Start a Discussion

generating the Pdf with styles and markups in Lightning

Hi All,
I am generating the pdf for Account object using lightning components .In that i want to use some styles and markups with all the fields of selected  record in detailed page.As of now i am unable to get the all the fields and styles.components code is  working fine and generate the pdf.
But unable to get all the fields in pdf form.how to get the all the fields with styles,markups like visualforce pages in LEX..how to use the standard/custom styles in LEX.any one can please provide the solution for this,i am new to the LEX.

my components are

Apex class
public class TextVFPDFController {
    public Account acc{get;set;}
    public TextVFPDFController(){
        Id accId = apexpages.currentpage().getparameters().get('id');
        acc = [select Id,Name,Type,Rating,Phone from Account where id=: accId];
VF Page
<apex:page controller="TextVFPDFController" renderAs="PDF">
    <apex:includeLightning rendered="true" /> 

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" controller="TestAppController">
    <lightning:button variant = "brand" label = "Generate Pdf" onclick = "{!c.savePDF}" />

Client-side controller.js
    savePDF : function(component, event, helper) {
        var action = component.get("c.savePDFAccount");
        action.setParams({recordId : component.get("v.recordId")});
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                alert('Attachment saved successfully');
                console.log('pdf created successfully');
            else if (state === "ERROR") {
                var errors = response.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        console.log("Error message: " +
               else {
                        console.log("Unknown error");

Server-side controller.cls

public class TestAppController {
    public static void  savePDFAccount(Id recordId){
        PageReference pdfPage = new PageReference('/apex/TextVFPDF');
        Blob pdfContent = pdfPage.getContent();
        Attachment attach1= new Attachment();
        attach1.ParentId = recordId;
        //attach1.ParentId = parentId;
        attach1.Name ='Test Attachment for PDF';
        attach1.Body = pdfContent;
        attach1.contentType = 'application/pdf';
        insert attach1;

Thanks in advance
Raj VakatiRaj Vakati
Lightning styles are not supported in PDF rendering .. 
Hi Raj,
for this which one i used either vf or LEX.