【问题标题】:Printing Text and Image in 1 PDF File在 1 个 PDF 文件中打印文本和图像
【发布时间】:2021-02-26 09:44:10
【问题描述】:

我在以 PDF 格式打印数据和图像时遇到问题。我使用下面的代码,它分别打印图像和数据。但我希望它们在一个 PDF 中,我该怎么做?

PrintDialog export = new PrintDialog();
string data = "data";
System.Windows.Documents.FlowDocument flowDoc = new System.Windows.Documents.FlowDocument(new System.Windows.Documents.Paragraph(new System.Windows.Documents.Run(data)));
System.Windows.Documents.IDocumentPaginatorSource source = flowDoc;
var result = export.ShowDialog();
if(result == true)
{
    export.PrintVisual(souradnySystem, "Visual");
    export.PrintDocument(source.DocumentPaginator, "Text");
}

【问题讨论】:

    标签: c# wpf pdf printing


    【解决方案1】:

    在继续打印之前将图像添加到 FlowDocument。 假设“souradnySystem”是您的图像(System.Windows.Controls.Image),它将如下所示:

    string data = "data";
    FlowDocument flowDoc = new FlowDocument(new Paragraph(new Run(data)));
    flowDoc.Blocks.Add(new BlockUIContainer(souradnySystem));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-03-14
      • 1970-01-01
      • 2014-04-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-25
      相关资源
      最近更新 更多