如何将Pdfsharp pdfDocument保存到文件路径 [英] How to save Pdfsharp pdfDocument to a file path

查看:153
本文介绍了如何将Pdfsharp pdfDocument保存到文件路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为项目使用pdfsharp.

我正在尝试将转换后的PdfDocument对象保存到指定路径的pdf文件中.

我有此方法

public static PdfDocument ConvertTiff2Pdf(string docpath)
{
var pdfDoc = Tiff2Pdf(docpath);

            return pdfDoc;

}

这将返回PdfDocument,我想将其保存到"C:\ temp \ docname.pdf"文件夹中.

如何使用csharp而不使用http响应. 因为我必须先将其存储在服务器上,然后使用.. 请帮助我.

解决方案

只需为您的PdfDocument调用"void Save(字符串路径)"方法即可.

如果您同时需要本地文件和http响应,还可以保存到MemoryStream.您可以将流复制到本地文件,并将stream.ToArray()用于http响应.

示例代码(仅适用于http响应)在这里: http://www.pdfsharp.net/wiki/Clock-sample.ashx

I am using the pdfsharp for my project..

I am trying to save the converted PdfDocument object to a pdf file in a specified path..

i do have this method

public static PdfDocument ConvertTiff2Pdf(string docpath)
{
var pdfDoc = Tiff2Pdf(docpath);

            return pdfDoc;

}

this will return PdfDocument and I want to save it to a "C:\temp\docname.pdf" folder..

how can do it with csharp without using the http response.. because i have to first store it on the server then use.. please help me..

解决方案

Just call the "void Save(string path)" method for your PdfDocument.

You can also save to a MemoryStream if you need both local file and http response. You can copy the stream to a local file and use stream.ToArray() for the http response.

Sample code (http response only) is here: http://www.pdfsharp.net/wiki/Clock-sample.ashx

这篇关于如何将Pdfsharp pdfDocument保存到文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆