• Arul Bernard I 14
  • NEWBIE
  • 10 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 9
    Replies
public class ProcessSheet_MergeController {

    Date myDate = system.today();
    Private Process_Sheet__c pageOpp;
    public Boolean initialised{get; set;}
    public id PageOppId {get; set;} 
    public Process_Sheet__c getID {get; set;}
    public ProcessSheet_MergeController(ApexPages.StandardController controller) {
          this.pageOpp = (Process_Sheet__c)controller.getRecord();
         PageOppId = ApexPages.currentPage().getParameters().get('processsheetId');
        initialised=false;
        system.debug('id = ' + pageOpp.id + '     id2' +PageOppId);
      
    initialised=false;
    }
    public PageReference  savePDF(){
    getID = new Process_sheet__c();
    getID = [Select id,name, xParts__c,Part_ID__c from Process_Sheet__c where id=:PageOppId];     
    System.debug('!!!'+getID);      
    
       if (!initialised && getID.ID !=NULL) {
    System.debug('GetID'+getId.Id);
    //PageReference pdf = Page.ProcessSheet;
    PageReference pdf ; //= Page.ProcessSheet;
    pdf = new PageReference('/apex/ProcessSheet');
    pdf.getParameters().put('processsheetId',PageOppId);
    pdf.getParameters().put('PartProcessFieldset', 'ProcessSheetTemplate');
    pdf.getParameters().put('ProcessSheetFieldset', 'ProcessSheetTemplate');

    // create the new attachment
    List<Attachment> attachList = new List<Attachment>();
    Attachment attach = new Attachment();
    Blob body;

    try {
               body = pdf.getContentAsPDF();
        system.debug('body should be fine');

        } catch (VisualforceException e) {
            system.debug('in the catch block');
             body = Blob.valueOf('Some Text');
        }

    attach.Body = body;
    attach.Name = 'PSA_'+ getID.name +'.pdf' ;
    attach.IsPrivate = false;
    attach.ParentId = getID.Id;
    List<Attachment> a = [Select ID, ParentID, body, Name from Attachment Where ParentID = :getID.Id];
    delete a;
    
    attachList.add(attach);
    
    insert attachList;
    
    system.debug('<<>>'+attach);
    initialised=true;
} else system.debug('tried to run twice');
return new PageReference('/apex/pdfMerge?processsheetId='+getID.id+'&PartProcessFieldset=ProcessSheetTemplate&ProcessSheetFieldset=ProcessSheetTemplate');

  public ProcessSheet_MergeController (){}
}
Here is my code,
public class pdfMerge_Controller {

public List<Attachment> att{get;set;}
public List<Attachment> attch{get;set;}

    public pdfMerge_Controller(ApexPages.StandardController controller) {
        String partid;
        String proId;
         id ProcessId = ApexPages.currentPage().getParameters().get('processsheetId');
    proId = [select id,part_id__c from process_sheet__c where id=:ProcessId].Id;
    partid = [select id,part_id__c from process_sheet__c where id=:ProcessId].part_id__c ;
    set<Id> Ids = new set<Id>();
    Ids.Add(partid);
    Ids.Add(proId);
    att=[Select a.Id,a.ContentType,a.ParentId,a.Parent.Type,a.Parent.Name,a.BodyLength From Attachment a where  a.parent.Id IN  :Ids AND name like 'PSA_%' ];  
    

    
    }

}
Hi,

I need to retrieve the attachment from Salesforce using java. Can anyone help me out with the solution
Hi,
    It's too hard to find the solution. Is there any other to merge pdf file.
Can Web Tabs be used to direct the flow to external sites also? For example, can it be used to navigate to https://www.google.com/. 
While I tried this example, I received a blank screen on clicking the web tab. So, wanted to explore if this is feasible and am I missing something.
<apex:page standardController="Process_Sheet__c"  extensions="AttachmentViewer"  showHeader="false" >          
            <apex:include pageName="accPDF"/>
            <apex:repeat value="{!att}" var="a">
            <apex:iframe src="{!URLFOR($Action.Attachment.Download, a.Id)}" height="400" />
            </apex:repeat>            
</apex:page>

In the page only apex include is working iframe is not working plz help me ....
 Thanks in Advance
I need to merge two visualforce page into a single page
I am using "renders - pdf". In that pdf page, I'm using command link and action is not working on the page. How to overcome this issue?
I have a requirement to grab a pdf file from child object using an external link.
That i mean if i click the external link, it should come up with a pdf file which i attached in child object.
 
I have a requirement where I want to merge two pdf into a single pdf and attach the attachments to the custom object in Salesforce.

PageReference pdf = PageReference(/apex/FirstPDF?id='+ccId);
Blob contentPdf = pdf.getContent();
PageReference cadre = new PageReference('/apex/SecondPDF?id=' + ccId);
Blob b = cadre.getContentPdf(); String combinedPdf = EncodingUtil.convertToHex(contentPdf)+EncodingUtil.convertToHex(b);
Blob horodatagePdf = EncodingUtil.convertFromHex(combinedPdf);
Attachment attachment = new Attachment();
attachment.Body = horodatagePdf;
attachment.Name = String.valueOf('New pdf.pdf');
attachment.ParentId = ccId; insert attachment;
Hi,

I need to retrieve the attachment from Salesforce using java. Can anyone help me out with the solution
<apex:page standardController="Process_Sheet__c"  extensions="AttachmentViewer"  showHeader="false" >          
            <apex:include pageName="accPDF"/>
            <apex:repeat value="{!att}" var="a">
            <apex:iframe src="{!URLFOR($Action.Attachment.Download, a.Id)}" height="400" />
            </apex:repeat>            
</apex:page>

In the page only apex include is working iframe is not working plz help me ....
 Thanks in Advance
I am using "renders - pdf". In that pdf page, I'm using command link and action is not working on the page. How to overcome this issue?
I have a custom button which instigates Apex to create a PDF and attach it to the record - this works. What I now want it to attach the PDF to a related object (child/parent relationship) but struggling with the ParentID - I underlined where the error is occurring.
Here is the code I have 
public with sharing class SaveAndOpenPDF {   public String recordId {     get {       return ApexPages.currentPage().getParameters().get('Id');     }   }   // this is to make testing a lot easier -- simply append renderAs=html   // to the url parameters to test, add displayOnly=1 if you don't want to save   public String renderAs {     get {       if (String.isBlank(ApexPages.currentPage().getParameters().get('renderAs'))) {         return 'pdf';       } else {         return ApexPages.currentPage().getParameters().get('renderAs');       }     }   }   public PageReference saveAndOpenPDF() {     if (String.isBlank(ApexPages.currentPage().getParameters().get('displayOnly'))) {       Id attachmentId = savePDF();       return openPDF(attachmentId);     } else {       return null;     }   }   public Id savePDF() {     Attachment attachment = new Attachment();     attachment.ParentId = 'aFA.Id';     attachment.name = 'PDF_'+String.valueof(Datetime.now())+'.pdf';     PageReference pdf = Page.SaveAndOpenPDF;     pdf.getParameters().put('Id', recordId);     pdf.getParameters().put('displayOnly', '1');     pdf.setRedirect(true);     try {       attachment.Body = pdf.getContent();     }     catch (VisualForceException e) {       attachment.Body = Blob.valueof('There was an error.');     }     attachment.ContentType = 'application/pdf';     insert attachment;     return attachment.Id;   }   public PageReference openPDF(Id attachmentId) {     PageReference ret = new PageReference('/servlet/servlet.FileDownload?file=' + attachmentId);     ret.setRedirect(true);     return ret;   } }
Hi Guys,

I have created one PDF page. So i want to add one more PDF into this PDF. Is it possible to do that. If it is possible how can i do that please help me out this problem.


Thanks,
Mahesh.