導航:首頁 > 編程語言 > aspnet4高級程序設計pdf

aspnet4高級程序設計pdf

發布時間:2024-12-16 06:16:44

1. 急~急~~急~~~ ASP.NET 怎麼講圖片生成PDF文件,求代碼

我是藉助組件完成導出PDF文件的。在寫代碼之前,你要下載一個名為iTextSharp的組件,並將其引用到你的程序中。然後將生成的PDF文件通過流形式導出。

代碼如下:C#的

stringstrPDF_Nm=DateTime.Now.Year+"-"+DateTime.Now.Month+"-"+DateTime.Now.Day+"-"+DateTime.Now.Hour+"-"+DateTime.Now.Minute+".pdf";
iTextSharp.text.Documentdocument=newDocument();
iTextSharp.text.pdf.PdfWriterpdfwrite=PdfWriter.GetInstance(document,newFileStream(HttpContext.Current.Server.MapPath("~/img_Tmp/"+strPDF_Nm),FileMode.Create));
document.Open();
BaseFontbasefont=BaseFont.CreateFont(@"C:WindowsFontsSTKAITI.TTF",BaseFont.IDENTITY_H,BaseFont.NOT_EMBEDDED);
//解決PDF不能顯示中文的關鍵;創建一個中文楷體的字體對象
iTextSharp.text.Fontfont=newiTextSharp.text.Font(basefont,14);
iTextSharp.text.Tabletable=newiTextSharp.text.Table(4);
iTextSharp.text.Cellcells=newCell(newPhrase("不良報告",font));
cells.Colspan=4;
cells.HorizontalAlignment=1;
table.AddCell(cells);

iTextSharp.text.Imagejpg=iTextSharp.text.Image.GetInstance(Server.MapPath("~/img_Tmp/"+strSavePath));
document.Add(jpg);
document.Add(table);
document.Close();
pdfwrite.Close();
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.ContentType="application/PDF";
HttpContext.Current.Response.WriteFile(HttpContext.Current.Server.MapPath("~/img_Tmp/"+strPDF_Nm));
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.Close();

2. asp.net中,把word文檔轉為PDF格式文件的問題。

C#編程,將Word轉PDF,該方法有一定弊端,但是比起網路上的其他方法來說,還算比較好的,弊端是需要客戶機上安裝有WORD2007或更高的版本
1、添加引用:Microsoft.Office.Interop.Word版本12.0.0.0;2、在開頭添加命名空間引用:usingMicrosoft.Office.Interop.Word;3、具體實現方法如下:
//Word轉換成pdf
///<summary>
///把Word文件轉換成為PDF格式文件///</summary>
///<paramname="sourcePath">源文件路徑</param>///<paramname="targetPath">目標文件路徑</param>///<returns>true=轉換成功</returns>
privateboolWordToPDF(stringsourcePath,stringtargetPath){
boolresult=false;
Microsoft.Office.Interop.Word.WdExportFormatexportFormat=Microsoft.Office.Interop.Word.WdExportFormat.wdExportFormatPDF;objectparamMissing=Type.Missing;
Microsoft.Office.Interop.Word.=newMicrosoft.Office.Interop.Word.ApplicationClass();
Microsoft.Office.Interop.Word.DocumentwordDocument=null;try
{
objectparamSourceDocPath=sourcePath;stringparamExportFilePath=targetPath;
Microsoft.Office.Interop.Word.=exportFormat;
boolparamOpenAfterExport=false;
Microsoft.Office.Interop.Word.=Microsoft.Office.Interop.Word.WdExportOptimizeFor.wdExportOptimizeForPrint;Microsoft.Office.Interop.Word.WdExportRangeparamExportRange=Microsoft.Office.Interop.Word.WdExportRange.wdExportAllDocument;intparamStartPage=0;intparamEndPage=0;
Microsoft.Office.Interop.Word.WdExportItemparamExportItem=Microsoft.Office.Interop.Word.WdExportItem.wdExportDocumentContent;boolparamIncludeDocProps=true;boolparamKeepIRM=true;
Microsoft.Office.Interop.Word.=Microsoft.Office.Interop.Word.WdExportCreateBookmarks.wdExportCreateWordBookmarks;boolparamDocStructureTags=true;boolparamBitmapMissingFonts=true;boolparamUseISO19005_1=false;
wordDocument=wordApplication.Documents.Open(refparamSourceDocPath,refparamMissing,refparamMissing,refparamMissing,refparamMissing,refparamMissing,refparamMissing,refparamMissing,refparamMissing,refparamMissing,refparamMissing,refparamMissing,refparamMissing,refparamMissing,refparamMissing,refparamMissing);if(wordDocument!=null)
wordDocument.ExportAsFixedFormat(paramExportFilePath,paramExportFormat,paramOpenAfterExport,
paramExportOptimizeFor,paramExportRange,paramStartPage,paramEndPage,paramExportItem,paramIncludeDocProps,paramKeepIRM,paramCreateBookmarks,paramDocStructureTags,paramBitmapMissingFonts,paramUseISO19005_1,refparamMissing);
result=true;
if(wordDocument!=null){
wordDocument.Close(refparamMissing,refparamMissing,refparamMissing);wordDocument=null;}
if(wordApplication!=null){
wordApplication.Quit(refparamMissing,refparamMissing,refparamMissing);
wordApplication=null;}GC.Collect();
GC.WaitForPendingFinalizers();GC.Collect();
GC.WaitForPendingFinalizers();}catch{
result=false;
if(wordDocument!=null){
wordDocument.Close(refparamMissing,refparamMissing,refparamMissing);wordDocument=null;}
if(wordApplication!=null){

3. 求一個.net師傅帶帶我學ASP。NET網站開發。

初學的話,最好看看像《ASP.NET 開發實戰範例寶典》這類的書,跟著做例子,主要把各種工具控制項弄熟悉,上來就能就出東西,也會增加興趣;
熟悉那些基礎的東西後,在看看《ASP.NET 4高級程序設計:第4版》這種深入解析原理的書,了解下工作原理,至於AJAX,jquery,JSON一邊做例子一邊學就行,光看書有點白費;
網上也有很多小例子源碼,只要你感覺自己不會做就可以下載來研究一下,學技術主要還是動手寫寫小東西;

4. asp.net怎麼實現在網頁上寫pdf和將pdf載入到網頁上呢。如果有源碼可以分享最好了,謝謝!!!

<embed width ="800" height="600" src="a.pdf"> </embed> 親測有效。


1、<embed width="800" height="600" src="test_pdf.pdf"> </embed>


通過的瀏覽器:360、Firefox、IE、Chrome

2、<object
classid="clsid:CA8A9780-280D-11CF-A24D-444553540000" width="800" height="600"
border="0">

<param name="SRC" value="test_pdf.pdf">


</object>

下面這個完整點:

<object
classid="clsid:CA8A9780-280D-11CF-A24D-444553540000" width="100%" height="100%"
border="0"><!--IE-->
<param name="_Version"
value="65539">
<param name="_ExtentX" value="20108">

<param name="_ExtentY" value="10866">
<param
name="_StockProps" value="0">
<param name="SRC"
value="testing_pdf.pdf">
<embed src="testing_pdf.pdf" width="100%"
height="800" href="testing_pdf.pdf"></embed><!--FF-->

</object>

通過的瀏覽器:360、IE

未通過的瀏覽器:Firefox、Chrome


3、<iframe src="test_pdf.pdf" width="800"
height="600"></iframe>

通過的瀏覽器:360、Firefox、IE、Chrome


4、用瀏覽器直接訪問http://127.0.0.1/test_pdf.pdf (其實這個不算是在網頁內吧)


通過的瀏覽器:360、Firefox、IE、Chrome


以上四種方式均在WinXP下。(之前有碰到過上傳的功能在Win7下失效的情況,故在此說明一下OS)

閱讀全文

與aspnet4高級程序設計pdf相關的資料

熱點內容
app直通車是什麼意思 瀏覽:710
cad文件怎麼輸出為wmf文件 瀏覽:137
bat批量重命名word文件 瀏覽:64
汽車安卓導航懸浮 瀏覽:481
ps用快速蒙版調文件里黑白色 瀏覽:746
蘋果6iphone解鎖無法開啟 瀏覽:201
高通模式線刷工具 瀏覽:40
打開pDF顯示檢查文件許可權 瀏覽:825
怎麼刪除文件名中指定字元 瀏覽:595
圖片如何轉化文件格式 瀏覽:859
無貨源鋪貨有哪些app 瀏覽:316
30g的文件可以保存在哪裡 瀏覽:329
不同文件夾的pdf怎麼批量拆分 瀏覽:98
順豐速運文件到付多少錢 瀏覽:892
安裝的app在哪裡看 瀏覽:773
流量包和數據包什麼區別 瀏覽:851
編程語言事先定義好是什麼意思 瀏覽:919
怎麼轉換qlv文件 瀏覽:516
大眾網關版本 瀏覽:832
編程為什麼要用佔位符 瀏覽:108

友情鏈接