• Rajendra Patel
  • 0 Points
  • Member since 2014

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 3

Hello all

lets take this for example for a vf page 

apex:page standardController="Contact" extensions="vf_ContactsUpdateFieldSetsController" showHeader="false" sidebar="false"

 I want to be able to set the standartController with a changing value so this page would be dynamic and serve various objects.... and not just Contact

I also need to be able to use : contact = (Contact)controller.getRecord(); ----------> in a dynamic way so I can still can get the values from the screen

is there a way to achive that ? maybe by using only the extensions ? but how can I get the values of the fields in the screen ?


Any help or direction would be appriciated

background behind that need:
I would like to display a fieldset on that page , but the fieldset can be once from Contact , or any other Object.




I have used toPdf() method of Blob object in an apex class, that is triggered with a custom button for pdf file is attached to Account record.

Some css style features as style="border-top-style:dotted;", style="font-family: Arial Unicode MS;" are not display in pdf file. This style features are working in apex page that using renderAs="pdf" attribute. But it isn't work when pdfContent variable is used as parameter by toPdf() method.

Can somebody help me?


global class AccountPDFGenerator{
    webservice static void generateInvoicePDF(String accountId){
//        Account account = [SELECT Id,Name FROM Account WHERE Id=:accountId];
        String accId = accountId;
        String pdfContent = '';
           pdfContent +=   '<html>' +
                                '<body>' +
                                    '<p align="left" style="font-family: Arial Unicode MS;">öçşığü</p>' + 
                                    '<br/><br/>' +
                                    '<table>' +                     
                                        '<tr>' +
                                           '<td align="center" style="border-top-style:dotted; border-bottom-style:dotted;">ÖÇŞİĞÜ</td>' +
                                        '</tr>' +                                        
                                    '</table>' +
                                '</body>' +
        }catch(Exception e)
            pdfContent = pdfContent + '<P>THERE WAS AN ERROR GENERATING PDF: ' + e.getMessage() + '</P>';
        Attachment attachmentPDF = new Attachment();
        attachmentPDF.parentId = accId;
        attachmentPDF.Name = 'Invoice.pdf';
        attachmentPDF.body = Blob.toPDF(pdfContent);
        insert attachmentPDF; 

 This is javascript code of custom button.

sforce.apex.execute("AccountPDFGenerator","generateInvoicePDF", {accountId:"{!Account.Id}

I have used toPdf() method of Blob object in an apex class that is triggered with a custom button for attach pdf document to a custom object. But pdf content can not be displayed Turkish character and also can not be use some property of css. For example:


 I have used following apex code:

global class AccountPDFGenerator
    webservice static void generateInvoicePDF(String accountId)
//        Account account = [SELECT Id,Name FROM Account WHERE Id=:accountId];
        String accId = accountId;
        String pdfContent = '';
            pdfContent = '<html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"></meta></head><body>';           
            pdfContent = pdfContent + '<p style="color:red">' + 'öçşğüıÖÇŞĞÜİ' + '</p>';
pdfContent +=  '<table>' +                     
                                        '<tr>' +
                                           '<td align="center" style="border-top-style:dotted; border-bottom-style:dotted;">aaaaaaaa</td></tr></table>' + 
            pdfContent = pdfContent + '</body></html>';
        }catch(Exception e)
            pdfContent = pdfContent + '<P>THERE WAS AN ERROR GENERATING PDF: ' + e.getMessage() + '</P>';
 //       pdfContent = 'öçşğüıÖÇŞĞÜİ'; 
        Attachment attachmentPDF = new Attachment();
        attachmentPDF.parentId = accId;
        attachmentPDF.Name = 'Invoice.pdf';
//        attachmentPDF.body= Blob.valueOf(pdfContent);
        attachmentPDF.body = Blob.toPDF(pdfContent); //This creates the PDF content
        insert attachmentPDF;

 And this is javascript code of custom button:

sforce.apex.execute("AccountPDFGenerator","generateInvoicePDF", {accountId:"{!Account.Id}"});
window.alert("pdf created" );

Created of pdf file after clicking the custom button doesn't contain some character and some html feature as I mentioned. Output of the pdf document is öçüÖÇÜ for following line:

pdfContent = pdfContent + '<p style="color:red">' + 'öçşğüıÖÇŞĞÜİ' + '</p>';


 Do you have an any idea, can you help urgently?