使用 pdfsharp.net 库——我试图加载一个大背景 jpg 然后在它上面以 90 度角写一些文本。然后另存为pdf
为什么我下面的 c# 代码不起作用。
using System.Diagnostics;
using System.IO;
using System.Drawing;
using PdfSharp;
using PdfSharp.Drawing;
using PdfSharp.Pdf;
using PdfSharp.Pdf.IO;
using System.Drawing.Imaging;
namespace test
{
class Program
{
static void Main(string[] args)
{
PdfDocument myDoc = new PdfDocument();
PdfPage myPage = myDoc.AddPage();
myPage.Size = PdfSharp.PageSize.A4;
XGraphics g = XGraphics.FromPdfPage(myPage);
XImage image = XImage.FromFile(@"myjpg.jpg");
g.DrawImage(image, 0, 0, myPage.Width, myPage.Height);
XFont font = new XFont("Verdana", 20, XFontStyle.BoldItalic);
g.RotateAtTransform(90,new XPoint(0,0));
g.DrawString("test text!", font, XBrushes.Black, new XRect(0, 0, 200, 50), XStringFormats.Center);
myDoc.Save(@"test.pdf");
Process.Start(@"test.pdf");
}
}
}