Discussions
- General Development
- Schema Development
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules
- Security
- Mobile
- Force.com Sites & Site.com
- Chatter Development
- Java Development
- .NET Development
- Perl, PHP, Python & Ruby
- Desktop Integration
- APIs and Integrations
- Visual Workflow
- Apple, Mac and OS X
- VB and Office Development
- AppExchange Directory & Packaging
- Salesforce Labs & Open Source Projects
- Other Salesforce Applications
- Jobs Board
- Force.com Discussion Boards
- :
- Developer Boards for Force.com and Database.com
- :
- General Development
- :
- Re: HOW TO PRINT A PDF DOCUMENT BY PRESSING A BUT...
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
HOW TO PRINT A PDF DOCUMENT BY PRESSING A BUTTON IN SALESFORCE DIRECTLY WITHOUT "PREVIEW"
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-03-2013 07:37 PM
BELOW IS MY CODE ON THE BUTTON:
{!REQUIRESCRIPT("/soap/ajax/9.0/connection.js")}
var smid = '{!Sales_Memo__c.Id}';
var result = sforce.connection.query("select Id, No_of_Prints__c From Sales_Memo__c where Id = '{!Sales_Memo__c.Id}' limit 1");
var records = result.getArray("records");
if (records.length > 0) {
var record = records[0];
var i = record.No_of_Prints__c;
record.No_of_Prints__c = ++i;
var result = sforce.connection.update([record]);
if(result[0].getBoolean("success")) {
window.open("https://ap1.salesforce.com/apex/SMPDF_re?id="+smid);
document.location.reload();
}
else {
window.alert ("failed to update Sales Memo " + result[0]);
}
}
else {
window.alert ("No record found for Sales Memo Id : {!Sales_Memo__c.Id}" );
}
Re: HOW TO PRINT A PDF DOCUMENT BY PRESSING A BUTTON IN SALESFORCE DIRECTLY WITHOUT "PREVIEW&q
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-03-2013 11:31 PM
Hi,
Here you can simply call JavaScript print function to print document.
on successfull update you can call "window.print()" to print your document.
Or in better way you can call this window.print() function on onload event of javascript.
You can add this onload event in you "SMPDF_re" vf page.
Regards,
Purushottam
Purushottam Bhaigade Software Developer, Screen-Magic
purushottambhaigade@gmail.com | www.screen-magic.com
Re: HOW TO PRINT A PDF DOCUMENT BY PRESSING A BUTTON IN SALESFORCE DIRECTLY WITHOUT "PREVIEW&a
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-04-2013 01:46 AM
Thanks for your idea!
However, I dun know how to add the "window.print()" into my "SMPDF_re" vf page.
below is my code:
<apex:page standardController="Sales_Memo__c" tabStyle="Sales_Memo__c" extensions="SMPDF_reController" renderAs="pdf">
........................................
Re: HOW TO PRINT A PDF DOCUMENT BY PRESSING A BUTTON IN SALESFORCE DIRECTLY WITHOUT "PREVIEW&a
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-04-2013 02:52 AM
Hi,
You can add following code snippet into your visualforce page after <apex:page> tag
<script type="text/javascript">
window.onload=function(){
window.print();
};
</script>
I hope it will help you.
Regards,
Purushottam
Purushottam Bhaigade Software Developer, Screen-Magic
purushottambhaigade@gmail.com | www.screen-magic.com
Re: HOW TO PRINT A PDF DOCUMENT BY PRESSING A BUTTON IN SALESFORCE DIRECTLY WITHOUT "PREVIEW&a
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-06-2013 06:44 PM
It seems not work.Below is my code in visualforce page:
<apex:page standardController="Sales_Memo__c" tabStyle="Sales_Memo__c" extensions="SMPDF_reController" renderAs="pdf" >
<script type="text/javascript">
window.onload=function(){
window.print();
};
</script>
<head>
<style type="text/css">
body {
font-family: Arial, Helvetica, sans-serif;
color: #555;
font-size:11px;
}
@page{
size: 840px 1188px;
margin-top:77.4 px;
margin-bottom:48 px;
margin-left: 13px;
margin-right: 13px;
@bottom-center{
content: element(footer)
}
}
div.footer{
position: running(footer);
}
.detailInformation{
font-family: Arial, Helvetica, sans-serif;
font-size: 13px;
color: #000;
margin-left: 10px;
font-weight: normal;
}
td.detailInformation{
font-family: Arial, Helvetica, sans-serif;
font-size: 13px;
color: #000;
margin-left: 10px;
}
th.detailInformation{
font-family: Arial, Helvetica, sans-serif;
font-size: 13px;
color: #000;
margin-left: 10px;
}
.detailInformation1{
font-family: Arial, Helvetica, sans-serif;
font-size: 13px;
color: #000;
font-weight: normal;
}
td.detailInformation1{
font-family: Arial, Helvetica, sans-serif;
font-size: 13px;
color: #000;
}
th.detailInformation1{
font-family: Arial, Helvetica, sans-serif;
font-size: 13px;
color: #000;
}
.detailInformation3{
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
color: #000;
font-weight: normal;
}
.tabledetailInformation{
font-family: Arial, Helvetica, sans-serif;
font-size: 13px;
color: #000;
margin-left: 10px;
text-align: right
}
th.tabledetailInformation{
font-family: Arial, Helvetica, sans-serif;
font-size: 13px;
color: #000;
margin-left: 10px;
text-align: right
}
.detailInformationBold{
font-family: Arial, Helvetica, sans-serif;
font-size: 24px;
color: #000;
font-weight: bold;
}
.itemLabel{
font-family: Arial, Helvetica, sans-serif;
font-size: 13px;
color: #333;
font-weight: bold;
}
.itemtable{
border-left:1px solid #000;
border-right:1px solid #000;
border-top:none;
border-bottom:1px solid #000;
}
.itemtable td{
border:none;
}
.remarktable{
border:1px solid #000;
}
.remarktable td{
border:none;
}
</style>
</head>
<div class="footer">
<div> <apex:outputText value="{!SM.Sys_Store_Address__c}" /> <apex:outputText value="{!SM.Sy_store_phone__c}" /></div>
</div>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="40" align="right">
<apex:outputText value="{!SM.Sys_Reprint__c}" style="font-family: Arial, Helvetica, sans-serif;
font-size: 18px;
color: #000;
margin-left: 10px; "/>
</td>
</tr>
</table>
<table width="100%" height="180" border="1" cellpadding="0" cellspacing="0">
<tr>
<td>
<table width="100%" height="180" border="0" cellpadding="2" cellspacing="0">
<col width="18%"></col>
<col width="15%"></col>
<col width="11%"></col>
<col width="22%"></col>
<col width="17%"></col>
<col width="17%"></col>
<tbody>
<tr>
<th height="40" valign="Top" colspan="2" style="border-top:none;
border-right: 0.5px solid ;
border-bottom: 0.5px solid ;
border-left: none; ">
<apex:outputText value="Customer Name:" styleClass="itemLabel" />
<apex:outputText value="{!CustomerName}" styleClass="detailInformation"/>
</th>
<th height="40" valign="Top" colspan="2" style="border-top:none;
border-right: 0.5px solid ;
border-bottom: 0.5px solid ;
border-left: none; ">
<apex:outputText value="Tel.:" styleClass="itemLabel"/>
<apex:outputText value="{!PhoneCombine}" styleClass="detailInformation"/>
</th>
<th height="40" colspan="2" valign="Middle" style="border-top:none;
border-right: none;
border-bottom: 0.5px solid ;
border-left: none; ">
<apex:outputText value="SALES MEMO" styleClass="detailInformationBold"/></th>
</tr>
<tr>
<th height="96" valign="TOP" style="border-top:none;
border-right: none ;
border-bottom: 0.5px solid;
border-left: none; ">
<apex:outputText value="Delivery Address:" styleClass="itemLabel"/>
</th>
<th height="96" colspan="3" valign="TOP" style="border-top:none;
border-right: 0.5px solid ;
border-bottom: 0.5px solid ;
border-left: none; ">
<apex:outputText value="{!ShippingAddress}" styleClass="detailInformation1"/>
</th>
<th height="96" colspan="2" valign="TOP" style="border-top:none;
border-right: none;
border-bottom: 0.5px solid ;
border-left: none; ">
.......
......
......<td colspan="2" >
<apex:outputText value="I acknowledge and agree with Miele’s general terms & conditions attached." styleClass="itemLabel"/>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</apex:page>
Re: HOW TO PRINT A PDF DOCUMENT BY PRESSING A BUTTON IN SALESFORCE DIRECTLY WITHOUT "PREVIEW&a
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-06-2013 10:30 PM
Hi,
Yes it will not work because you are trying to execute jscript on pdf page.
When we use renderAs="pdf" then that page is no more html so it will not execute any javascript.
What you can do is you can simply remove attribute renderAs="pdf" from the page tag and your script will run.

