Go Back   CodingForums.com > :: Server side development > ASP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-11-2012, 07:07 AM   PM User | #1
deepsan
New to the CF scene

 
Join Date: Sep 2012
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
deepsan is an unknown quantity at this point
ASP pdf generator

Dear All,

I am actually working on an ASP project which purpose is to generate letters and print them.The generation and printing part is working well.Now I have to add an other option that which include a save button that also allow to save those letters in PDF format in a specific location.Can anyone please help me.Thank you.
Below is my code:
-------------------------------------------------------------------
<head>
<script type="text/javascript">
window.onload =function()
{
var content = window.opener.LoadLetterinPreview();
document.getElementById("print").innerHTML=content;

var url = window.opener.LoadLetterinPreview_url();
document.getElementById("url").innerHTML=url;
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
}
<script type="text/javascript">
document.oncontextmenu = function() { //disable right click button
return false;
}
}
function GetFrom(which)
{

xmlHttp=GetXmlHttpObject();

if (CheckxmlHttp(xmlHttp)) return;

var url = "./app_ajax_getassignment_asp.asp?";

switch(which) //if script will be used to make asynchronous more than one call
{
case 1: //Update mapping(missing and complete apps)
var str = document.getElementById("url").innerHTML;
str = str.replace(/&amp;/g, "&");
url += "a=updatemapping&"+str;

POP=1;
break;
}

xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stateChanged()
{

if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
if(xmlHttp.status == 200){
Populate(xmlHttp.responseText);
}
}
}

function Populate(str)
{
switch(POP)
{
case 1:
alert("Applications tagged as Printed");
break;
}
}
function Print(){

window.print();
Printed();
}

function Printed(){
if(confirm("Ok - Remove from list.\n\n Cancel - To print again."))
{
GetFrom(1);//updatePersonMapping();
}
}

function Close(){
window.close();
}
</script>
</head>
<body>
<div id="div_btn"><p align="center"><input type="button" value="Print" onclick="Print();" />&nbsp;&nbsp;&nbsp;&nbsp;
<input type="button" value="Close Window" onclick="Close();"/></p></div>
<div id="print" style="border:1px red solid; width:650px;"></div>
<div id="url" style=" display:none;border:1px blue solid;"></div>
</body>
</html>
-----------------------------------------------------------
Note:
var content = window.opener.LoadLetterinPreview();
document.getElementById("print").innerHTML=content;

The content is the letter which is loaded in the div print (<div id="print" style="border:1px red solid; width:650px;"></div>)
deepsan is offline   Reply With Quote
Old 10-11-2012, 02:31 PM   PM User | #2
alykins
Senior Coder

 
alykins's Avatar
 
Join Date: Apr 2011
Posts: 1,608
Thanks: 37
Thanked 183 Times in 182 Posts
alykins will become famous soon enough
Idk if this is what you are looking for or not. What I would try to do is open the PDF in a new window. If the user has Adobe on their machine then they will be able to save it.

If you already have the PDF generated and have the path then this will probably be of more use.

Sorry for the limited response... If this was ASP.NET I could give you a better answer :P
__________________

I code C hash-tag .Net
Reference: W3C W3CWiki .Net Lib
Validate: html CSS
Debug: Chrome FireFox IE
alykins is offline   Reply With Quote
Old 10-11-2012, 08:35 PM   PM User | #3
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,237
Thanks: 59
Thanked 3,998 Times in 3,967 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
And if the content is *NOT* already PDF, then you will have to use an ActiveX component to generate the PDF. The only really good one is AspPdf, available at www.asppdf.com I use it for several things; it works quite well. Very speedy, too.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:40 AM.


Advertisement
Log in to turn off these ads.