1

I have a request, the client what to creat Robotic Process Automation that can read and treat a pdf generated from a visualforce. To do that, all the fields should be readable as it is appearing in the PDF. However, when we copy and paste the PDF content in notepad++ , we have the fields content first then the fields names at the end. Hence the Robotic Process Automation cannot read and treat the PDF.

enter image description here

enter image description here

<apex:page docType="html-5.0" standardController="AXXXX_xxxxxxx__c" extensions="AXXXX_Detailxxxxxxx" showHeader="false" sidebar="false">
<head>
<meta charset="UTF-8" />
<title>Détail xxxxxxx </title>    
<!--<apex:includeScript value="{!URLFOR($Resource.AXXXX_JsBarCode, 'JsBarcode.all.js')}"/>-->
<script src='https://cdn.jsdelivr.net/jsbarcode/3.5.1/JsBarcode.all.min.js'></script>
<!-- Libraries to take screenshot and image to pdf conversion -->
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> -->
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.2/jspdf.min.js"></script> -->
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.min.js"></script> -->
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/amcharts/3.13.0/exporting/rgbcolor.js"></script> -->
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/amcharts/3.13.0/exporting/canvg.js"></script> -->

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.2.61/jspdf.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.js"></script>
<script src="https://cdn.jsdelivr.net/canvas2image/0.1/base64.js"></script>
<script src="https://cdn.jsdelivr.net/canvas2image/0.1/canvas2image.js"></script>
<apex:includeScript value="{!URLFOR($Resource.AXXXX_JsBarCode, 'code39.js')}"/>
<!-- Code to take screenshot and image to pdf conversion-->

<style  type="text/css">         
#barcode39Client {font-weight: normal; font-style: normal; line-height:normal; Arial; font-size: 10pt}
#barcode39 {font-weight: normal; font-style: normal; line-height:normal; Arial; font-size: 10pt}
</style>
<style> type="text/css" media="print"> div.page {
height: 1250px;
width: 800px;
filter: progid:D/XImageTransform.Microsoft.BasicImage(Rotation=2);
font-size:16px !important;
}
body {

font-size:11pt;

}
</style>
</head>
<body>

<div class="page">
<apex:form id="theForm" >
<apex:actionFunction name="givefeedback" action="{!Retourxxxxxxx}"/>
<div id="resultForPdf">
<apex:pageBlock mode="edit" id="results" > 
<apex:pageBlockButtons id="PBButtons">
<apex:commandButton id="fermer" value="Fermer" onClick="window.close();" styleClass="myClass" />
</apex:pageBlockButtons>

<table style="width:100%">                                    
<tr>
<td style="text-align:left;width:100%;height:25px;">
<apex:image url="{!URLFOR($Resource.AXXXX_Images, 'AXXXX_Logo2.png')}" width="100%" height="110px" />
</td>
</tr>
</table>
<table style="width:100%" cellspacing="15"> 
<tr>
<td >
<div id="externalbox1" style="float: right;">
<div id="barcode39" style="float: right;"></div>
</div>
</td>
</tr>
<tr>
<td >
<div id="externalbox2" >
<div id="barcode39Client" style="width: 890px;" ></div>
</div>
</td>
</tr>

</table>
<table align="center">
<tr><th style="font-size:30pt;"><b>{!AXXXX_xxxxxxx__c.Theme__c}</b></th></tr>
</table>
<apex:pageBlockSection columns="1" showHeader="true" title="Informations xxxxxxxur"> 
<apex:outputField id="DR" label="DR" value="{!AXXXX_xxxxxxx__c.DR_xxxxxxxur__c}" />
<apex:outputField id="Agence" label="Agence" value="{!AXXXX_xxxxxxx__c.Agence_xxxxxxxur__c}" />
<apex:outputField id="xxxxxxxur" label="xxxxxxxur" value="{!AXXXX_xxxxxxx__c.xxxxxxxur__c}" />
</apex:pageBlockSection>

<apex:pageBlockSection columns="1" showHeader="true" title="Informations Client"> 
<apex:outputField id="RelationavecXXX" value="{!AXXXX_xxxxxxx__c.Relation_avec_XXX__c}"/>
<apex:outputField id="LibelleCompteClient" value="{!AXXXX_xxxxxxx__c.Libelle_compte_client__c}" rendered="{!isClientXXX}"/>
<apex:outputField id="CodeAgenceClient" value="{!AXXXX_xxxxxxx__c.Code_agence_client__c}" rendered="{!isClientXXX}"/>
<apex:outputText id="NumeroCompte" label="Numéro du compte" value="{!AXXXX_xxxxxxx__c.Numero_compte__c}{!AXXXX_xxxxxxx__c.Lettre_Cle__c}" rendered="{!isClientXXX}"/>
<apex:outputField id="LibelleProspect" label="Libellé Prospect" value="{!AXXXX_xxxxxxx__c.Libelle_compte_client__c}" rendered="{!isProspectXXX}"/>
</apex:pageBlockSection>

<apex:pageBlockSection columns="1" showHeader="true" title="Décision" rendered="{!(ACCOR_xxxx__c.Statut__c=='Décidé' || ACCOR_xxxx__c.Statut__c=='Transféré 2ème accord' || ACCOR_xxxx__c.Statut__c=='Pris en charge 2ème accord' || ACCOR_xxxx__c.Statut__c=='Décidé 2ème accord')}">
<apex:outputPanel rendered="{!isAssuranceVieBDPForm}">
<c:ACCOR_View_Decision1_AssuranceVieBDP record="{!ACCOR_xxxx__c}" />
</apex:outputPanel> 
</apex:pageBlockSection>


<script type="text/javascript">
var isClient = '{!isClientLCL}';
var isHors3CFacturationPARForm = '{!isHors3CFacturationPARForm}';
var isHors3CFacturationPROForm = '{!isHors3CFacturationPROForm}';
var isHors3CGestionComPARForm = '{!isHors3CGestionComPARForm}';
var isHors3CGestionComPROForm = '{!isHors3CGestionComPROForm}';
var isHors3CIndemniteClientForm = '{!isHors3CIndemniteClientForm }';
var isSortie_FDC_995 = '{!isSortie_FDC_995}';
var isFermetureCompte = '{!isFermetureCompte}';
var isCparGeneriqueForm = '{!isCparGeneriqueForm}'; 
var isCpar1a3Form = '{!isCpar1a3Form}';
var isCpar5a9Form = '{!isCpar5a9Form}';
var isCpar10Form = '{!isCpar10Form}';
var typeForm;
var codeDocument;


if(isHors3CFacturationPARForm == 'true' || isHors3CFacturationPROForm == 'true'|| isHors3CGestionComPARForm == 'true' || isHors3CGestionComPROForm == 'true' || isHors3CIndemniteClientForm == 'true'){                    
typeForm = 'true';
codeDocument = '90121004';
displayBarcode(codeDocument,isClient);
}
else if(isSortie_FDC_995 == 'true'){
typeForm = 'true';
codeDocument = '90120343';
displayBarcode(codeDocument,isClient);
}
else if(isFermetureCompte == 'true'){
typeForm = 'true';
codeDocument = '90129155';
displayBarcode(codeDocument,isClient);
}
else if(isCparGeneriqueForm == 'true' || isCpar1a3Form == 'true'|| isCpar5a9Form == 'true' || isCpar10Form == 'true' ){   
typeForm = 'true';
codeDocument = '90100185';
displayBarcode(codeDocument,isClient);

}else{
typeForm = 'false';
codeDocument = '';
}                                 


/* Début zone codebarre à activer */
function displayBarcode(codeDocument,isClient){

var numBarreClient = "90330002"+"{!ACCOR_xxxx__c.Code_agence_client__c}{!ACCOR_xxxx__c.Numero_compte__c}{!ACCOR_xxxx__c.Lettre_Cle__c}";




get_object("barcode39").innerHTML=DrawCode39Barcode(codeDocument,0,"yes","in", 0.02,3,1,3,"bottom","center", "font-size:10pt","black","white");
if(isClient =='true')
get_object("barcode39Client").innerHTML=DrawCode39Barcode(numBarreClient,0,"yes","in", 0.02,3,1,3,"bottom","center", "font-size:10pt","black","white");



window.print();

}

function get_object(id) {
var object = null;
if (document.layers) {
object = document.layers[id];
} else if (document.all) {
object = document.all[id];
} else if (document.getElementById) {
object = document.getElementById(id);
}
return object;
}
/*Fin zone codebarre à activer */                                                                                                                                                                                                 targetElem = document.getElementById('resultForPdf');
var nodesToRecover = [];
var nodesToRemove = [];
var svgs = $(targetElem).find('svg');
svgs.each(function(index, node) {
var parentNode = node.parentNode;
var svg = parentNode.innerHTML;
var canvas = document.createElement('canvas');
xml = (new XMLSerializer()).serializeToString(node);
xml = xml.replace(/xmlns=\"http:\/\/www\.w3\.org\/2000\/svg\"/, '');
canvg(canvas, xml); // html to image
nodesToRecover.push({
parent: parentNode,
child: node
})
parentNode.removeChild(node)
nodesToRemove.push({
parent: parentNode,
child: canvas
})
parentNode.appendChild(canvas)
})

html2canvas(targetElem, {
onrendered: function(canvas) {
canvas.style.visibility = 'hidden';

document.body.appendChild(canvas);

var doc = new jsPDF('portrait');
doc.internal.scaleFactor = 5;
doc.addHTML(canvas, 0, 0, {pagesplit: true}, function() { // add image to pdf file

})

}
})        
</script>
</body>
</apex:page>
0

It sounds as though this is due to formatting of the document columns in the PDF. Your columns appear be ordered in reverse.

Since you've not provided the source code for your PDF it's very difficult to give you any additional guidance. I don't know if you formatted this as a table, as a list or simply as lines within a div.

I'd suggest you try changing the way you formatted the document when creating it in Salesforce to see if it affects the way the output is rendered when you try to select it after you do. One thing to remember is that you're rendering to a very old standard of PDF and the not the most current one.

Edit - in response to comments:

Having looked at your code, you have a very complex page that generally would be very "iffy" to even print using the PDF render engine. The Flying Render PDF engine that Salesforce uses only Supports HTML 4.1, CSS 2.2 and NO Active content, but you've embedded it inside of an HTML 5 page with active content.

Also, I see apex you're using within your page code that are important to avoid to in order to even render a PDF page successfully. In particular are your '' references. I'd replace that instead with standard HTML <Table> markup. See Components That Are Unsafe to Use When Rendering as PDF section of Component Behavior When Rendered as PDF. With the active content you have your page, I'm surprised you're able to render your PDF at all.

As for your specific problem, I note that you're creating these as columns rather than as sequential cells in a row. That also means they'll get selected as columns rather than as rows. If you change your markup to have these within the table cells in rows that would easily solve the problem and get things in order. An alternative would be to define the tab order of your <PageBlockSection> columns and other elements which the PDF would also be expected to respect.

| improve this answer | |
  • Hello, tahnk you @crmprodev, please find attached the code – ihan Aug 27 '19 at 8:29
  • Thank you crmprogdev – ihan Aug 30 '19 at 13:41
  • You're welcome @ihan. Community etiquette is to help others by marking your question as solved through checking the answer that resolved your issue. If you don't, it leaves the impression to anyone who searches the topic later that your question wasn't answered to your satisfaction. Once you have sufficient reputation, you can also upvote posts and answers. – crmprogdev Aug 31 '19 at 13:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.