Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/332.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将图像导出为PDF_C#_Pdf_Silverlight 5.0 - Fatal编程技术网

C# 将图像导出为PDF

C# 将图像导出为PDF,c#,pdf,silverlight-5.0,C#,Pdf,Silverlight 5.0,我有一个项目,必须将图像导出到PDF。需要将图像和文本导出为pdf格式。有没有办法通过使用silverPDF.dll和PdfReader来做到这一点 代码在这里 private void btnOutlook_Click(object sender, System.Windows.RoutedEventArgs e) { XBrush xbrush; SaveFileDialog savePDF = new SaveFileDialog();

我有一个项目,必须将图像导出到PDF。需要将图像和文本导出为pdf格式。有没有办法通过使用silverPDF.dll和PdfReader来做到这一点

代码在这里

 private void btnOutlook_Click(object sender, System.Windows.RoutedEventArgs e)
    {
        XBrush xbrush;
        SaveFileDialog savePDF = new SaveFileDialog();
        savePDF.Filter = "PDF file format | *.pdf";
        if (savePDF.ShowDialog() == true)
        {
            PdfDocument document = new PdfDocument();
            PdfPage page = document.AddPage();
            XGraphics gfx = XGraphics.FromPdfPage(page);
            XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always);

            XFont font = new XFont("Huxtable", 20, XFontStyle.Bold, options);

            for (int x = 0; x < 10; x++)
            {
                if (x % 2 == 0)
                {
                    xbrush = XBrushes.Red;
                }
                else
                    xbrush = XBrushes.Black;
                gfx.DrawString(string.Format("{0}", stringArray[x]), font, xbrush, new XRect(0, (x * 20), page.Width, page.Height), XStringFormats.TopLeft);
            }

            document.Save(savePDF.OpenFile());
        }

    }
private void btnOutlook\u单击(对象发送方,System.Windows.RoutedEventArgs e)
{
XBrush XBrush;
SaveFileDialog savePDF=新建SaveFileDialog();
savePDF.Filter=“PDF文件格式|*.PDF”;
if(savePDF.ShowDialog()==true)
{
PdfDocument document=新PdfDocument();
PdfPage page=document.AddPage();
XGraphics gfx=XGraphics.FromPdfPage(第页);
XPdfFontOptions options=新的XPdfFontOptions(PdfFontEncoding.Unicode,PdfFontEmbedding.Always);
XFont=newxfont(“Huxtable”,20,XFontStyle.Bold,options);
对于(int x=0;x<10;x++)
{
如果(x%2==0)
{
xbrush=xbrush.Red;
}
其他的
xbrush=xbrush.Black;
DrawString(string.Format(“{0}”,stringArray[x]),字体,xbrush,新的XRect(0,(x*20),page.Width,page.Height),XStringFormats.TopLeft);
}
document.Save(savePDF.OpenFile());
}
}

在此代码中,我可以在何处插入将其插入pdf的图像?有办法吗?感谢所有回复。

是否需要使用SilverPDF?正如我在以前的雇主使用iTextSharp库做过类似的事情一样(否则我会粘贴示例代码)


我对SilverPDF一无所知,但网上有几个教程使用了其他实用程序类。我不能使用它们,它们不是针对Silverlight运行时构建的。这对我来说是个大问题。我现在正在使用它们。我只是在.Web应用程序中创建了这个项目,然后将它以字节的形式传递给Silverlight应用程序进行保存。谢谢你的帮助!