Pregunta

Tengo un proyecto que tiene que exportar imágenes a PDF. Se necesita exportar imágenes y texto para exportarse a PDF. ¿Hay alguna forma de hacer esto usando Silverpdf.dll y PdFeader?

Código aquí.

 private void btnOutlook_Click(object sender, System.Windows.RoutedEventArgs e)
    {
        XBrush xbrush;
        SaveFileDialog savePDF = new SaveFileDialog();
        savePDF.Filter = "PDF file format | *.pdf";
        if (savePDF.ShowDialog() == true)
        {
            PdfDocument document = new PdfDocument();
            PdfPage page = document.AddPage();
            XGraphics gfx = XGraphics.FromPdfPage(page);
            XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always);

            XFont font = new XFont("Huxtable", 20, XFontStyle.Bold, options);

            for (int x = 0; x < 10; x++)
            {
                if (x % 2 == 0)
                {
                    xbrush = XBrushes.Red;
                }
                else
                    xbrush = XBrushes.Black;
                gfx.DrawString(string.Format("{0}", stringArray[x]), font, xbrush, new XRect(0, (x * 20), page.Width, page.Height), XStringFormats.TopLeft);
            }

            document.Save(savePDF.OpenFile());
        }

    }

¿En qué parte de este código puedo insertar una imagen que la inserta en PDF? ¿Hay alguna manera? Gracias por todas las respuestas.

¿Fue útil?

Solución

¿Necesita ser SilverPDF? Como hice algo similar antes en mi empleador anterior usando la biblioteca ItextSharp (de lo contrario, habría pegado el código de muestra)

itextsharp-working-with-image

Enlace de descarga

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top