【问题标题】:issue in exporting image to pdf将图像导出为 pdf 的问题
【发布时间】:2014-09-19 05:50:10
【问题描述】:

m 有一个网格:companysnapshot.. 该网格被导出到磁盘,然后再次从磁盘中取出并导出到 pdf。 下面的代码工作正常,图像导出完成。 bt 问题是..

-->从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));

    }

【问题讨论】:

    标签: c# wpf pdf telerik


    【解决方案1】:

    问题已解决.. 通过从 Telerik 导出切换到 itextsharp 以进行 pdf 导出。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-08
      • 1970-01-01
      相关资源
      最近更新 更多