C# 将图像导出为pdf时出现的问题

C# 将图像导出为pdf时出现的问题,c#,wpf,pdf,telerik,C#,Wpf,Pdf,Telerik,我有一个网格:companysnapshot。。该网格被导出到磁盘,然后再次从磁盘获取并导出到pdf。 下面的代码工作正常,并和图像一起导出。英国电信的问题是 -->从UI保存的图像为黑色背景。当其导出内容在白色背景中更改时(可能是转换为png) -->我想对齐pdf页面中图像的坐标 有没有办法增加图片或pdf页面的宽度。 我是一个新手…如果有人给我写一点代码会很有帮助的 private void PrepareDocument(RadDocument document) {

我有一个网格:companysnapshot。。该网格被导出到磁盘,然后再次从磁盘获取并导出到pdf。 下面的代码工作正常,并和图像一起导出。英国电信的问题是

-->从UI保存的图像为黑色背景。当其导出内容在白色背景中更改时(可能是转换为png)

-->我想对齐pdf页面中图像的坐标

有没有办法增加图片或pdf页面的宽度。 我是一个新手…如果有人给我写一点代码会很有帮助的

 private void PrepareDocument(RadDocument document)
    {
        document.SectionDefaultPageOrientation = PageOrientation.Landscape;
        document.LayoutMode = DocumentLayoutMode.Paged;
        document.Measure(RadDocument.MAX_DOCUMENT_SIZE);
        document.Arrange(new RectangleF(PointF.Empty, document.DesiredSize));
    }
图表文件部分:

private void CreateChartDocumentPart(RadDocument document, Grid whGrid, Grid companysnapshot, Grid chartgridimage)
    {
        Telerik.Windows.Documents.Model.Section section = new Telerik.Windows.Documents.Model.Section();

        Telerik.Windows.Documents.Model.Paragraph paragraph = new Telerik.Windows.Documents.Model.Paragraph();

        Telerik.Windows.Documents.Model.Span span1;

        using (MemoryStream ms = new MemoryStream())
        {
            companysnapshot.Measure(new System.Windows.Size(double.PositiveInfinity, double.PositiveInfinity));
            int companywidth = (int)Math.Round(companysnapshot.ActualWidth);
            int companyheight = (int)Math.Round(companysnapshot.ActualHeight);
            companywidth = companywidth == 0 ? 1 : companywidth;
            companyheight = companyheight == 0 ? 1 : companyheight;
            RenderTargetBitmap rtbmp = new RenderTargetBitmap(companywidth, companyheight, 96d, 96d, PixelFormats.Default);
            rtbmp.Render(companysnapshot);
            BmpBitmapEncoder encoder = new BmpBitmapEncoder();
            encoder.Frames.Add(BitmapFrame.Create(rtbmp));
            FileStream fs1 = File.Create(@"C:\Users\Admin\Desktop\Chart12xx.bmp");
            encoder.Save(fs1);
            fs1.Close();
         //   this.ExportPNGToImage(chart, ms);

            paragraph.LeftIndent = 0;
            paragraph.RightIndent = 0.0;
            FileStream ss = File.Open(@"C:\Users\Admin\Desktop\Chart12xx.bmp", FileMode.Open);
            ImageInline image = new ImageInline(ss, new Size(companywidth, companyheight), "bmp");
            paragraph.FlowDirection = FlowDirection.LeftToRight;
            paragraph.Inlines.Add(image);
            ss.Close();
            //Span spacespan = new Span("  ");
            //paragraph.Inlines.Add(spacespan);
        }

        try
        {
            section1.Blocks.Add(paragraph);
            document.Sections.Add(section1);
        }
        catch (Exception)
        {
        }

      //  paragraph.Inlines.Add(new Span(FormattingSymbolLayoutBox.LINE_BREAK));

    }

问题解决了。。从telerik导出切换到itextsharp进行pdf导出