Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用PDFMARK和/或PERL cpan模块PDF::API2创建PDF表单?_Perl_Forms_Pdf_Cpan_Postscript - Fatal编程技术网

如何使用PDFMARK和/或PERL cpan模块PDF::API2创建PDF表单?

如何使用PDFMARK和/或PERL cpan模块PDF::API2创建PDF表单?,perl,forms,pdf,cpan,postscript,Perl,Forms,Pdf,Cpan,Postscript,是否有人有任何示例演示如何创建简单的PDF表单(单个文本输入框或单个单选按钮),并在单击时使用三种方法之一将“通过HTTP post提交字段\名称/值对”提交到服务器 通过将Adobe的PDFMARK注释嵌入Postscript文件,然后通过Adobe distiller或ghostscript将Postscript文件转换为PDF?我阅读了PDFMARK文档,其中只简要提到一个“操作”可以发送到“表单提交”。但这些文档严重缺乏该实现的真实细节。通常Adobe的文档都非常棒,但作者一定是迫于压力

是否有人有任何示例演示如何创建简单的PDF表单(单个文本输入框或单个单选按钮),并在单击时使用三种方法之一将“通过HTTP post提交字段\名称/值对”提交到服务器

  • 通过将Adobe的
    PDFMARK
    注释嵌入Postscript文件,然后通过Adobe distiller或ghostscript将Postscript文件转换为PDF?我阅读了PDFMARK文档,其中只简要提到一个“操作”可以发送到“表单提交”。但这些文档严重缺乏该实现的真实细节。通常Adobe的文档都非常棒,但作者一定是迫于压力才完成了这一章。缺少详细信息的是,PDF表单实际上可能会向服务器提交多达四种不同类型的数据包,但这些都没有提到。此外,“表单提交”操作的实际语法甚至没有给出
  • 通过使用PERL和免费的
    PDF::API2
    或3 PDF操作库。作者已经提供了一些低级函数调用,他认为这些调用有足够的可能性实际实现这一点,但遗憾的是,实际上并没有使用他的库来完成这一特定任务。有人知道如何利用他的图书馆吗?我问,因为我主要是一名Perl程序员
  • 最后,如果以上两种方法都不能给我带来任何好处,那么有没有人知道使用免费或成本相对较低的软件(不到200美元)来实现这一点的windows命令行可调用方法。如果可以使用不同的开发环境实现这一点,我愿意学习另一种语言

  • 在PostScript语言程序中使用pdfmark

    首先,我将处理您问题的第1部分:通过Adobe Acrobat Dilleter或类似工具运行带有pdfmark表达式的PostScript语言程序来创建这样的PDF表单文件。请参见下面的示例程序

    我认为您阅读的“PDFMARK文档”是。我的副本日期是2006年11月。在示例5.11中,在文档目录中定义AcroForm字典,在示例5.12中,在第70-75页定义小部件注释,它们也是此表单的字段字典。仔细阅读那里的代码,将其复制到一个源文件中并提取它,根据需要进行修改。这就是我的样本的基础

    请务必仔细阅读第1章介绍(第9-16页),这将帮助您阅读示例5.11和5.12中的pdfmark语法。命名对象部分(第12-16页)对于理解如何引用示例中的字体和编码非常重要

    但是您还需要阅读PDF语言规范。Adobe的规范副本已被ISO标准《阅读第12.7节交互式表单》(第430-456页)所取代,该标准将经常让您参考第12.5节注释(第381-414页),了解表单字段外观的控制

    需要了解的重要一点是,大多数表单字段将由PostScript语言
    […/ANN pdfmark
    表达式。键值对在PDF规范中指定,而不是在pdfmark规范中指定。但是在阅读PDF规范时编辑pdfmark表达式很容易

    以下程序提取为带有表单字段的PDF文件:

    % Simple pdfmark form example
    % by Jim DeLaHunt, jdlh.com, 3. March 2012
    %
    % This PostScript language code, when converted to PDF by 
    % Adobe Acrobat Distiller or the like, creates a PDF file with form
    % fields, and a Submit button which sends the values of the fields
    % via an HTTP POST request.
    %
    % In reply to Stack Overflow question, "How can I create a PDF form 
    % using PDFMARK and/or PERL cpan module PDF::API2?",
    % http://stackoverflow.com/questions/9440930/
    %
    
    % Define stubs for interpreters without pdfmark support
    % From pdfMark reference, Example 1.2, p.10
    /pdfmark where {
        % pdfmark is built-in
        % define {code} ?pdfmark - : exec modal PDF code.
        pop globaldict /?pdfmark /exec load put
    }{
        globaldict begin
            /?pdfmark /pop load def% pdfmark is absent: ignore code.
            /pdfmark /cleartomark load def
        end
    } ifelse
    %%EndProlog
    
    % This code makes the example clearer. It isn't part of the AcroForm.
    <</PageSize [300 300]>> setpagedevice  % smaller page (~ 10cm x 10cm)
    
    clippath 0.9 setgray fill  % light grey background, to show widgets.
    /Helvetica-Bold 12 selectfont 0 setgray  % for labels
    /showlabel {   % (text) x y showlabel - 
        % shows (text) top-justified at x,y, moves down one line
        -12 add moveto   % x y -12 add moveto -
        gsave show grestore
        0 -3 rmoveto  % leading (space between lines)
    } def
    /showcomment {  % (text) showcomment - 
        % shows (text) top-justified at current point, moves down 1 line
        0 -10 rmoveto 
        gsave /Helvetica 10 selectfont show grestore
        0 -2 rmoveto  % leading (space between lines)
    } def
    
    (Simple pdfmark form example) 10 290 showlabel
    
    
    % AcroForm dictionary setup. From pdfmark Reference, Example 5.11, p.70
    %
    % Read also PDF specification PDF32000:2008 
    % "Document management — Portable document format — Part 1: PDF 1.7",
    % Section 12.7 "Interactive Forms", p.430
    % To understand the syntax: [/_objdef {foo} /type /dict /OBJ pdfmark
    % read carefully pdfMark reference, "User-defined named objects", p.13.
    
    % Define font objects for the widgets to use
    [ /_objdef {ZaDb} /type /dict /OBJ pdfmark
    [ {ZaDb} <<
        /Type /Font
        /Subtype /Type1
        /Name /ZaDb
        /BaseFont /ZapfDingbats
    >> /PUT pdfmark
    [ /_objdef {Helv} /type /dict /OBJ pdfmark
    [ {Helv} <<
        /Type /Font
        /Subtype /Type1
        /Name /Helv
        /BaseFont /Helvetica
        % /Encoding {pdfDocEncoding} % for simplicity, use font's own encoding
        % pdfmark Reference, Example 5.11, p.70, provides an Encoding
        % array defining PDFDocEncoding
    >> /PUT pdfmark
    
    [ /_objdef {aform} /type /dict /OBJ pdfmark
    
    % Define Fields array of Acroform dictionary. It will contain entries for
    % each of the widgets defined below.
    % NOTE: It is not necessary to explicitly assign the widget annotations
    % to the Fields array; Acrobat does it automatically when the file is
    % opened.  
    
    [ /_objdef {afields} /type /array /OBJ pdfmark
    [ {aform} <<
        /Fields {afields}
        /DR << /Font << /ZaDb {ZaDb} /Helv {Helv} >> >>
        /DA (/Helv 0 Tf 0 g)
        /NeedAppearances true
        % "/NeedAppearances true" tells reader 'to construct appearance
        % streams and appearance dictionaries for all widget annotations
        % in the document...' --PDF32000:2008 Table 218 p.431
    >> /PUT pdfmark
    
    % Put Acroform entry in catalog dictionary
    [ {Catalog} << /AcroForm {aform} >> /PUT pdfmark
    
    
    % Example 5.12 Define the Widget annotations
    % pdfmark Reference pp. 72-75, with clarifications by Jim DeLaHunt
    %
    % These Widget annotations are also field dictionaries for this form.
    % This is the collection of all individual widget annotations. 
    % It is possible to have multiple instances of these sections, such as
    % for defining a single widget on each instance.
    %
    % See PDF32000:2008 Section 12.5.6.19 "Widget Annotations", p.408
    % especially tables 188 and 189.
    
    (/Tx text field) 10 260 showlabel
    (with Javascript) showcomment (validation) showcomment
    [ /Subtype /Widget
        /Rect [100 223 245 260]
        /F 4
        /T (SL Text)
        /FT /Tx
        /DA (/Helv 14 Tf 0 0 1 rg)
        /V (5)
        /AA <<
            /K << 
                /S /JavaScript 
                /JS (AFNumber_Keystroke\(2, 0, 0, 0, "$", true\);)
            >>
            /F << 
                /S /JavaScript 
                /JS (AFNumber_Format\(2, 0, 0, 0, "$", true\);)
                % pdfmark Reference p.72 seems to omit closing ")" above. Oops.
            >>
        >>
    /ANN pdfmark
    
    (/Btn field) 10 208 showlabel
    (Check Box) showcomment
    [  /Subtype /Widget
        /Rect [100 172 136 208]
        /F 4
        /T (Check Box)
        /FT /Btn
        /DA (/ZaDb 0 Tf 0 g)
        /AS /Off
        /MK << /CA (4)>>
        /AP << /N << /Oui /null >> >>
    /ANN pdfmark
    
    (/Ch field) 10 160 showlabel
    (List Box) showcomment
    [   /Subtype /Widget
        /Rect [100 87 137 160]
        /F 4
        /T (List Box)
        /FT /Ch
        /DA (/Helv 10 Tf 1 0 0 rg)
        /Opt [(1)(2)(3)(4)(5)]
        /DV (3)
        /V (3)
        /MK <<
            /BG [1 1 1]   % Background: white
            /BC [0 0 0]   % Border colour: black
        >>
        % MK is 'An appearance characteristics dictionary (see Table 189)'
        % --PDF32000:2008 Table 188 p.408
        % Without an /MK entry, Acrobat Pro 8.0 complains of an error
        % when displaying this field, and some entries aren't displayed.
    
    /ANN pdfmark
    
    (/Btn button) 160 85 showlabel
    (/S /SubmitForm action) showcomment
    % Example of how the /MK dictionary is used.
    [   /Subtype /Widget
        /Rect [ 130 10 270 50 ]
        /F 4
        /T (Submit)
        /FT /Btn
        /H /P
        /A << 
            /S /SubmitForm 
            /F (http://posttestserver.com/post.php) % Thanks, Henry!
            /Flags 16#6 % IncludeNoValueFields, ExportFormat
        >>
        /DA (/HeBo 18 Tf 0 0 1 rg)
        /Ff 65536
        /MK <<
            /BC [ 1 0 0 ]
            /BG [ 0.75 0.45 0.75 ]
            /CA (Submit)
            /AC (Submitted!)
        >>
        /BS <<
            /W 3
            /S /I
        >>
    /ANN pdfmark
    
    % When pressing the Submit button in Adobe Acrobat Professional 8.3.1,
    % there is a pause, and then Acrobat displays a PDF file with the
    % results of the HTTP POST operation. This is text like,
    %   Successfully dumped 3 post variables. View it at
    %   http://www.posttestserver.com/data/2012/03/04/01.29.271751566025 
    %   Post body was 0 chars long.
    %
    % Browse to that URL, and you will see diagnostics with the following:
    %   ....
    %   Post Params:
    %   key: 'Check_Box' value: 'Oui'
    %   key: 'List_Box' value: '4'
    %   key: 'SL_Text' value: '3.14'
    %   Empty post body.
    
    showpage  % make sure a page gets produced
    
    如果要支持小部件注释,您可能会看到类似
    $self->{Subtype}=PDFName('Widget')
    这样的语句。但是在这个模块(版本2.019)中没有字符串
    小部件的实例。因此,可能需要对这个模块进行扩展以支持小部件注释

    现在注释只是具有特定内容的PDF字典。可能可以使用它从基本部分构造小部件注释。但是,我猜想这将比扩展PDF::API2::Annot还要多


    把这个问题以及它所吸引的赏金作为一个信号:如果有人在PostScript语言程序中使用pdfmark为PDF::API2::Annot添加小部件注释支持,并可能制作一个PDF::API2::Form模块,那将是一件非常令人高兴的事情

    首先,我将处理您问题的第1部分:通过Adobe Acrobat Dilleter或类似工具运行带有pdfmark表达式的PostScript语言程序来创建这样的PDF表单文件。请参见下面的示例程序

    “PDFMARK文档”您阅读的是,我想是吧。我的副本日期是2006年11月。您需要的代码几乎都在这里,在示例5.11中,在文档目录中定义AcroForm字典,在示例5.12中,在第70-75页定义小部件注释,它们也是此表单的字段字典。请仔细阅读那里的代码,然后复制它转换为源文件并提取它,根据需要进行修改。这就是我的示例的基础

    请务必仔细阅读第1章引言(第9-16页),这将帮助您阅读示例5.11和5.12中的pdfmark语法。命名对象部分(第12-16页)对于理解示例中的字体和编码是如何引用的非常重要

    但您还需要阅读PDF语言规范。Adobe的规范副本已被ISO标准取代阅读第12.7节交互式表单(第430-456页),这将经常让您参考第12.5节注释(第381-414页),了解表单字段外观的控制

    需要了解的重要一点是,大多数表单字段将由PostScript语言
    […/ANN pdfmark
    表达式中提供的键值对定义。键值对在PDF规范中指定,而不是在pdfmark规范中指定。但是在读取PDF规范时编辑pdfmark表达式很容易
    $self->{Subtype}=PDFName('Link');