導航:首頁 > 版本升級 > net導出pdf文件

net導出pdf文件

發布時間:2022-12-23 23:02:51

① 如何把要列印的網頁導出成pdf文件

1、首先用chrome瀏覽器打開一個網頁,如圖所示。

② 關於asp.net 把網頁內容導出為PDF文件

有個叫ITextsharp的開源dll,如果只是簡單的報表可以滿足你的要求,對於html支持不怎麼好

③ asp.net中,gridview中的數據能不能導出成pdf格式的文件

asp.net中,gridview中的數據能不能導出成pdf格式的文件
本題只問最終結果?
結果是:

④ .net中如何將網頁中的數據導出成pdf文件

可以用水晶報表啊

⑤ asp.net中,gridview中的數據能不能導出成pdf格式的文件

system.web.ui.control
ctl=this.datagrid1;
//datagrid1是你在窗體中拖放的控制項
httpcontext.current.response.appendheader("content-disposition","attachment;filename=excel.xls");
httpcontext.current.response.charset
="utf-8";
httpcontext.current.response.contentencoding
=system.text.encoding.default;
httpcontext.current.response.contenttype
="application/ms-excel";
ctl.page.enableviewstate
=false;
system.io.stringwriter
tw
=
new
system.io.stringwriter()
;
system.web.ui.htmltextwriter
hw
=
new
system.web.ui.htmltextwriter
(tw);
ctl.rendercontrol(hw);
httpcontext.current.response.write(tw.tostring());
httpcontext.current.response.end();

⑥ vb.net 導出PDF

利用DataWindow.net在 vb.net 下導出PDF格式文件
利用datawindow.net,導出PDF文件,實現前提:
1.安裝Acrobat Distiller虛擬列印機,注意要用datawindow.net提供的列印驅動,在c:\program files\sybase\datawindow.net2.0\driver中,在文章最後,我會提供一個靜態安裝虛擬列印機的批處理文件,方便安裝。
2.安裝Ghostscript 7.05 ,在網上找,免費的。
3.導出PDF文件前,一要指定虛擬列印機名,其次導出格式為PDF(Export.PDF.Method=Distill!),另外還要指定 PDF.Distill.CustomPostScript=Yes。
具體代碼如下:
''' <summary>
''' 導出文件
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
''' <remarks></remarks>
Private Sub btnExport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExport.Click
Try
Dim strFilename, strPrinter As String
Dim saveDg As New SaveFileDialog
strPrinter = Me.dwPrint.Describe("DataWindow.Print.PrinterName")
saveDg.FileName = Me.dwPrint.Tag.ToString
saveDg.Filter = "Pdf文件|*.pdf|Excel文件|*.xls|所有文件|*.*"
If saveDg.ShowDialog = Windows.Forms.DialogResult.OK Then
strFilename = saveDg.FileName
If strFilename.IndexOf(".pdf") > 0 Then
Me.dwPrint.Modify("DataWindow.Print.PrinterName='Acrobat Distiller'")
Me.dwPrint.Modify("DataWindow.Export.PDF.Method=Distill!")
Me.dwPrint.Modify("DataWindow.Export.PDF.Distill.CustomPostScript=Yes")
Me.dwPrint.SaveAs(strFilename, Sybase.DataWindow.FileSaveAsType.Pdf, True)
ElseIf strFilename.IndexOf(".xls") > 0 Then
Me.dwPrint.SaveAs(strFilename, Sybase.DataWindow.FileSaveAsType.Excel, True)
End If
Me.dwPrint.Modify("DataWindow.Print.PrinterName='" + strPrinter + "'")
MessageBox.Show("導出成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub

4 批處理文件(實現靜默安裝)

⑦ 怎樣把.net頁面中的表格轉換成pdf

安裝Adobe Acrobat軟體,安裝成功後網頁有個「將網頁轉換為PDF」的插件功能,能將任何網頁及文檔轉成PDF文檔。

⑧ 如何用.NET將DWG文件列印為PDF

因為有人問到,所以寫了個例子。具體的要求是從.NET(比如C#)裡面調用AutoCAD ActiveX API實現後台列印DWG文件為PDF文件,而且要把列印頁面的大小設置成和DWG視圖的頁面的大小一致。當然除了ActiveX API,其它介面,比如ObjectARX和AutoCAD.NET API也支持列印並能實現上述功能的。不過我們今天就限定一下范圍,用一用ActiveX API,而且指定產品是AutoCAD 2010吧。
執行步驟:打開一個dwg文件,用netload載入下面代碼所在的.dll文件,再輸入命令plottest,就得到輸出結果(一個.pdf文件)。
要用到的參考:
AcDbMgd.dll;AcMgd.dll;AutoCAD 2010 Type Library;System.Windows.Forms; AutoCAD/ObjectDBX Common 18.0 Type Library.
VB.NET:
Imports System
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.Interop
Imports Autodesk.AutoCAD.Interop.Common
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput

<Autodesk.AutoCAD.Runtime.CommandMethod("Plottest")> _
Public Sub PlotToPDF()
Dim activeDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim ThisDrawing As AcadDocument = CType(activeDoc.AcadDocument, AcadDocument)
Dim layout As AcadLayout = ThisDrawing.ActiveLayout
Dim MediaName As String = layout.CanonicalMediaName
If MediaName.Equals("") Then
activeDoc.Editor.WriteMessage("There is no media set for the active layout.")
Return
Else
activeDoc.Editor.WriteMessage(("The media for the active layout is: " + MediaName))
End If
Try
Dim oplot As AcadPlotConfiguration = ThisDrawing.PlotConfigurations.Add("PDF", layout.ModelType)
oplot.PaperUnits = AcPlotPaperUnits.acMillimeters
oplot.StyleSheet = "monochrome.ctb"
oplot.PlotWithPlotStyles = True
oplot.ConfigName = "DWG To PDF.pc3"
oplot.UseStandardScale = True
oplot.StandardScale = AcPlotScale.acScaleToFit
oplot.PlotType = AcPlotType.acExtents
oplot.CenterPlot = True
Dim oMediaNames As Object = layout.GetCanonicalMediaNames
Dim mediaNames As ArrayList = New ArrayList(CType(oMediaNames, String()))
For Each sName As String In mediaNames
If sName.Contains(MediaName) Then
oplot.CanonicalMediaName = sName
layout.CopyFrom(oplot)
layout.PlotRotation = AcPlotRotation.ac0degrees
layout.RefreshPlotDeviceInfo()
ThisDrawing.SetVariable("BACKGROUNDPLOT", 0)
ThisDrawing.Plot.QuietErrorMode = True
ThisDrawing.Plot.PlotToFile("c:/temp/d1.pdf", "DWG To PDF.pc3")
oplot.Delete()
oplot = Nothing
Return
End If
Next
Catch es As System.Exception
System.Windows.Forms.MessageBox.Show(es.ToString)
End Try
End Sub

C#:
using System;
using System.Collections;
using System.Collections.Specialized;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Interop;
using Autodesk.AutoCAD.Interop.Common;

// Define Command "plotTest"
[CommandMethod("plotTest")]
static public void PlotToPDF()
{
Document activeDoc = Application.DocumentManager.MdiActiveDocument;
AcadDocument ThisDrawing = activeDoc.AcadDocument as AcadDocument;
AcadLayout layout = ThisDrawing.ActiveLayout;

String MediaName = layout.CanonicalMediaName;
if (MediaName.Equals(""))
{
activeDoc.Editor.WriteMessage("There is no media set for the active layout.");
return;
}
else
{
activeDoc.Editor.WriteMessage("The media for the active layout is: " + MediaName);
}

try
{
AcadPlotConfiguration oplot = ThisDrawing.PlotConfigurations.Add("PDF", layout.ModelType);
oplot.PaperUnits = AcPlotPaperUnits.acMillimeters;
oplot.StyleSheet = "monochrome.ctb";
oplot.PlotWithPlotStyles = true;
oplot.ConfigName = "DWG To PDF.pc3";
oplot.UseStandardScale = true;
oplot.StandardScale = AcPlotScale.acScaleToFit;
oplot.PlotType = AcPlotType.acExtents;
oplot.CenterPlot = true;

Object oMediaNames = layout.GetCanonicalMediaNames();

ArrayList mediaNames = new ArrayList((string[])oMediaNames);

foreach (String sName in mediaNames)
{
if (sName.Contains(MediaName))
{
oplot.CanonicalMediaName = sName;
layout.CopyFrom(oplot);
layout.PlotRotation = AcPlotRotation.ac0degrees;
layout.RefreshPlotDeviceInfo();

ThisDrawing.SetVariable("BACKGROUNDPLOT", 0);
ThisDrawing.Plot.QuietErrorMode = true;

ThisDrawing.Plot.PlotToFile("c://temp//d1.pdf","DWG To PDF.pc3");
oplot.Delete();
oplot=null;
return;
}
}
}
catch (System.Exception es)
{
System.Windows.Forms.MessageBox.Show(es.ToString());
}
}
輸出結果:

⑨ .net列印pdf文件

方法一(web):window.print()

    print()方法是瀏覽器列印功能的一種程序調用。print方法用於列印當前窗口的內容。

列印當前頁:

function printPage(){

    window.print();

}

列印局部頁面:

        前端頁面:<iframe style="width:100%;height:100%;" id="fileId" src="文件路徑">

        </iframe>

        <input type="button" name="print" id="print" value="列印" />

        js:$("#print").click(function () {

        var iframe = document.getElementById("fileId");

        iframe.contentWindow.print();

    });

方法二:調用系統API(得保證本地裝有相關的軟體)

PrintDocument pd = new PrintDocument();

            pd.PrinterSettings.PrinterName = "Microsoft Print to PDF";

            Process p = new Process

            {

                StartInfo = new ProcessStartInfo

                {

                    CreateNoWindow = false,

                    WindowStyle = ProcessWindowStyle.Hidden,

                    UseShellExecute = true,

                    FileName = filePath,//文件路徑

                    Verb = "print",

                    Arguments = @"/p /h \" + filePath + "\"\"" + pd.PrinterSettings.PrinterName + "\""

                }

            };

            p.Start();

            p.WaitForExit();

方法三:spire列印方式(收費)下面是簡單的使用例子

 var pdf = new PdfDocument(filePath);

//設置列印機

pdf.PrintSettings.PrinterName = "Microsoft Print to PDF";

pdf.print();

方法四:安裝RawPrint

var printer = new Printer();

var file = File.Open(filePath, FileMode.Open);

byte[] array = new byte[file.Length];

file.Read(array, 0, array.Length);

printer.PrintRawStream(printerName, file, "列印機上顯示的任務名");

file.Close();

printer.PrintRawFile(printerName, fileFullPath, "列印機上顯示的任務名");

這個測試時虛擬列印機上正常,使用公司列印機時出現亂碼問題以及列印任務不停的問題

⑩ 如何用.NET將DWG文件列印為PDF

執行步驟:打開一個dwg文件,用netload載入下面代碼所在的.dll文件,再輸入命令plottest,就得到輸出結果(一個.pdf文件)。

要用到的參考:

AcDbMgd.dll;AcMgd.dll;AutoCAD 2010 Type Library;System.Windows.Forms; AutoCAD/ObjectDBX Common 18.0 Type Library.

VB.NET:

Imports System

Imports Autodesk.AutoCAD.Runtime

Imports Autodesk.AutoCAD.Interop

Imports Autodesk.AutoCAD.Interop.Common

Imports Autodesk.AutoCAD.ApplicationServices

Imports Autodesk.AutoCAD.DatabaseServices

Imports Autodesk.AutoCAD.EditorInput

<Autodesk.AutoCAD.Runtime.CommandMethod("Plottest")> _

Public Sub PlotToPDF()

Dim activeDoc As Document = Application.DocumentManager.MdiActiveDocument

Dim ThisDrawing As AcadDocument = CType(activeDoc.AcadDocument, AcadDocument)

Dim layout As AcadLayout = ThisDrawing.ActiveLayout

Dim MediaName As String = layout.CanonicalMediaName

If MediaName.Equals("") Then

activeDoc.Editor.WriteMessage("There is no media set for the active layout.")

Return

Else

activeDoc.Editor.WriteMessage(("The media for the active layout is: " + MediaName))

End If

Try

Dim oplot As AcadPlotConfiguration = ThisDrawing.PlotConfigurations.Add("PDF", layout.ModelType)

oplot.PaperUnits = AcPlotPaperUnits.acMillimeters

oplot.StyleSheet = "monochrome.ctb"

oplot.PlotWithPlotStyles = True

oplot.ConfigName = "DWG To PDF.pc3"

oplot.UseStandardScale = True

oplot.StandardScale = AcPlotScale.acScaleToFit

oplot.PlotType = AcPlotType.acExtents

oplot.CenterPlot = True

Dim oMediaNames As Object = layout.GetCanonicalMediaNames

Dim mediaNames As ArrayList = New ArrayList(CType(oMediaNames, String()))

For Each sName As String In mediaNames

If sName.Contains(MediaName) Then

oplot.CanonicalMediaName = sName

layout.CopyFrom(oplot)

layout.PlotRotation = AcPlotRotation.ac0degrees

layout.RefreshPlotDeviceInfo()

ThisDrawing.SetVariable("BACKGROUNDPLOT", 0)

ThisDrawing.Plot.QuietErrorMode = True

ThisDrawing.Plot.PlotToFile("c:/temp/d1.pdf", "DWG To PDF.pc3")

oplot.Delete()

oplot = Nothing

Return

End If

Next

Catch es As System.Exception

System.Windows.Forms.MessageBox.Show(es.ToString)

End Try

End Sub

閱讀全文

與net導出pdf文件相關的資料

熱點內容
蘋果6sp的蜂窩網路是不是更新了 瀏覽:970
儀表升級編程是什麼意思 瀏覽:190
微信歡樂紅包怎麼搶 瀏覽:772
excel在文件中發現不可讀取的內容 瀏覽:435
dv300f驅動程序 瀏覽:34
word清空最近打開文件 瀏覽:407
ps單色文件變成四色黑了 瀏覽:171
青島違章拍照app哪個好 瀏覽:922
榮成側耳傾聽微信 瀏覽:881
excel2017密碼忘記 瀏覽:400
郵箱文件怎麼保存到桌面上 瀏覽:96
一平面二平面上傳哪些數據 瀏覽:452
excel不能保存文件 瀏覽:369
蘋果手機6怎麼開4g網路 瀏覽:179
怎麼編程apk 瀏覽:506
ccs環境下的模擬器配置文件 瀏覽:123
門戶網站配色分析 瀏覽:387
如何讀取谷歌緩存文件 瀏覽:243
網路羅漢什麼意思 瀏覽:508
還助學貸款用什麼網站 瀏覽:505

友情鏈接