function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Bernd NawrathBernd Nawrath 

PDF file to be sent but not found

hello dear community, I was having trouble sending a PDF to an opportunity, whenever I want to send the PDF files via Adons, Salesforce is telling me the file is not found, even though I have the PDF file saved as a component as well as its apex class which generates the specific contact information on the pdf which is going to be sent.
Also I wanted to change some things on the component but it doesn't help it because it cannot be sent anyway so what do I do?
Have a look on the code maybe there's something wrong:
thanks in advance!

(component aka PDF)
<apex:component controller="MandatPDF" access="global">
<apex:attribute name="accountId" type="string" assignTo="{!actId}" description="to fetch account contacts"/>
<apex:attribute name="opId" type="string" assignTo="{!oppId}" description="to fetch account contacts"/>
        <apex:repeat value="{!AccConOppList}" var="AccCon">

<style type="text/css">
@page {
   size: 210mm 297mm; /* A4 width and height */
    margin:0mm;
    margin-top: 10mm;
    margin-left: 10mm;
    margin-right: 18mm;
    marging-bottom: 5mm;
}
HTML, body, p, {
    margin: 0;
    padding: 0;
    }
    
#pageNum:before {
    content: "Seite " counter(page);
}
.pageNum {
   float: right;
}    
/* div {border: 1px solid #000;} */
.document {
    min-height: 272mm;
    position: relative; 
    font-family: "Sans-Serif";
    font-size: 10pt;
    margin-left: 10mm;
}
.logo {
    margin-right: 5mm;
    margin-left: -5mm;
    float: left;
}
.headline {
    font-size: 19pt;
    margin-top: 9.5mm;
    float: left;
}
.kdref {
    font-size: 8pt;
    padding-top: 10mm;
    text-align: right;
}
.doctype {
    font-size: 16pt;
    margin-top: 10mm;
    margin-bottom: 10mm;
    border-bottom: 1px solid #000;
}

.text {
    text-align: justify;
    font-size: 11pt;
    line-height: 16pt;
}

.footer-right {
    float: right;
    text-align: right;
}

.footer { position:absolute; bottom:0; width:100%;}
.page-break { display:block; page-break-after:always;}
.clearing { clear: both; }
</style>

<!-- ################ Seite 1 ################ -->
<div class="document page-break">
    <div class="logo"><img src="https://c.eu3.content.force.com/servlet/servlet.ImageServer?id=015w0000001JOTq&oid=00Dw0000000Cy2g&lastMod=1411384891000" width="53mm"/></div>
    <div class="headline">Tarifoptimierung für Privatpatienten</div>
    <div class="kdref clearing">Kundenreferenz&nbsp;<apex:outputField value="{!AccCon.Account.Kundennummer_del__c}"/></div>
    <div class="doctype">Bevollmächtigung</div>
    <div class="text">
        <div style="padding-bottom: 10mm;">Hiermit erteile ich&nbsp;<apex:outputField value="{!AccCon.Account.Name}"/>, geboren am&nbsp;<apex:outputField value="{!AccCon.Account.Geburtsdatum__c}"/>, wohnhaft in&nbsp;<apex:outputField value="{!AccCon.Account.PersonMailingCity}"/></div>
        
        <div style="float: left;width: 65mm;"><apex:outputField value="{!AccCon.Account.PersonMailingPostalCode}"/>&nbsp;<apex:outputField value="{!AccCon.Account.PersonMailingCity}"/></div><div style="float: left;width: 65mm;"><apex:outputField value="{!AccCon.Account.PersonMailingStreet}"/></div>
        <div style="float:left;font-size: 7pt; border-top: 1px solid #000; width: 60mm; margin-right: 5mm;">PLZ/Ort</div>
        <div style="float:left;font-size: 7pt; border-top: 1px solid #000; width: 60mm; margin-bottom: 5mm;">Straße</div>
        <div style="float:left; width: 60mm; margin-right: 5mm;">krankenversichert bei der</div>
        <div style="float:left;"><apex:outputText value="{!AccCon.Versicherungsgesellschaft__r.Name}"/></div>
        <div style="float:left; width: 60mm; font-size: 7pt; border-top: 1px solid #000;  margin-right: 20mm; margin-left: 65mm; margin-bottom: 3mm; padding: 0px;">Versicherungsgesellschaft</div>
        
        <div style="float:left; width: 60mm; margin-right: 5mm;">mit Versicherungsnummer</div>
        <div style="float:left;"><apex:outputText value="{!AccCon.Versicherungsscheinnummer__c}"/></div>
        <div style="float:left; width: 60mm; font-size: 7pt; border-top: 1px solid #000;  margin-right: 20mm; margin-left: 65mm; margin-bottom: 3mm; padding: 0px;"></div>
    </div>
    <div class="text clearing" style="padding-top: 1mm;">
        <p>der Mavencare GmbH die ausschließliche Vollmacht, Informationen zu der bestehenden Krankenversicherung des Auftraggebers beim Versicherer einzuholen und meine Interessen gegenüber dem Versicherer zu vertreten.</p>
        <p>Das umfasst unter anderem die Aufforderung an den Versicherer, für die von der Mavencare GmbH recherchierten Tarife, Berechnungen gemäß § 204 VVG vorzunehmen und diese vom Versicherer anzufordern. Des Weiteren ist die Mavencare GmbH bevollmächtigt, die Tarifumstellung im Auftrag des Auftraggebers gegenüber dem Versicherer einzuleiten und abzuwickeln und beim Versicherer Auskunft über den geltenden Tarif einzuholen.</p>
        <p>Sämtliche von der Mavencare GmbH angeforderten Unterlagen, Daten, Auskünfte und Informationen sind umgehend und direkt an die Mavencare GmbH zu übersenden.</p>
    </div>
    <div style="width: 100%; border-top: 1px solid #000; font-size: 7pt; margin-top: 20mm; padding-top: 3px;">
        <span style="margin-left: 12mm;">Ort, Datum</span><span style="margin-left: 70mm;">Unterschrift&nbsp;<apex:outputField value="{!AccCon.Account.Name}"/></span>
    </div>
    <div class="footer">
        <div style="float: left;font-size: 16pt; line-height: 22pt; margin-bottom: 4mm;">Bitte vorab per Email an<br/>oder per Telefax an</div>
        <div style="font-size: 16pt; line-height: 22pt;" class="footer-right">kontakt@mavencare.de<br/>040 - 1234567</div>
        <div style="border-top: 1px solid #000; padding-top: 4mm; font-size: 8pt;" class="clearing">Bitte Unterlagen im Original auf dem Postweg an:<br/><span style="font-size: 11pt;">Mavencare GmbH, Wittenbergener Weg 90, 22559 Hamburg</span></div>
    </div>
</div>


<!-- ################ Seite 2 ################ -->
<div class="document">
    <div class="logo"><img src="https://c.eu3.content.force.com/servlet/servlet.ImageServer?id=015w0000001JOTq&oid=00Dw0000000Cy2g&lastMod=1411384891000" width="53mm"/></div>
    <div class="headline">Tarifoptimierung für Privatpatienten</div>
    <div class="clearing" align="right" style="font-size: 8pt; padding-top: 10mm;"><span id="pageNum"></span></div>
    <div class="doctype">Dienstleistungsvertrag</div>
    <div class="text">
        <p>zwischen dem Kunden&nbsp;<apex:outputField value="{!AccCon.Account.Salutation}"/>&nbsp;<apex:outputField value="{!AccCon.Account.Name}"/> und der Mavencare GmbH.</p>
        <p>Die Mavencare GmbH ist vom Kunden beauftragt, die Möglichkeit eines Tarifwechsels innerhalb der Krankenversicherungsgesellschaft des Kunden zu prüfen. Mavencare recherchiert im Namen des Kunden nach Einsparungsmöglichkeiten.</p>
        <p>Erst wenn sich der Kunde entschließt, eine der durch die Mavencare GmbH recherchierten Einsparungsmöglichkeiten durch Tarifumstellung in Auftrag zu geben, wird eine Vergütung der Dienstleistung berechnet. Die Vergütung wird fällig mit der Tarifumstellung. Die Höhe der Vergütung bemisst sich an der monatlichen Ersparnis. Die Differenz zwischen der alten und neuen Monatsprämie multipliziert mit dem Faktor&nbsp;<apex:outputField value="{!AccCon.MC_Faktor__c}"/> ergibt die Gesamtvergütung zuzüglich der gesetzlichen Mehrwertsteuer. Es kann vereinbart werden, dass die Vergütung in acht gleichen Monatsraten gezahlt wird.</P>
        <p>Sollte der Kunde keine der durch die Mavencare GmbH recherchierten Tarifumstellungen nutzen, ist die Dienstleistung der Mavencare GmbH kostenfrei.</p>
        <p>Der Kunde hat mit diesem Schreiben die geltenden Allgemeinen Geschäftsbedingungen, Datenschutzerklärung und Widerrufsbelehrung erhalten, zur Kenntnis genommen und anerkannt.</p>
    </div>
    <div style="width: 100%; border-top: 1px solid #000; font-size: 7pt; margin-top: 20mm; padding-top: 0px;">
        <span style="margin-left: 12mm;">Ort, Datum</span><span style="margin-left: 70mm;">Unterschrift&nbsp;<apex:outputField value="{!AccCon.Account.Name}"/></span>
    </div>

    <div style="padding-left: 100mm; padding-top: 10mm;">
        <img src="https://c.eu3.content.force.com/servlet/servlet.FileDownload?file=015w0000001JOj0" width="80mm"/>
    </div>     
    <div style="width: 100%; border-top: 1px solid #000; font-size: 7pt; margin-top: -13mm; ">
        <span style="margin-left: 12mm;">Ort, Datum</span><span style="margin-left: 70mm;">Unterschrift Werner Gerdts / Mavencare GmbH</span>
    </div>
    <div style="padding-left: 10mm; margin-top: -8mm; ">Hamburg, den&nbsp;<apex:outputText value=" {!TODAY()}" /></div>

    <div class="footer">
        <div style="float: left;font-size: 16pt; line-height: 22pt; margin-bottom: 4mm;">Bitte vorab per Email an<br/>oder per Telefax an</div>
        <div style="font-size: 16pt; line-height: 22pt;" class="footer-right">kontakt@mavencare.de<br/>040 - 1234567</div>
        <div style="border-top: 1px solid #000; padding-top: 4mm; font-size: 8pt;" class="clearing">Bitte Unterlagen im Original auf dem Postweg an:<br/><span style="font-size: 11pt;">Mavencare GmbH, Wittenbergener Weg 90, 22559 Hamburg</span></div>
    </div>
</div>

</apex:repeat>
</apex:component>


(apex class)
public class MandatPDF {

// This ID is set by a parameter in the email template
public String actId{get;set;}
public String oppId{get;set;}
//public string Faktor{get;set;}
    // Datum für PDF vorbereiten
    public String getIPDatum()
    {
        Date tmpDatum   =   Date.today();
        system.debug('### ' + tmpDatum + 'Date as String: ' + string.valueOf(tmpDatum));
        
        // return Date as String
        return string.valueOf(tmpDatum);
        
    }

    // Account Informationen sammeln
    public List<Opportunity> getAccConOppList()
    {
        // Wenn die Seite als Vorschau geöffnet wird, kommt die ID als Id Parameter
        if(ApexPages.currentPage().getParameters().get('id')!='' && ApexPages.currentPage().getParameters().get('id').startsWith('001'))
        {
            actId = ApexPages.currentPage().getParameters().get('id');
        }

         // When page is seen as preview, ID appears as ID parameter 
        if(ApexPages.currentPage().getParameters().get('opId')!='' && ApexPages.currentPage().getParameters().get('opId').startsWith('006'))
        {
            oppId = ApexPages.currentPage().getParameters().get('opId');
        }       
        
        system.debug('### actId:' +actId);
        system.debug('### oppId:' +oppId);
        
        return [SELECT MC_Faktor__c, Account.Id, Account.Owner.Name, Account.Owner.Phone, Account.Name, Account.Salutation, Account.Geburtsdatum__c, Account.PersonEmail, Account.textliche_Ansprache__pc, Account.Kundennummer_del__c, Account.akademischer_Titel__pc,Account.PersonMailingStreet, Account.PersonMailingCity, Account.PersonMailingPostalCode, Account.Owner.Benutzer_Unterschriften_URL__c, Account.Owner.Durchwahl__c, Account.doc_salutation__c, Account.doc_academictitle__c, Account.doc_firstname__c, Account.doc_lastname__c, Account.doc_street__c, Account.doc_birthdate__c, Account.doc_zipcode__c, Account.doc_city__c, Account.doc_salutationtext__c, Versicherungsgesellschaft__r.Name, Versicherungsscheinnummer__c FROM Opportunity WHERE Id=:oppId];
        //return [SELECT Id, Owner.Name, Owner.Phone, Name, Salutation, Geburtsdatum__c, PersonEmail, textliche_Ansprache__pc, Kundennummer_del__c, akademischer_Titel__pc,PersonMailingStreet, PersonMailingCity, PersonMailingPostalCode, Owner.Benutzer_Unterschriften_URL__c, Owner.Durchwahl__c, doc_salutation__c, doc_academictitle__c, doc_firstname__c, doc_lastname__c, doc_street__c, doc_birthdate__c, doc_zipcode__c, doc_city__c, doc_salutationtext__c FROM Account WHERE Id = :actId LIMIT 1];
    }

}
KevinPKevinP
two things:

1: have you tried doing this pdf as a visualforce page, rather than a component?
2: if you use the <> button on the toolbar, we see line numbers, and syntax highlighting. Please use it in the future.
Bernd NawrathBernd Nawrath
@KevinP thank you I just noticed that this pdf actually exists as a visualforce page but still I'm not sure what the cause might be, any idea?:)