DevExpress年中超值优惠券大放送

DevExpress控件使用交流,DevExpress中国社区Dev联系电话 联系电话:023-68661681

DevExpress Document Server在线示例:如何获取复选框的选中值

来源:   发布时间:2018-11-05   浏览:487次

此示例显示如何获取“Female”复选框的已检查外观名称,并选中具有此值的复选框。 要完成此任务,请使用PdfDocumentProcessor实例和字段名称调用GetCheckboxCheckedValue方法。

PdfDocumentProcessor Class

句法

public class PdfDocumentProcessor : PdfDisposableObject
Public Class PdfDocumentProcessor Inherits PdfDisposableObject

备注

扩展示例
此示例显示如何使用PDF文档创建API以编程方式创建包含图形的文档。 要使用Document Creation API生成文档:
  • 通过调用CreateEmptyDocument重载方法之一(例如,使用文件路径)创建一个没有页面的空文档。
  • 创建由PdfGraphics类的实例表示的PDF图形,调用CreateGraphics方法。 要访问PdfGraphics,您需要引用DevExpress.Pdf.Drawing程序集。
  • 通过调用相应的Draw方法绘制图形内容(例如,图像,字符串,线条,多边形)。
  • 通过调用RenderNewPage方法渲染包含已创建图形的页面。
Imports DevExpress.Pdf
Imports System
Imports System.Drawing

Namespace DocumentCreationAPI
    Friend Class Program

        Shared Sub Main(ByVal args() As String)

            Using processor As New PdfDocumentProcessor()

                ' Create an empty document.
                processor.CreateEmptyDocument("..\..\Result.pdf")

                ' Create and draw PDF graphics.
                Using graph As PdfGraphics = processor.CreateGraphics()
                    DrawGraphics(graph)

                    ' Render a page with graphics.
                    processor.RenderNewPage(PdfPaperSize.Letter, graph)
                End Using
            End Using
        End Sub

        Private Shared Sub DrawGraphics(ByVal graph As PdfGraphics)

            ' Draw text lines on the page. 
            Dim black As SolidBrush = CType(Brushes.Black, SolidBrush)
            Using font1 As New Font("Times New Roman", 32, FontStyle.Bold)
                graph.DrawString("PDF Document Processor", font1, black, 180, 150)
            End Using
            Using font2 As New Font("Arial", 20)
                graph.DrawString("Display, Print and Export PDF Documents", font2, black, 168, 230)
            End Using
            Using font3 As New Font("Arial", 10)
                graph.DrawString("The PDF Document Processor is a non-visual component " & "that provides the application programming interface of the PDF Viewer.", font3, black, 16, 300)
            End Using
        End Sub
    End Class
End Namespace
using DevExpress.Pdf;
using System;
using System.Drawing;

namespace DocumentCreationAPI {
    class Program {

        static void Main(string[] args) {

            using (PdfDocumentProcessor processor = new PdfDocumentProcessor()) {

                // Create an empty document. 
                processor.CreateEmptyDocument("..\\..\\Result.pdf");

                // Create and draw PDF graphics. 
                using (PdfGraphics graph = processor.CreateGraphics()) {
                    DrawGraphics(graph);

                    // Render a page with graphics. 
                    processor.RenderNewPage(PdfPaperSize.Letter, graph);
                }
            }
        }

        static void DrawGraphics(PdfGraphics graph) {

            // Draw text lines on the page.  
            SolidBrush black = (SolidBrush)Brushes.Black;
            using (Font font1 = new Font("Times New Roman", 32, FontStyle.Bold)) {
                graph.DrawString("PDF Document Processor", font1, black, 180, 150);
            }
            using (Font font2 = new Font("Arial", 20)) {
                graph.DrawString("Display, Print and Export PDF Documents", font2, black, 168, 230);
            }
            using (Font font3 = new Font("Arial", 10)) {
                graph.DrawString("The PDF Document Processor is a non-visual component " +
                                  "that provides the application programming interface of the PDF Viewer.", font3, black, 16, 300);
            }
        }
    }
}
要获取交互式表单数据,请调用PdfDocumentProcessor.GetFormData方法。 要选中“Female”复选框,请使用PdfFormData.Value属性。

PdfDocumentProcessor.GetFormData Method

句法

public PdfFormData GetFormData()
Public Function GetFormData() As PdfFormData

备注

扩展示例
该示例显示如何使用字段名称填充现有的交互式表单。 要获取交互式表单数据,请调用GetFormData方法。 然后,使用PdfFormData.Value属性为表单字段指定值。
' Load a document with an interactive form.
Using documentProcessor As New PdfDocumentProcessor()
    documentProcessor.LoadDocument(filePath & fileName & ".pdf")

    ' Obtain interactive form data from a document.
    Dim formData As PdfFormData = documentProcessor.GetFormData()

    ' Specify the value for FirstName and LastName text boxes.
    formData("FirstName").Value = "Janet" 
    formData("LastName").Value = "Leverling" 

    ' Specify the value for the Gender radio group.
    formData("Gender").Value = "Female" 

    ' Specify the check box checked appearance name.
    formData("Check").Value = "Yes" 

    ' Specify values for the Category list box.
    formData("Category").Value = New String() { "Entertainment", "Meals", "Morale" }

    ' Obtain data from the Address form field and specify values for Address child form fields.
    Dim address As PdfFormData = formData("Address")

    ' Specify the value for the Country combo box. 
    address("Country").Value = "United States" 

    ' Specify the value for City and Address text boxes. 
    address("City").Value = "California" 
    address("Address").Value = "20 Maple Avenue" 

    ' Apply data to the interactive form. 
    documentProcessor.ApplyFormData(formData)

    ' Save the modified document.
    documentProcessor.SaveDocument(filePath & fileName & "_new.pdf")

    btnFillFormData.Enabled = False
    btnLoadFilledPDF.Enabled = True
End Using
// Load a document with an interactive form. 
using (PdfDocumentProcessor documentProcessor = new PdfDocumentProcessor()) {
    documentProcessor.LoadDocument(filePath + fileName + ".pdf");

    // Obtain interactive form data from a document. 
    PdfFormData formData = documentProcessor.GetFormData();

    // Specify the value for FirstName and LastName text boxes. 
    formData["FirstName"].Value = "Janet";
    formData["LastName"].Value = "Leverling";

    // Specify the value for the Gender radio group. 
    formData["Gender"].Value = "Female";

    // Specify the check box checked appearance name. 
    formData["Check"].Value = "Yes";

    // Specify values for the Category list box. 
    formData["Category"].Value = new string[] { "Entertainment", "Meals", "Morale" };

    // Obtain data from the Address form field and specify values for Address child form fields. 
    PdfFormData address = formData["Address"];

    // Specify the value for the Country combo box.  
    address["Country"].Value = "United States";

    // Specify the value for City and Address text boxes.  
    address["City"].Value = "California";
    address["Address"].Value = "20 Maple Avenue";

    // Apply data to the interactive form.  
    documentProcessor.ApplyFormData(formData);

    // Save the modified document. 
    documentProcessor.SaveDocument(filePath + fileName + "_new.pdf");

    btnFillFormData.Enabled = false;
    btnLoadFilledPDF.Enabled = true;
}
本站文章除注明转载外,均为本站原创或翻译
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:DevExpress控件中文网 [https://www.devexpresscn.com/]
本文地址:https://www.devexpresscn.com/post/1219.html

相关产品: DevExpress Universal Subscription,


联系我们
  • 重庆总部 023-68661681 400-700-1020
  • 北京公司 010-56705895
购买
  • sales@evget.com
合作
  • business@evget.com