如何在C#中的Pdfsharp中从我的资源文件夹添加图像到Pdf文件 [英] How Do I Add A Image To Pdf File From My Resource Folder In The Pdfsharp At C#
本文介绍了如何在C#中的Pdfsharp中从我的资源文件夹添加图像到Pdf文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以从我的资源文件夹中将图像添加到pdf。这意味着我已将图像添加到解决方案资源管理器。我正在使用 pdfsharp dll file。
Ho do i add a image to pdf from my resource folder.That means i have added a image to solution explorer.I'm using pdfsharp dll file.
推荐答案
Goolgle说:
http://www.billrowell.com/2010/12/13/adding-an-image -to-a-pdf-document-using-c-and-pdfsharp / [ ^ ]
Goolgle says:
http://www.billrowell.com/2010/12/13/adding-an-image-to-a-pdf-document-using-c-and-pdfsharp/[^]
void AddLogo(XGraphics gfx, PdfPage page, string imagePath, int xPosition, int yPosition)
{
if (!File.Exists(imagePath))
{
throw new FileNotFoundException(String.Format("Could not find image {0}.", imagePath));
}
XImage xImage = XImage.FromFile(imagePath);
gfx.DrawImage(xImage, xPosition, yPosition, xImage.PixelWidth, xImage.PixelWidth);
}
try
{
PdfDocument doc = new PdfDocument();
PdfPage page = doc.AddPage();
XGraphics gfx = XGraphics.FromPdfPage(page);
AddLogo(gfx, invoice, "pathtoimage", 0, 0);
}
catch (Exception)
{
// Handle exception
}
这篇关于如何在C#中的Pdfsharp中从我的资源文件夹添加图像到Pdf文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文