• arronlee
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 3
    Replies

Hi Guys,

 

 I want to create a pdf of my vf page ,

 

 we can create like this way

 

pdfPage = page.product_delivery;//new PageReference('/apex/product_delivery1');
pdfPage.getParameters().put('id',oppid);
pdfPage.setRedirect(false);
Blob b=pdfPage.getContentAsPDF();

 

In my vf i am displaying some records with checkbox. When i click on Selected Button , It is displaying Selected Records.

 

I want to Create PDF for Selected Records only.

 

But it is Generating PDF for my intial VF page.. 

 

 

please suggest me..

 

 

 

prem

Hi Folks,

 

I am getting a pdf/word/excel file from the System and storing the binary information in a separate object. When I try to decode it in the attachment it is decoding in the right format but the file is not opening. It is giving Failed to open the pdf documnet error.

 

//In a separate method

fileBody=EncodingUtil.base64Encode(myfile.body);

 

DateTime todayDate=datetime.now();
ts=todayDate.format('yyyyMMddHHmmss');

Decimal ord=0.0;
List<Attachment_Creation__c> attList=new List<Attachment_Creation__c>();

while(fileBody!=null){
String str;
Attachment_Creation__c attcre=new Attachment_Creation__c();
if(fileBody.length()>32000){
str=fileBody.substring(0,32000);
filebody=fileBody.substring(32001);
attcre.File_Body__c=str;
attcre.Timestamp__c=ts;
attcre.Order__c=ord++;
attList.add(attcre);
}
else {
str=fileBody.substring(0);
attcre.File_Body__c=str;
attcre.Timestamp__c=ts;
attcre.Order__c=ord++;
attList.add(attcre);
fileBody=null;
}
}//while ends

if(attList.size()>0)
insert attList;

 

 

And, In the save method,

 

transient List<Attachment_Creation__c> att=[select Timestamp__c,File_Body__c,Order__c from Attachment_Creation__c where Timestamp__c=:ts order by Order__c asc];
String b='';
if(renderAttachmentSec && att.size()>0){
Attachment a = new Attachment(parentId = createAction.id, name=myfile.name);
for(Attachment_Creation__c sa:att){
b=b+sa.File_Body__c;
}
System.debug('£££ Body Save : '+b);

if(a.Name.contains('pdf')){
a.Name=a.Name+'.pdf';
a.ContentType='application/pdf';
// Blob bb=Blob.valueOf(b.trim());
// String s=EncodingUtil.base64Encode(bb);
a.Body=EncodingUtil.base64Decode(b.trim());
}

 

The reason I am doing in this way is, to avoid the View state issue. Please explain the right way to decode it and open the pdf.

 

Thanks

Raja

Hi..........

 

I want to generate PDF file for selected (check box selected in contact list"All" view) contact in the view...

 

For that I created a visualforce page custom button in contact list search layout. Now I selected some contacts through checkbox which is available in Contact list view...

 

How can I achieve above  requirement? anyone help me......

 

Shell I neet to write any apex code for this.?.............