Seu primeiro formulário PDF usando o Scribus

From Scribus Wiki
Revision as of 21:14, 3 January 2006 by Ludi (talk | contribs)
Jump to navigation Jump to search
Este artigo é parte da seção de Tutoriais.
Instalação Uso Questões sobre PDF DTP Outros
Voltar para a página principal

EM CONSTRUÇÃO

Versão em inglês.

Básico

Uma das imensas vantagens do Scribus, é a possibilidade de criar formulários PDF com um JavaScript incorporado ao documento. Normalmente, os formulários de PDF são feitos para serem preenchidos pelo usuário em seus computadores e então impressos. Informações contidas em formulários do PDF, podem também serem enviadas através da internet a algum lugar remoto para processamento futuro (um servidor, por exemplo).

Ainda há questões não resolvidas de formulários de PDF no Scribus que devem ser solucionadas para tornar o Scribus completo no uso desta ferramenta. Por exemplo, há um problema relacionado ao comportamento dos botões de rádio (de marcação/seleção). Veja o pedido de recurso 866.

Ainda sim, o Scribus já é uma ferramenta útil na criação de formulários de PDF para muita gente, e está se tornando cada vez melhor a passos largos. Aproveite!

Requerimentos

  • Scribus -- quando mais novo melhor. Vá até o site do Scribus e na seção de download, baixe a última versão. Você também pode usar o Klik ou usar um dos repositórios Debian/Ubuntu.
  • Adobe Reader 7 ou mais novo (o 8.5 está em fase de testes).
  • Um navegador que suporte o plugin do Acrobat Reader.

Criando formulários PDF

É simples criar um novo formulário com o Scribus. Nós começamos com um clique no ícone Novo Documento ou usando o menu Arquivo > Novo.

A janela de diálogo de novo documento no Scribus 1.2.2

Diálogo de novo documento no Scribus 1.2.2

Vamos nos voltar para a grade primeiramente (menu Visualizar>Mostrar Grade), ela irá nos ajudar a colocar nossos campos de formulário corretamente na página. Nós precisamos de alguns quadro de textos para criar uma bela descrição de título e campo - alguns cliques no botão de quadro de texto (aquele ao lado da seta) e todos os quadros de textos estão lá, de forma instantânea.


Grid menu.png

Grade

Tendo preenchido os nossos quadros com texto, nós podemos alterar as suas propriedades com a paleta Propriedades, que pode ser encontrada no menu Ferramentas Having filled our frames with text, we can change their properties with the Properties palette, which can be found in the Tools menu.


Properties.png

Janela de propriedades

Agora nós podemos iniciar a adicção de elementos; alguns campos de texto para o envio do nosso formulário para um URL. Para adicionar um campo, dê um clique simples na seta do lado direito do ícone OK e selecione o tipo de opção a ser exibida: Botão, campo de texto, caixa de combinação e caixa de lista.

Form elements1.png

Janelas de seleção de formulário

The current active element of the form has a red frame border; you can select an element in choosing the Select icon (the one with an arrow, left to the text frame icon) and clicking on the item to be chosen.


Ulica.png


The right click on an element activates a new context menu. We choose Pdf Options > Field Properties and define field names (we will need the field names in our PHP script, to which we'll send the form), types (e.g., number, time, date), and actions to be performed on different events (Mouse Enter, Mouse Exit, On Blur, and so on).


Field properties appearance1.png


Here we are defining the No field as a number. Acrobat Reader won't accept anything else as a valid entry, then.


Field properties format1.png


To change the existing tab order of your form fields, simply open the Properties palette, click on the X,Y,Z tab, and change the level of the selected field.


Field tab order.png


Here, we are defining a custom validation script for the Name field - after changing the field contents there will be a beep sound and an alert will be showed (not very sophisticated, I know, but it still demonstrates the possibilities of PDF). Scribus has its own simple text editor, which enables us to save the script to a separate file. Custom scripts can be defined not only on the form field level, but document wide too (Edit > JavaScripts).


Js validate script.png


After saving the script and closing the editor, the script contents is shown in the Field Properties.


Field properties validate.png


We have still to define, to which URL the form contents will be sent (there is a simple PHP script at the destination address, which will format and display the received form data). We choose in the button properties as the action type Submit form and enter the address of our PHP script: scribus_test.php. We match the Submit Data as HTML option to end with (the other option would be the FDF data, but this is a very different story) and we are done now.


Field action.png


The only thing else to do is to export the document to PDF: menu File > Export... > Export to PDF.... We select Acrobat 5.0 as the file format and save the file.


Pdf export.png


Now it is time to launch Acrobat Reader and and see what you have done. Acrobat Reader 7 finally delivers the capability to display Unicode characters inside form fields -- great news for all non English native speakers. Both Name and Street fields contain characters outside of the Latin-1 font set. The No field contains a default value of 15 that has been put into it eaerlier -- in Scribus, just right click onto the form field, choose Edit text... from the context menu and type your default value.


Acroread unicode.png

Configurando o naveador para visualizar formulários de PDF

If you are a happy owner of a relatively recent edition of Firefox, Mozilla, or Netscape, you are best suited to view PDF forms with your browser. Since neither Opera nor Konqueror has been capable of submitting PDF forms, let's focus on Mozilla family. The only thing to do is to tell Firefox, where the Acrobat Reader plug-in is located. For Linux:

  1. Create a symbolic link to $your_installation_directory/Acrobat7.0/Browser/intellinux/nppdf.so 
     to your Mozilla plugins directory, e.g. in Gentoo Linux /usr/lib/MozillaFirefox/plugins
  2. Ensure a copy of acroread is in your PATH.

For using Firefox plug-ins with other operating systems, refer to Mozilla Plugindoc site.


Testando e baixando arquivos de exemplos

  • Sample PDF form (made with Scribus) -- Open this form in your browser and click on the Submit button. If your browser is configured for working with Adobe Reader, you should get a responce from a PHP script.

Outras fontes de informação (em inglês)