简体   繁体   English

将图像导出为pdf时出现问题

[英]issue in exporting image to pdf

m having a grid: companysnapshot.. that grid is exported to disk then its again taken from disk and exported to the pdf. m有一个网格:companysnapshot ..该网格被导出到磁盘,然后再次从磁盘获取并导出到pdf。 Below code is working fine and export with the image is done. 下面的代码工作正常,并且已完成图像导出。 bt issues is that.. 债务问题是..

-->image is saved from UI is black background..when its exported is changing in white background( may be its getting converted to png) ->从UI保存的图像是黑色背景..当导出的图像在白色背景中更改时(可能是转换为png)

--> i want to align the coordinates of the image in the pdf page ->我想在pdf页面中对齐图像的坐标

is there any way to either increase the width of the image or pdf page. 有没有办法增加图像或pdf页面的宽度。 ma newbie to this ...it would be helpful if someone code me out for this a little. 一位新手...如果有人对此进行编码,这将很有帮助。

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

chart document part: 图表文档部分:

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导出,解决了问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM