ASP 导成PDF

ccjjww1222 2009-01-04 11:36:24
把数据库里面的数据 现在页面上显示(已实现)
然后导出PDF 并且保存
谁做过 给个例子 谢谢啦
...全文
124 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
勿说心想 2010-09-11
  • 打赏
  • 举报
回复
kanbudong
ccjjww1222 2009-01-04
  • 打赏
  • 举报
回复
服务器是自己的 可以使用组件
layers2323 2009-01-04
  • 打赏
  • 举报
回复
在没有组件情况下,asp好像不能像导出excel那样导出pdf吧。
明珠佩佩 2009-01-04
  • 打赏
  • 举报
回复
可以研究下PDF的SDK,里面有相关的使用例子

附上添加签名的代码

/*********************************************************************

ADOBE SYSTEMS INCORPORATED
Copyright (C) 1998-2004 Adobe Systems Incorporated
All rights reserved.

NOTICE: Adobe permits you to use, modify, and distribute this file
in accordance with the terms of the Adobe license agreement
accompanying it. If you have received this file from a source other
than Adobe, then your use, modification, or distribution of it
requires the prior written permission of Adobe.

---------------------------------------------------------------------

sdkAddSignature.js

- Folder level Acrobat JavaScript file.

*********************************************************************/


/** sdkAddSignature.js
Folder Javascript Created by Acrobat SDK.

This JavaScript sample shows you can programmatically sign a PDF document using
your digital ID file.

As a sample, this file has included all the digital signature information
except the path and password for the digital ID file to be used.
When you are ready to sign a PDF, click the newly added "Add My Signature"
menu item under the tool menu. After you input the platform independent path and
the password through a dialog, the program will create a digital
signature field in the top-left corner, and sign it with your data. The path
and password are valid in a Acrobat session, so you can continue to sign more
documents in the session without the input dialogs.
If you change the code to specify the path and password for the digital ID
file to be used in this file, then when you click the menu item, the program will
go automatically to sign PDFs without UI.

Using the function SetUserPassword() and function SetUserDigitalIDPath() in this
folder JavaScript code, you can call the JavaScript to quietly sign a PDF from other
JavaScript code, or from a plug-in or IAC VB or VC program through function
ExecuteThisScript( ). The VB and C Sample code is attached in end of this file.

A digital signature file ( DrTest.pfx ) is provided with the sample for your test.
To use it, put it in a folder, and specify the proper DIpath ( e.g. /C/DrTest.pfx ).
Its password is "testpassword".
*/


// password to use the digital signature
var sigUserPwd = "UNKNOWN";
// to test the sample without user input, specify:
// var sigUserPwd = "testpassword";

// path to the digital signature file
var sigDigitalIDPath = "UNKNOWN";
// to test the sample without user input, specify:
//var sigDigitalIDPath = "/C/DrTest.pfx";

// other variables the user can modify
var sigHandlerName = "Adobe.PPKLite";
var sigFieldname = "sdkSignatureTest";
var sigReason = "I want to test my digital signature program.";
var sigLocation = "San Jose, CA";
var sigContactInfo = "sendme@testinc.com";


/* Add a menu item for AddSignature */
app.addMenuItem( { cName: "ADBESDK:AddSignature", cUser: "Add My Signature", cParent: "Advanced",
cEnable: "event.rc = (event.target != null);",
cExec: "AddSignature(event.target)" });


// main function
function AddSignature(doc)
{
// if sigDigitalIDPath is not spcified, ask for user input
if(sigDigitalIDPath == "UNKNOWN"){
var cResponse = app.response({
cQuestion: "Input your digital ID path:",
cTitle: "Digital Signature",
cDefault: "/C/DrTest.pfx",
});

if ( cResponse == null) {
app.alert("No input.");
return;
}
else
SetUserDigitalIDPath(cResponse);
}

// if sigUserPwd is not spcified, ask for user input
if(sigUserPwd == "UNKNOWN"){
var cResponse = app.response({
cQuestion: "Input your password:",
cTitle: "Digital Signature",
cDefault: "testpassword",
});

if ( cResponse == null) {
app.alert("No input.");
return
}
else
SetUserPassword(cResponse);
}

// create a new signature field
var signatureField = AddSignatureField(doc);

// sign it
if(signatureField) Sign(signatureField, sigHandlerName);
}



// create a signature field in the upper left conner with name of sigFieldname
function AddSignatureField(doc)
{
var inch=72;
var aRect = doc.getPageBox( {nPage: 0} );
aRect[0] += 0.5*inch; // from upper left hand corner of page.
aRect[2] = aRect[0]+2*inch; // Make it 2 inch wide
aRect[1] -= 0.5*inch;
aRect[3] = aRect[1] - 0.5*inch; // and 0.5 inch high

var sigField = null;
try {
sigField = doc.addField(sigFieldname, "signature", 0, aRect );
} catch (e) {
console.println("An error occurred: " + e);
}

return sigField;
}

// define the Sign function as a privileged function
Sign = app.trustedFunction (
function( sigField, DigSigHandlerName )
{
try {
app.beginPriv();
var myEngine = security.getHandler(DigSigHandlerName);
myEngine.login( sigUserPwd, sigDigitalIDPath);
sigField.signatureSign({oSig: myEngine,
bUI: false,
oInfo: { password: sigUserPwd,
reason: sigReason,
location: sigLocation,
contactInfo: sigContactInfo}
});
app.endPriv
} catch (e) {
console.println("An error occurred: " + e);
}
}
);

// set a correct password for using the signature, so you can quietly sign a doc.
function SetUserPassword(pwd)
{
sigUserPwd = pwd;
}

// set path to the digital signature file
function SetUserDigitalIDPath(idPath)
{
sigDigitalIDPath = idPath;
}

/******************************************************
VB code in an Acrobat IAC program
to sign a PDF quietly ( no Acrobat running on screen ),
using the JS methods in this file
******************************************************
' .........
' At this point, a PDF file has been opened, but Acrobat may be hidden.

' get acrobat form object
Dim formApp As AFORMAUTLib.AFormApp
Set formApp = CreateObject("AFormAut.App")

' access some object property in objects inside AcroForm.
Dim fields As AFORMAUTLib.fields
Set fields = formApp.fields

' One way to use a JavaScript code in VB is through fields' method ExecuteThisJavascript.
'Dim nVersion As Integer
'nVersion = fields.ExecuteThisJavascript("event.value = app.viewerVersion;")
'MsgBox "The Acrobat Viewer Version is " & nVersion

'Sign the document
Dim menuItem As String
Dim digitalIDPwd As String
Dim digitalIDPath As String

digitalIDPwd = "testpassword"
digitalIDPath = "/C/DrTest.pfx"
menuItem = "ADBESDK:AddSignature"

Dim jsCode As String
Dim jsRc As Boolean
jsCode = "SetUserPassword(" + "'" + digitalIDPwd + "'); SetUserDigitalIDPath(" + "'" + digitalIDPath + "');" + "app.execMenuItem(" + "'" + menuItem + "');"

' Execute JS code to sign doc
fields.ExecuteThisJavascript (jsCode)

'save & close
AVDoc.Close (True)


' .........
*********************************************************************/

/******************************************************
C code in an Acrobat plug-in
to sign a PDF quietly using the JS methods in this file
******************************************************
ASBool MyCallJS(PDDoc pdDoc)
{
if(!pdDoc) return false;

char jsScript[512];
char* pwd="testpassword";
char* digitalIDPath = "/C/DrTest.pfx";
char* menuItem = "ADBESDK:AddSignature";

sprintf(jsScript, "SetUserPassword('%s'); SetUserDigitalIDPath('%s'); app.execMenuItem('%s');",
pwd, digitalIDPath, menuItem);

return AFExecuteThisScript (pdDoc, jsScript, NULL);
}

**************************************/
  • 打赏
  • 举报
回复
给个你参考一下

用asp实现Crystal Report 8.5导出到PDF问题解决
需要在服务器上做如下的动作:
安装IIS。
安装Crystal Report 8.5的开发版。开发版最多5个并发用户,在IIS下面的Crystal_Licence中可以预览到当前的并发和激活用户。
将C:\windows\crystal下面的Crxf_pdf.dll覆盖为V9.1.1.534的版本,文件更新日期为2002/7/10。此问题可以解决Export到PDF中文为乱码的问题。
至此如果用ASP开发导出的时候会出现“Unexpected Error”。那么可以用第5步来进行解决
打开Component管理,添加新的Application,设定Identity为Local Service。设定Security中的Enforce Access为不选。
添加新的Component,选择Craxdrt.dll.
导出代码:

Set session("ExportOptions") = Session("oRpt").ExportOptions
session("ExportFileName") = BasePath & sPO &".pdf"

session("ExportOptions").DiskFileName=session("ExportfileName")

session("ExportOptions").FormatType = cint(31) 'PDF

session("ExportOptions").DestinationType = 1

Session("oRpt").Export False

Session.Abandon
  • 打赏
  • 举报
回复
.net通过组件可以导出 asp好像没看到过 你可以baidu里找找

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧