Your first PDF form with Scribus: Difference between revisions

From Scribus Wiki
Jump to navigation Jump to search
m (Viewing PDF forms in browsers)
No edit summary
 
(69 intermediate revisions by 11 users not shown)
Line 1: Line 1:
'''Other languages:''' [[Twój pierwszy formularz PDF w Scribusie|Polski (pl)]] - [[Seu primeiro formulário PDF usando o Scribus|Português (br)]] - [[Dein_erstes_PDF-Formular_mit_Scribus|Deutsch (de)]]
{{HOWTO Index}}
{{HOWTO Index}}
[[Category:PDF_Forms]][[Category:EN]][[Category:PDF]]


=Introduction=
<!--
<div style="background-color: #fee; margin: 0 1em; padding: 0 10px; border: 1px dotted #c00;">
'''BIG FAT WARNING:'''
Scribus support for PDF forms in the last two stable Scribus releases 1.3.3.8 and 1.3.3.9  is badly broken due to two unresolved major bugs,  please refer to the bug reports [http://bugs.scribus.net/view.php?id=5444 5444] and [http://bugs.scribus.net/view.php?id=5408 5408] for more information. 
</div>
-->
 
 
{| border="0" cellpadding="2" cellspacing="0" align="right" style="color:white;background:#065682;"
<!-- Header -->
|-style="color:white; background: #98712a;margin-bottom:5px;font-weight:bold"
|'''Requirements:'''
|&nbsp;&nbsp;
 
<!-- Row 1 -->
|-
|'''Operating System:'''
|&nbsp;&nbsp;any supported system &nbsp;
<!-- Row 2 -->
|-
|'''Scribus Version:'''
|&nbsp;&nbsp;stable 1.3.3.10 or above
<!-- Row 3 -->
|-
|'''PDF forms skills:'''
|&nbsp;&nbsp;novice 
<!-- Row 4 -->
|-
|'''PDF viewer:'''
|&nbsp;&nbsp;Adobe Reader 7 or newer 
<!-- Row 5 -->
|-
|'''Browser:'''
|&nbsp;&nbsp;any that supports Adobe Reader plug-in,<br/>&nbsp;&nbsp;preferrably Firefox 
|}


One of the biggest advantages of Scribus is the possibility to create PDF forms with embedded JavaScript scripts (in Adobe's own version, as described in the [http://partners.adobe.com/asn/developer/pdfs/tn/5186AcroJS.pdf Acrobat Javascript Reference] - 9.8 Mb). If you belong to the small minority of people who can do without any characters apart from the ISO-8859-1 font set, you are a lucky guy, because this is the only font set which will be properly displayed in form fields in Acrobat Reader. This is at least true for forms created with Scribus, because Acrobat Reader seems to use its own special fonts to display '''exotic''' (means non-English) characters.


Furthermore, there are still some issues with PDF forms, which have to be addressed to make Scribus a full featured PDF forms tool. E.g., there is an issue with radio buttons behaviour [http://bugs.scribus.net/view.php?id=866 feature request 866], and Scribus seems to be lacking the possibility to define globally executable JavaScripts (e.g. to execute on document loading).


Nevertheless, Scribus already '''is''' an useful PDF forms tool for many people, and it's been becoming better in an incredible pace. Enjoy!
=Introduction=
{{TOC_Forms_sidebar}}


''(Beware: this is still work in progress, I'm going to update this howto and insert new images, as soon as possible --[[User:Mhanski|Mhanski]] 17:22, 7 Feb 2005 (UTC) )''
One of the biggest advantages of Scribus is its ability to create PDF forms with embedded JavaScript scripts. Usually, PDF forms are filled out by users on their computers and then printed out locally. Information in a PDF form may also be submitted online to a remote location for further processing. However, this online submission works ''only when using the Acrobat Reader plugin'', not when using the standalone Acrobat Reader application.


=How it works=
There are still some issues around creating PDF forms in Scribus that need to be addressed to make Scribus a fully featured PDF forms tool. For example, there is an issue with the behaviour of radio buttons(see [http://bugs.scribus.net/view.php?id=3831 this list] of bugs and feature requests related to PDF forms).


Its rather simple to create a new form with Scribus. We start with clicking on the "New Document" icon or choosing '''New''' from the '''File''' menu.
Nevertheless, Scribus '''already is''' a useful PDF forms tool for many people, and it is becoming better at an incredible pace. Enjoy!


=Creating PDF forms=


<!--[[Image:New form.png|left|thumb|400px|New document dialog in Scribus 1.2.2]]-->
Its rather simple to create a new form with Scribus. We start with clicking on the &quot;New Document&quot; icon or choosing '''New''' from the '''File''' menu.
[[Image:New form.png|New document dialog in Scribus 1.2.2]]


[[Image:Pdf form howto new doc.png|New document dialog in Scribus 1.3.3.*]]


Let us activate the grid then (menu '''View -> Show Grid'''), it will help us to correctly locate our form fields on the page. We need some text frames to make a nice title and field descriptions - a few clicks on the '''[ab]''' icon and all the text frames are there in no time.
Let us turn on the grid first (menu '''View>Show Grid'''), it will help us to correctly locate our form fields on the page. We need some text frames to make a nice title and field descriptions - a few clicks on the text frame icon (that one right to the arrow)  and all the text frames are there in no time.




[[Image:Grid menu.png]]
[[Image:Pdf form howto grid menu.png]]




Having filled our frames with text, we can change their properties with the '''Properties''' palette, which can be found in the '''Tools''' menu.
Having filled our frames with text, we can change their properties with the '''Properties''' palette, which can be found in the '''Windows''' menu.




[[Image:Properties.png]]
[[Image:Pdf_form_howto_properties.png]]




Line 35: Line 71:




[[Image:Form elements1.png]]
[[Image:Pdf form howto pdf form elements.png]]




The current active element of the form has a red frame border; you can activate an element in choosing the "Select" icon (the one with crossed arrows) and clicking on the item to be chosen.
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.




Line 44: Line 80:




The right click on an element activates a new menu. We choose Under PdfOptions '''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).
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).




Line 56: Line 92:




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.
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.




[[Image:Field tab order.png]]
[[Image:Pdf form howto 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 as global scripts as well ('''Edit -> JavaScripts''').
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''').




Line 80: Line 116:




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




[[Image:Pdf export.png]]
[[Image:Pdf form howto 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 in eaerlier -- in Scribus, just right click onto the form field, choose '''Edit text...''' from the context menu and type your default value.
 
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.




[[Image:Acroread unicode.png]]
[[Image:Acroread unicode.png]]


=Configuring browsers for viewing PDF forms=


=Viewing PDF forms in browsers=
If you are a happy owner of a relatively recent edition of [http://www.mozilla.org/products/firefox/ 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:


If you are a happy owner of a relatively recent edition of [http://www.mozilla.org/products/firefox/ 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 say 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.


  Create a symbolic link to nppdf.so to your Mozilla plugins directory. //On my Gentoo '''/usr/lib/MozillaFirefox/plugins'''
For using Firefox plug-ins with other operating systems, refer to [http://plugindoc.mozdev.org/ Mozilla Plugindoc site].
  Ensure a copy of acroread is in your PATH.




<!--  The resulting PDF form can be tested [http://linux.hanski.info/tests/scribus_form_en.pdf here]. In order to submit the form we must open it from within a browser, Netscape 4.* or Mozilla are the safe choices (check the Mozilla plug-ins to see, if the Acrobat Reader plug-in is enabled. If not, you have to symlink it into the Mozilla's plug-in directory. In my particular case, the Mozilla's plug-in directory is /usr/lib/mozilla-1.3/plug-in, and the plug-in to be symlinked into it is /usr/local/Acrobat5/Browsers/intellinux/nppdf.so).
=Testing and downloading sample files=
-->
 
* [http://linux.hanski.info/tests/scribus_form_en.pdf 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.
 
* [http://linux.hanski.info/tests/scribus_sample_form.tar.gz Download sample files] -- A gzipped tarball of sample files (SLA, PHP, PDF) used in this howto


=Final word=  
=Final word=  
Line 108: Line 150:
My very own impression: Scribus as a tool for working with PDF forms seems to be more comfortable in use than Adobe Acrobat 5.0 (the only version, I've worked with). It's a lot easier to layout documents with Scribus, since Acrobat only allows you to edit existing documents, but not to create a new document from scratch. Scribus provides us with the full control over the final results and allows us much more freedom in changing the document's layout. More over, Scribus files can be edited even with a simple text editor, since its file format is entirely XML based.
My very own impression: Scribus as a tool for working with PDF forms seems to be more comfortable in use than Adobe Acrobat 5.0 (the only version, I've worked with). It's a lot easier to layout documents with Scribus, since Acrobat only allows you to edit existing documents, but not to create a new document from scratch. Scribus provides us with the full control over the final results and allows us much more freedom in changing the document's layout. More over, Scribus files can be edited even with a simple text editor, since its file format is entirely XML based.


--[[User:Mhanski|Mhanski]] 17:17, 7 Feb 2005 (UTC)
 
=Other information sources=
 
* [http://www.planetpdf.com/developer/article.asp?ContentID=6575&mp JavaScript - Introduction to Development with Examples]
 
{{CC_BY_SA_and_GNU_FDL|2004-2008|Maciej Hański and subsequent Scribus Wiki authors mentioned in the article history}}

Latest revision as of 06:03, 14 January 2011

Other languages: Polski (pl) - Português (br) - Deutsch (de)

This article is part of the HOWTOs series.
Installation Usage PDF issues Imposition Other


Requirements:   
Operating System:   any supported system  
Scribus Version:   stable 1.3.3.10 or above
PDF forms skills:   novice
PDF viewer:   Adobe Reader 7 or newer
Browser:   any that supports Adobe Reader plug-in,
  preferrably Firefox


Introduction

  1. Your first PDF form with Scribus
  2. How to create an e-Mail PDF Survey Form
  3. Your second PDF form with Scribus
  4. Enhance PDF forms with JavaScript

One of the biggest advantages of Scribus is its ability to create PDF forms with embedded JavaScript scripts. Usually, PDF forms are filled out by users on their computers and then printed out locally. Information in a PDF form may also be submitted online to a remote location for further processing. However, this online submission works only when using the Acrobat Reader plugin, not when using the standalone Acrobat Reader application.

There are still some issues around creating PDF forms in Scribus that need to be addressed to make Scribus a fully featured PDF forms tool. For example, there is an issue with the behaviour of radio buttons(see this list of bugs and feature requests related to PDF forms).

Nevertheless, Scribus already is a useful PDF forms tool for many people, and it is becoming better at an incredible pace. Enjoy!

Creating PDF forms

Its rather simple to create a new form with Scribus. We start with clicking on the "New Document" icon or choosing New from the File menu.

New document dialog in Scribus 1.3.3.*

Let us turn on the grid first (menu View>Show Grid), it will help us to correctly locate our form fields on the page. We need some text frames to make a nice title and field descriptions - a few clicks on the text frame icon (that one right to the arrow) and all the text frames are there in no time.


Pdf form howto grid menu.png


Having filled our frames with text, we can change their properties with the Properties palette, which can be found in the Windows menu.


Pdf form howto properties.png


Now we can start adding form elements: some text fields and one button for submitting our form to an URL. To add a field simply click on the arrow on the right side of the OK icon and select a type from the displayed options: button, text field, check box, combo box, and list box.


Pdf form howto pdf form elements.png


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.


Pdf form howto 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... > Save as PDF.... We select PDF 1.3 as the file format and save the file.


Pdf form howto 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

Configuring browsers for viewing PDF forms

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.


Testing and downloading sample files

  • 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.

Final word

My very own impression: Scribus as a tool for working with PDF forms seems to be more comfortable in use than Adobe Acrobat 5.0 (the only version, I've worked with). It's a lot easier to layout documents with Scribus, since Acrobat only allows you to edit existing documents, but not to create a new document from scratch. Scribus provides us with the full control over the final results and allows us much more freedom in changing the document's layout. More over, Scribus files can be edited even with a simple text editor, since its file format is entirely XML based.


Other information sources


(c)

The content of this page is available under the Creative Commons Attribution-ShareAlike Licence and Free Documentation Licence

If you alter, transform, or build upon this work, you may distribute the resulting work either under one or under both of the abovementioned licences.