You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ms...@apache.org on 2014/11/09 21:44:02 UTC
pdfbox-docs git commit: PDFBOX-2340 initial AcroForms cookbook entry
Repository: pdfbox-docs
Updated Branches:
refs/heads/master 3165c7a7c -> 0110155da
PDFBOX-2340 initial AcroForms cookbook entry
Project: http://git-wip-us.apache.org/repos/asf/pdfbox-docs/repo
Commit: http://git-wip-us.apache.org/repos/asf/pdfbox-docs/commit/0110155d
Tree: http://git-wip-us.apache.org/repos/asf/pdfbox-docs/tree/0110155d
Diff: http://git-wip-us.apache.org/repos/asf/pdfbox-docs/diff/0110155d
Branch: refs/heads/master
Commit: 0110155dad4bdd7d191971f14a6ddddd4f98cd35
Parents: 3165c7a
Author: Maruan Sahyoun <sa...@fileaffairs.de>
Authored: Sun Nov 9 21:43:41 2014 +0100
Committer: Maruan Sahyoun <sa...@fileaffairs.de>
Committed: Sun Nov 9 21:43:41 2014 +0100
----------------------------------------------------------------------
docs/1.8/cookbook/acroforms/fill-form-field.md | 68 ++++++++++++++++++++
docs/1.8/cookbook/fonts/working-with-fonts.md | 40 +++++++++---
.../cookbook/metadata/working-with-metadata.md | 30 +++++++--
3 files changed, 126 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/pdfbox-docs/blob/0110155d/docs/1.8/cookbook/acroforms/fill-form-field.md
----------------------------------------------------------------------
diff --git a/docs/1.8/cookbook/acroforms/fill-form-field.md b/docs/1.8/cookbook/acroforms/fill-form-field.md
new file mode 100644
index 0000000..5a42922
--- /dev/null
+++ b/docs/1.8/cookbook/acroforms/fill-form-field.md
@@ -0,0 +1,68 @@
+---
+license: Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+title: Cookbook - Fill a Form Field
+---
+
+Fill a Form Field
+==================
+
+Form fields within a PDF are defined as part of the AcroForm entry within the PDF's document catalog.
+Form there individual fields can be accessed. Fields might be organized in a tree structure so it might
+be neccessary to walk through the tree to get an individual field.
+
+Load the PDF document.
+
+ :::java
+ // load the document
+ PDDocument pdfDocument = PDDocument.loadNonSeq(new File(... ), null);
+
+Get the docoument catalog and the AcroForm which might be contained within.
+
+ :::java
+ // get the document catalog
+ PDDocumentCatalog docCatalog = pdfDocument.getDocumentCatalog();
+ PDAcroForm acroForm = docCatalog.getAcroForm();
+
+Retrieve an individual field and set it's value.
+
+ :::java
+ // as there might not be an AcroForm entry a null check is necessary
+ if (acroForm != null)
+ {
+ PDField field = (PDField) acroForm.getField( "fieldName" );
+ field.setValue("new field value");
+ }
+
+If a field is nested within the form tree a fully qualified name might be provided
+to access the field.
+
+ :::java
+ // as there might not be an AcroForm entry a null check is neccessary
+ if (acroForm != null)
+ {
+ PDField field = (PDField) acroForm.getField( "fieldsParentName.fieldName" );
+ field.setValue("new field value");
+ }
+
+Save and close the filled out form.
+
+ :::java
+ doc.save(filledForm);
+ doc.close();
+
http://git-wip-us.apache.org/repos/asf/pdfbox-docs/blob/0110155d/docs/1.8/cookbook/fonts/working-with-fonts.md
----------------------------------------------------------------------
diff --git a/docs/1.8/cookbook/fonts/working-with-fonts.md b/docs/1.8/cookbook/fonts/working-with-fonts.md
index 1a717c1..3654b65 100644
--- a/docs/1.8/cookbook/fonts/working-with-fonts.md
+++ b/docs/1.8/cookbook/fonts/working-with-fonts.md
@@ -1,8 +1,29 @@
-Title: Cookbook - Working with Fonts
-
-## Working with Fonts
-
-### Standard 14 Fonts
+---
+license: Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+title: Cookbook - Working with Fonts
+---
+
+Working with Fonts
+==================
+
+Standard 14 Fonts
+-----------------
The PDF specification states that a standard set of 14 fonts will always be available when consuming PDF documents. In PDFBox these are defined as constants in the PDType1Font class.
@@ -23,7 +44,8 @@ The PDF specification states that a standard set of 14 fonts will always be avai
| PDType1Font.SYMBOL | Symbol Set |
| PDType1Font.ZAPF_DINGBATS | Dingbat Typeface |
-### Hello World using a PDF base font
+Hello World using a PDF base font
+---------------------------------
This small sample shows how to create a new document and print the text "Hello World" using one of the PDF base fonts.
@@ -53,7 +75,8 @@ This small sample shows how to create a new document and print the text "Hello W
document.save( "Hello World.pdf");
document.close();
-### Hello World using a TrueType font
+Hello World using a TrueType font
+---------------------------------
This small sample shows how to create a new document and print the text "Hello World" using a TrueType font.
@@ -92,7 +115,8 @@ names to TTF font files. The UNKNOWN_FONT property in that file will tell PDFBox
use when no mapping exists.
-### Hello World using a Postscript Type1 font
+Hello World using a Postscript Type1 font
+-----------------------------------------
This small sample shows how to create a new document and print the text "Hello World" using a Postscript Type1 font.
http://git-wip-us.apache.org/repos/asf/pdfbox-docs/blob/0110155d/docs/1.8/cookbook/metadata/working-with-metadata.md
----------------------------------------------------------------------
diff --git a/docs/1.8/cookbook/metadata/working-with-metadata.md b/docs/1.8/cookbook/metadata/working-with-metadata.md
index 150600b..154e323 100644
--- a/docs/1.8/cookbook/metadata/working-with-metadata.md
+++ b/docs/1.8/cookbook/metadata/working-with-metadata.md
@@ -1,8 +1,29 @@
-Title: Cookbook - Working with Metadata
+---
+license: Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
-## Working with Metadata
+ http://www.apache.org/licenses/LICENSE-2.0
-### Introduction
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+title: Cookbook - Working with Metadata
+----
+
+Working with Metadata
+=====================
+
+Introduction
+------------
PDF documents can contain information describing the document itself or certain objects
within the document such as the author of the document or it's creation date.
@@ -28,7 +49,8 @@ provides a high level API to that information:
System.out.println( "Trapped=" + info.getTrapped() );
-### Accessing PDF Metadata
+Accessing PDF Metadata
+----------------------
See class:org.apache.pdfbox.pdmodel.common.PDMetadata
See example:AddMetadataFromDocInfo