PdfDocument _pdfDoc = new PdfDocument();
_pdfDoc.AddPage(new PdfPage());
XGraphics _g = XGraphics.FromPdfPage(_pdfDoc.Pages[0]);
Bitmap _b = new Bitmap(@"D:\Download\***.jpg");
using (MemoryStream _stream = new MemoryStream())
{
_b.Save(_stream, ImageFormat.Jpeg);
XImage _img = XImage.FromStream(_stream);
_g.DrawImage(_img, new XPoint(0, 0));
}
var request = (FtpWebRequest)WebRequest.Create("ftp://127.0.0.1/test.pdf");
request.Credentials = new NetworkCredential("FTP账号", "FTP密码");
request.Method = WebRequestMethods.Ftp.UploadFile;
using (var ftpStream = request.GetRequestStream())
{
using (MemoryStream _pdfStream = new MemoryStream())
{
_pdfDoc.Save(_pdfStream);
_pdfStream.CopyTo(ftpStream);
}
}
using (var response = request.GetResponse())
{
}