PdfSharpCore 是收费的吗
时间: 2024-04-18 11:31:18 浏览: 13
PdfSharpCore是一个开源项目,根据其GitHub页面上的许可证信息,它使用MIT许可证发布。这意味着您可以免费使用和修改PdfSharpCore库,无需支付任何费用。您可以在其GitHub存储库中找到源代码,并根据需要进行定制和集成。
然而,请注意,如果您使用PdfSharpCore来处理或生成包含受版权保护的内容的PDF文件(例如商业用途),您可能需要遵循相关的版权和许可要求,并与相关的版权持有人联系。此外,如果您使用PdfSharpCore的其他依赖项,例如字体或图像处理库,这些库可能具有不同的许可证要求。
因此,在使用PdfSharpCore或任何其他开源项目时,请务必查阅其许可证信息,并确保您的使用符合相关的法律和许可要求。
相关问题
PdfSharpCore 指定打印机打印Pdf文件
您可以使用PdfSharpCore库来打印Pdf文件,但是该库本身并不直接支持指定打印机。不过,您可以通过使用System.Drawing.Printing命名空间中的PrintDocument类来实现这一功能。以下是一个示例代码:
```csharp
using System;
using System.Drawing;
using System.Drawing.Printing;
using PdfSharpCore.Pdf.IO;
class Program
{
static void Main(string[] args)
{
string pdfFilePath = "path/to/your/pdf/file.pdf";
string printerName = "Your Printer Name";
PrintDocument printDoc = new PrintDocument();
printDoc.PrinterSettings.PrinterName = printerName;
printDoc.PrintPage += (sender, e) =>
{
PdfDocument pdfDoc = PdfReader.Open(pdfFilePath, PdfDocumentOpenMode.Import);
PdfPage page = pdfDoc.Pages[e.PageNumber - 1];
XGraphics gfx = XGraphics.FromGraphics(e.Graphics, e.PageBounds);
XRect box = new XRect(0, 0, page.Width, page.Height);
gfx.DrawImage(XImage.FromStream(page.Stream), box);
};
printDoc.Print();
}
}
```
在上面的代码中,您需要将`pdfFilePath`替换为您要打印的Pdf文件的路径,并将`printerName`替换为您要使用的打印机的名称。然后,PrintDocument类的PrintPage事件处理程序会在每个打印页面时加载Pdf页面,并使用XGraphics类绘制Pdf页面的内容。
请注意,PdfSharpCore库本身并不提供打印功能,而是使用System.Drawing.Printing命名空间中的PrintDocument类来实现打印。因此,您需要确保已正确安装和配置所需的打印机驱动程序。
.NET6中 PdfSharpCore没有ConvertToImage()方法吗?
在最新的`PdfSharpCore`库中,没有`ConvertToImage()`方法。但是,您可以使用`PdfRenderer`类将PDF页面渲染为图像。以下是将PDF页面转换为图像的代码示例:
```csharp
using System.Drawing;
using PdfSharpCore.Drawing;
using PdfSharpCore.Pdf;
using PdfSharpCore.Pdf.IO;
public static void ConvertPdfToImage(string pdfFilePath, string imageFilePath)
{
using (var document = PdfReader.Open(pdfFilePath, PdfDocumentOpenMode.ReadOnly))
{
var pdfPage = document.Pages[0];
var pdfRenderer = new PdfRenderer();
pdfRenderer.Document = document;
pdfRenderer.Page = pdfPage;
pdfRenderer.Render(new XGraphics(), 300, 300);
var image = pdfRenderer.GetBitmap();
if (image != null)
{
image.Save(imageFilePath, System.Drawing.Imaging.ImageFormat.Jpeg);
}
}
}
```
在上述示例中,我们使用`PdfRenderer`类将PDF页面渲染为图像。然后,将图像保存为JPEG格式的图像文件。您可以根据需要更改图像的格式。此外,您还可以使用循环将PDF中的所有页面转换为图像。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)