C#: создание PDF-формы (AcroForm) с помощью PDFsharp ⇐ C#
C#: создание PDF-формы (AcroForm) с помощью PDFsharp
How does one add a PDF Form element to a PDFsharp PdfPage object?
I understand that AcroForm is the best format for form-fillable PDF elements, but the PDFsharp library doesn't seem to allow you to create instances of the AcroForm objects.
I have been able to use PDFsharp to generate simple documents, as here:
static void Main(string[] args) { PdfDocument document = new PdfDocument(); document.Info.Title = "Created with PDFsharp"; // Create an empty page PdfPage page = document.AddPage(); // Draw Text XGraphics gfx = XGraphics.FromPdfPage(page); XFont font = new XFont("Verdana", 20, XFontStyle.BoldItalic); gfx.DrawString("Hello, World!", font, XBrushes.Black, new XRect(0, 0, page.Width, page.Height), XStringFormats.Center); // Save document const string filename = "HelloWorld.pdf"; document.Save(filename); } But I cannot work out how to add a fillable form element. I gather it would likely use the page.Elements.Add(string key, PdfItem item) method, but how do you make an AcroForm PdfItem? (As classes like PdfTextField do not seem to have a public constructor)
The PDFsharp forums and documentation have not helped with this, and the closest answer I found on Stack Overflow was this one, which is answering with the wrong library.
So, in short: How would I convert the "Hello World" text above into a text field?
Is it possible to do this in PDFsharp, or should I be using a different C# PDF library? (I would very much like to stick with free - and preferably open-source - libraries)
Источник: https://stackoverflow.com/questions/544 ... g-pdfsharp
How does one add a PDF Form element to a PDFsharp PdfPage object?
I understand that AcroForm is the best format for form-fillable PDF elements, but the PDFsharp library doesn't seem to allow you to create instances of the AcroForm objects.
I have been able to use PDFsharp to generate simple documents, as here:
static void Main(string[] args) { PdfDocument document = new PdfDocument(); document.Info.Title = "Created with PDFsharp"; // Create an empty page PdfPage page = document.AddPage(); // Draw Text XGraphics gfx = XGraphics.FromPdfPage(page); XFont font = new XFont("Verdana", 20, XFontStyle.BoldItalic); gfx.DrawString("Hello, World!", font, XBrushes.Black, new XRect(0, 0, page.Width, page.Height), XStringFormats.Center); // Save document const string filename = "HelloWorld.pdf"; document.Save(filename); } But I cannot work out how to add a fillable form element. I gather it would likely use the page.Elements.Add(string key, PdfItem item) method, but how do you make an AcroForm PdfItem? (As classes like PdfTextField do not seem to have a public constructor)
The PDFsharp forums and documentation have not helped with this, and the closest answer I found on Stack Overflow was this one, which is answering with the wrong library.
So, in short: How would I convert the "Hello World" text above into a text field?
Is it possible to do this in PDFsharp, or should I be using a different C# PDF library? (I would very much like to stick with free - and preferably open-source - libraries)
Источник: https://stackoverflow.com/questions/544 ... g-pdfsharp
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
PDFBox Acroform не может найти ранее добавленные поля на подписанном PDF ITEXT PDF
Anonymous » » в форуме JAVA - 0 Ответы
- 8 Просмотры
-
Последнее сообщение Anonymous
-