0

だから私は私の基本的なiTextSharpコードを持っています

 private void button1_Click(object sender, EventArgs e)
    {
        Document doc = new Document(iTextSharp.text.PageSize.LETTER, 10, 10, 42, 35);
        PdfWriter wri = PdfWriter.GetInstance(doc, new FileStream("Test.pdf", FileMode.Create));
        doc.Open();
        doc.Add();
        doc.Close();

    }

今、私は使用することができます

e.Graphics.DrawString(label1.Text, label1.Font, Brushes.Black, 13, 13);

それと??

4

1 に答える 1

0

あなたを使用PdfDocumentすると、このようなことができます..

  PdfDocument document = new PdfDocument();
  document.Info.Title = "Sample pdf using PDFsharp";

  PdfPage page = document.AddPage();

  XGraphics gfx = XGraphics.FromPdfPage(page);

  XFont font = new XFont("Verdana", 20, XFontStyle.BoldItalic); //set your label1.Font here

  gfx.DrawString("Sample using PdfSharp!", font, XBrushes.Black, //you can use your label1.Text here
    new XRect(0, 0, page.Width, page.Height),
    XStringFormats.Center);

  const string filename = "sample.pdf";
  document.Save(filename);

  Process.Start(filename);

ここでXGraphics.DrawString()は のようGraphics.DrawString()に動作し.NETます。

于 2013-07-18T20:03:15.200 に答える