C#: создание PDF-формы (AcroForm) с помощью PDFsharpC#

Место общения программистов C#
Ответить Пред. темаСлед. тема
Anonymous
 C#: создание PDF-формы (AcroForm) с помощью PDFsharp

Сообщение Anonymous »


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
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение
  • PDFBox Acroform не может найти ранее добавленные поля на подписанном PDF ITEXT PDF
    Anonymous » » в форуме JAVA
    0 Ответы
    8 Просмотры
    Последнее сообщение Anonymous
  • Как получить формы от PDF с помощью pdfsharp
    Anonymous » » в форуме C#
    0 Ответы
    19 Просмотры
    Последнее сообщение Anonymous
  • Как получить формы от PDF с помощью pdfsharp
    Anonymous » » в форуме C#
    0 Ответы
    9 Просмотры
    Последнее сообщение Anonymous
  • Как получить формы от PDF с помощью pdfsharp
    Anonymous » » в форуме C#
    0 Ответы
    18 Просмотры
    Последнее сообщение Anonymous
  • Я не могу распечатать PDF-файл с помощью PdfSharp
    Anonymous » » в форуме C#
    0 Ответы
    13 Просмотры
    Последнее сообщение Anonymous

Вернуться в «C#»