asp 환경에서 무료 콤포넌트를 사용해서 asp.net 에서 html 문서를 pdf 다운로드하는 방법
1.http://selectpdf.com/ 사이트에서 SelectPdf-HtmlToPdf-v2.3.0.zip 다운로드하기
2. 다운 받은 파일 중 아래 파일을 웹서버(IIS) /Bin 폴더에 복사하기
ColorCode.dll
Select.HtmlToPdf.dll
Select.HtmlToPdf.xml
Select.Html.dep
3. 참고문서
https://code.msdn.microsoft.com/Convert-from-HTML-to-PDF-09ce2a1d
http://selectpdf.com/community-edition/
4. 다운로드 링크
http://selectpdf.com/free-downloads/
5. 작업 소스
사용방법은 아래 aspx 파일 링크를 클릭하면 자동으로 다운로드 됨...
pdf.aspx
--------------
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="pdf.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title> pdf download </title>
</head>
<body>
<form id="form1" runat="server">
</form>
</body>
</html>
--------------
pdf.aspx.cs
--------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SelectPdf;
using ColorCode;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// instantiate a html to pdf converter object
HtmlToPdf converter = new HtmlToPdf();
// create a new pdf document converting an url
PdfDocument doc = converter.ConvertUrl("http://aaa.co.kr/convert_pdf.asp?idx=" + Request["id"]);
//Request["id"]
// 1024 px
// save pdf document
doc.Save(Response, false, "Transcript_" + Request["id"] + ".pdf");
// close pdf document
doc.Close();
}
}
--------------
'HTML' 카테고리의 다른 글
다음 오픈에디터 ASP.Net 으로 구현, 다음에디터 엔터키 입력시 자동입력 P 태그 변경하기,PHP이미지 깨짐 (0) | 2024.02.19 |
---|---|
jQuery 레이어 팝업, jquery 이미지 배너 슬라이드,div 이동 및 애니메이션 효과 (0) | 2024.02.19 |
모바일 웹에서 이미지, 폰트 크기, abcupload,나누미,asp날짜 (0) | 2024.02.17 |
웹 사이트 최적화 기법 (1) | 2024.02.15 |
웹표준과 HTML, CSS (0) | 2024.02.15 |