导航:首页 > 版本升级 > 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文件相关的资料

热点内容
魔百和网络机顶盒怎么连接电视 浏览:611
国产显示器icc配置文件 浏览:52
java编程常见的语法糖有哪些 浏览:41
jspmysql选课源码 浏览:877
ipadmini2下载app等待 浏览:399
creo工程图配置文件 浏览:699
编程和钢琴哪个贵 浏览:841
移动进销存app哪个好 浏览:600
编程制作游戏什么原理 浏览:97
linux如何查看是否有共享文件夹 浏览:264
u盘拷贝文件以后为空 浏览:917
快云主机数据库连接方法 浏览:756
javagsp定位 浏览:384
jsp页面表格导出excel 浏览:976
imagetest教程 浏览:244
怎样将一个cad文件包图纸兼容 浏览:898
论文有什么好的网站 浏览:581
jdk7javadoc 浏览:687
编程小游戏是如何设计的 浏览:913
网络安全风险案例 浏览:46

友情链接