Exporter des images au format PDF
-
28-10-2019 - |
Question
J'ai un projet qui doit exporter des images au format PDF.Les images et le texte doivent être exportés au format pdf.y a-t-il un moyen de faire cela en utilisant silverPDF.dll et PdfReader?
Code ici.
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());
}
}
Où dans ce code puis-je insérer une image qui l'insère en pdf?Y a-t-il un moyen?Merci pour toutes les réponses.
La solution
Doit-il être SilverPDF?Comme Iv'e a déjà fait quelque chose de similaire chez mon ancien employeur en utilisant la bibliothèque iTextSharp (sinon j'aurais collé un exemple de code)
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow