在 WPF RichTextBox 中插入图像

发布于 2024-07-13 14:52:43 字数 1875 浏览 9 评论 0原文

您好,我使用以下代码插入文本和图像,但我想将图像插入“文本后面”作为 Image>Adjust with Text property in MSWord

{
            int numeroInforme = Convert.ToInt32(txtNroInforme.Text);
            List<informeMedico> lstInformes = getInformeMedico(numeroInforme);


            FlowDocument mcFlowDoc = new FlowDocument();

            Paragraph para = new Paragraph();

            foreach (informeMedico info in lstInformes)
            {
                var signatureOne = BinaryImageConverter(info.firma1);
                var signatureTwo = BinaryImageConverter(info.firma2);

                para.Inlines.Add(new Run("RM Nro:" + "\t" + info.numeroinforme.ToString()));
                para.Inlines.Add(new Run("\n\n"));

                para.Inlines.Add(new Run("Sr. Dr.  :" + "\t" + info.medicoCompleto.ToString()));
                para.Inlines.Add(new Run("\n\n"));

                para.Inlines.Add(new Run("NOMBRE :" + "\t" + info.pacienteCompleto.ToString()));
                para.Inlines.Add(new Run("\n\n"));

                para.Inlines.Add(new Run("EXAMEN :" + "\t" + info.estudioExamenNombre.ToString()));
                para.Inlines.Add(new Run("\n\n"));

                para.Inlines.Add(new Run("FECHA :" + "\t" + info.fechainforme.ToString()));
                para.Inlines.Add(new Run("\n\n"));

                para.Inlines.Add(new Run(info.tecnica));
                para.Inlines.Add(new Run("\n\n"));

                para.Inlines.Add(new Run(info.hallazgo));
                para.Inlines.Add(new Run("\n\n"));

                para.Inlines.Add(new Run(info.conclusion));
                para.Inlines.Add(new Run("\n\n"));

                para.Inlines.Add(signatureOne);
                para.Inlines.Add(signatureTwo);
            }

            mcFlowDoc.Blocks.Add(para);

            mainRTB.Document = mcFlowDoc;


        }

提前致谢

Hi there im using the following code for insert text and images, but I want to insert the image "behind text" as Image>Adjust with Text property in MSWord

{
            int numeroInforme = Convert.ToInt32(txtNroInforme.Text);
            List<informeMedico> lstInformes = getInformeMedico(numeroInforme);


            FlowDocument mcFlowDoc = new FlowDocument();

            Paragraph para = new Paragraph();

            foreach (informeMedico info in lstInformes)
            {
                var signatureOne = BinaryImageConverter(info.firma1);
                var signatureTwo = BinaryImageConverter(info.firma2);

                para.Inlines.Add(new Run("RM Nro:" + "\t" + info.numeroinforme.ToString()));
                para.Inlines.Add(new Run("\n\n"));

                para.Inlines.Add(new Run("Sr. Dr.  :" + "\t" + info.medicoCompleto.ToString()));
                para.Inlines.Add(new Run("\n\n"));

                para.Inlines.Add(new Run("NOMBRE :" + "\t" + info.pacienteCompleto.ToString()));
                para.Inlines.Add(new Run("\n\n"));

                para.Inlines.Add(new Run("EXAMEN :" + "\t" + info.estudioExamenNombre.ToString()));
                para.Inlines.Add(new Run("\n\n"));

                para.Inlines.Add(new Run("FECHA :" + "\t" + info.fechainforme.ToString()));
                para.Inlines.Add(new Run("\n\n"));

                para.Inlines.Add(new Run(info.tecnica));
                para.Inlines.Add(new Run("\n\n"));

                para.Inlines.Add(new Run(info.hallazgo));
                para.Inlines.Add(new Run("\n\n"));

                para.Inlines.Add(new Run(info.conclusion));
                para.Inlines.Add(new Run("\n\n"));

                para.Inlines.Add(signatureOne);
                para.Inlines.Add(signatureTwo);
            }

            mcFlowDoc.Blocks.Add(para);

            mainRTB.Document = mcFlowDoc;


        }

Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

毁我热情 2024-07-20 14:52:44

您可以设置背景 段落,或个人 < a href="http://msdn.microsoft.com/en-us/library/system.windows.documents.run.aspx" rel="nofollow noreferrer">运行,到 ImageBrush

<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Grid.Resources>
        <FlowDocument x:Key="document">
            <Paragraph>
                <Paragraph.Background>
                    <ImageBrush ImageSource="http://sipi.usc.edu/database/misc/4.1.01.tiff" Stretch="UniformToFill"/>
                </Paragraph.Background>
                <Run Foreground="White" Text="this is some text"/>
                <LineBreak/>
                <Run Foreground="White" Text="and some more text"/>
            </Paragraph>
        </FlowDocument>
    </Grid.Resources>
    <FlowDocumentReader Document="{StaticResource document}"/>
</Grid>

You can set the Background of the Paragraph, or of the individual Runs, to an ImageBrush:

<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Grid.Resources>
        <FlowDocument x:Key="document">
            <Paragraph>
                <Paragraph.Background>
                    <ImageBrush ImageSource="http://sipi.usc.edu/database/misc/4.1.01.tiff" Stretch="UniformToFill"/>
                </Paragraph.Background>
                <Run Foreground="White" Text="this is some text"/>
                <LineBreak/>
                <Run Foreground="White" Text="and some more text"/>
            </Paragraph>
        </FlowDocument>
    </Grid.Resources>
    <FlowDocumentReader Document="{StaticResource document}"/>
</Grid>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文