導航:首頁 > 編程語言 > 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相關的資料

熱點內容
有兩個網站如何操作 瀏覽:499
excel怎麼把兩個表格中的數據導入 瀏覽:530
什麼是一二一二三APP 瀏覽:877
cs6的魔棒工具 瀏覽:243
文件夾變成受系統保護 瀏覽:479
雨林木風系統安裝教程win7 瀏覽:886
黨中央文件有哪些 瀏覽:872
關於頁眉頁腳文件圖片 瀏覽:147
editbin文件 瀏覽:199
手機怎麼編寫文件到qq 瀏覽:483
蘋果5怎麼樣清理內存 瀏覽:870
win7屏保文件 瀏覽:784
agk什麼文件 瀏覽:441
安卓app編程用什麼 瀏覽:222
文件下載路徑設置不可用 瀏覽:192
win7打不開本地視頻文件 瀏覽:740
怎麼解壓targz文件 瀏覽:358
大數據系統的預算一般多少 瀏覽:381
光陽智能網怎麼下載App 瀏覽:868
編程與c語言哪個好學 瀏覽:624

友情鏈接