You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Venkatesh Prasad.B.K. (JIRA)" <ji...@apache.org> on 2009/06/05 15:24:07 UTC

[jira] Created: (PDFBOX-481) renaming a field and not able to set value to the saved PDF document ...

renaming a field and not able to set value to the saved PDF document ...
------------------------------------------------------------------------

                 Key: PDFBOX-481
                 URL: https://issues.apache.org/jira/browse/PDFBOX-481
             Project: PDFBox
          Issue Type: Bug
          Components: PDModel.AcroForm
    Affects Versions: 0.7.3
         Environment: Windows XP Professional SP3, jre1.6.0_07/jdk1.6.0_11 , PDFBox-0.7.3.jar
            Reporter: Venkatesh Prasad.B.K.
             Fix For: 0.7.3


I will explain what I want to do.

1. I have a PDF Document with Fields and let us call this 'Source_Original.PDF'. The field names in this PDF document have to be renamed and stored as 'Source_Target.PDF'. I then have to set/change the values of form-fields in 'Source_Target.PDF'.

The issue I am facing is given below:

1. I renamed the form fields in 'Source_Original.PDF" using the code given in my earlier mail (below) and saved it as 'Source_Target.PDF'.
2. I checked the form fields in 'Source_Target.PDF" and form-fields were renamed correctly.
3. However when I tried to set/change values of form-fields in 'Source_Target.PDF' using PDFBox code, I was not able to do so.

I used iText to set/change values of form-fields in 'Source_Target.PDF' and was successful. But we want to use only PDFBox.

To summarize - We are not able to set/change values of form fields of a PDF Document whose form-fields have been renamed. There is no issue if the form-fields are renamed manually using Adobe Acrobat 9. The issue is only
when the form-fields are renamed using PDFBox option - setPartialName(newFieldName);

> Only to be sure, changing values in 'Source_Original.PDF'  works with the same code you use to 
> manipulate 'Source_Target.PDF'??

Yes

I have attached the 2 files - "Source_Original.PDF' and 'Source_Target.PDF',

----- Code
				try
				{
					PDDocument pdfDocument = PDDocument.load(pdfSource);
					try
					{
						if (pdfDocument.isEncrypted())
						{
							pdfDocument.decrypt("");
						}
						PDDocumentCatalog docCatalog = pdfDocument.getDocumentCatalog();
						PDAcroForm acroForm = docCatalog.getAcroForm();
						if (acroForm != null)
						{
							List pdfFields = acroForm.getFields();
							if (pdfFields != null)
							{
								PDField pdfField;
								for (int i = 0; i < pdfFields.size(); i++)
								{
									pdfField = (PDField) pdfFields.get(i);
									String fieldName = pdfField.getPartialName();
									if( pdfFieldNames.containsKey(fieldName) ){
										String newFieldName = (String) pdfFieldNames.get(fieldName);
										pdfField.setPartialName(newFieldName);
									}
								}
								pdfDocument.save(pdfOutput);
							} else {
								return "No Acro Form Fields found in PDF Document " + pdfSource + "!";
							}
						} else {
							return "PDF document " + pdfSource + " not able to access!";
						}
					} catch (Exception e) {
						return "PDF Document " + pdfSource + " is encrypted! Cannot process.";
					}
					pdfDocument.close();
				} catch (Exception e) {
					return "PDF Document " + pdfSource + " cannot be found!";
				}


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PDFBOX-481) renaming a field and not able to set value to the saved PDF document ...

Posted by "Andreas Lehmkühler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PDFBOX-481?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12717047#action_12717047 ] 

Andreas Lehmkühler commented on PDFBOX-481:
-------------------------------------------

During my debugging I found an issue concerning the scaling of lines. Some lines are too thick. e.g. on the last page the 2 lines for the signature.
The solution is to scale the linewidth with the current transformation matrix. But at this point It is important that the scaling is done just before the path is stroked and not during setting the linewidth as implemented in my former patch (see PDFBOX-454). With version 782401 everything seems to be ok.

> renaming a field and not able to set value to the saved PDF document ...
> ------------------------------------------------------------------------
>
>                 Key: PDFBOX-481
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-481
>             Project: PDFBox
>          Issue Type: Bug
>          Components: PDModel.AcroForm
>    Affects Versions: 0.7.3
>         Environment: Windows XP Professional SP3, jre1.6.0_07/jdk1.6.0_11 , PDFBox-0.7.3.jar
>            Reporter: Venkatesh Prasad.B.K.
>             Fix For: 0.7.3
>
>         Attachments: PDFBOX481-Source_Target_filled.pdf, Source_Original.pdf, Source_Target.pdf
>
>
> I will explain what I want to do.
> 1. I have a PDF Document with Fields and let us call this 'Source_Original.PDF'. The field names in this PDF document have to be renamed and stored as 'Source_Target.PDF'. I then have to set/change the values of form-fields in 'Source_Target.PDF'.
> The issue I am facing is given below:
> 1. I renamed the form fields in 'Source_Original.PDF" using the code given in my earlier mail (below) and saved it as 'Source_Target.PDF'.
> 2. I checked the form fields in 'Source_Target.PDF" and form-fields were renamed correctly.
> 3. However when I tried to set/change values of form-fields in 'Source_Target.PDF' using PDFBox code, I was not able to do so.
> I used iText to set/change values of form-fields in 'Source_Target.PDF' and was successful. But we want to use only PDFBox.
> To summarize - We are not able to set/change values of form fields of a PDF Document whose form-fields have been renamed. There is no issue if the form-fields are renamed manually using Adobe Acrobat 9. The issue is only
> when the form-fields are renamed using PDFBox option - setPartialName(newFieldName);
> > Only to be sure, changing values in 'Source_Original.PDF'  works with the same code you use to 
> > manipulate 'Source_Target.PDF'??
> Yes
> I have attached the 2 files - "Source_Original.PDF' and 'Source_Target.PDF',
> ----- Code
> 				try
> 				{
> 					PDDocument pdfDocument = PDDocument.load(pdfSource);
> 					try
> 					{
> 						if (pdfDocument.isEncrypted())
> 						{
> 							pdfDocument.decrypt("");
> 						}
> 						PDDocumentCatalog docCatalog = pdfDocument.getDocumentCatalog();
> 						PDAcroForm acroForm = docCatalog.getAcroForm();
> 						if (acroForm != null)
> 						{
> 							List pdfFields = acroForm.getFields();
> 							if (pdfFields != null)
> 							{
> 								PDField pdfField;
> 								for (int i = 0; i < pdfFields.size(); i++)
> 								{
> 									pdfField = (PDField) pdfFields.get(i);
> 									String fieldName = pdfField.getPartialName();
> 									if( pdfFieldNames.containsKey(fieldName) ){
> 										String newFieldName = (String) pdfFieldNames.get(fieldName);
> 										pdfField.setPartialName(newFieldName);
> 									}
> 								}
> 								pdfDocument.save(pdfOutput);
> 							} else {
> 								return "No Acro Form Fields found in PDF Document " + pdfSource + "!";
> 							}
> 						} else {
> 							return "PDF document " + pdfSource + " not able to access!";
> 						}
> 					} catch (Exception e) {
> 						return "PDF Document " + pdfSource + " is encrypted! Cannot process.";
> 					}
> 					pdfDocument.close();
> 				} catch (Exception e) {
> 					return "PDF Document " + pdfSource + " cannot be found!";
> 				}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (PDFBOX-481) renaming a field and not able to set value to the saved PDF document ...

Posted by "Andreas Lehmkühler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PDFBOX-481?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12717046#action_12717046 ] 

Andreas Lehmkühler edited comment on PDFBOX-481 at 6/7/09 8:29 AM:
-------------------------------------------------------------------

I've filled some fields of the acroform using pdfbox and attached the file. Due to an issue displaying this pdf you have to use some other viewer like acrobat

      was (Author: lehmi):
    I've filled some fields of the acroform using pdfbox. Due to an issue displaying this pdf you have to use some other viewer like acrobat
  
> renaming a field and not able to set value to the saved PDF document ...
> ------------------------------------------------------------------------
>
>                 Key: PDFBOX-481
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-481
>             Project: PDFBox
>          Issue Type: Bug
>          Components: PDModel.AcroForm
>    Affects Versions: 0.7.3
>         Environment: Windows XP Professional SP3, jre1.6.0_07/jdk1.6.0_11 , PDFBox-0.7.3.jar
>            Reporter: Venkatesh Prasad.B.K.
>             Fix For: 0.7.3
>
>         Attachments: PDFBOX481-Source_Target_filled.pdf, Source_Original.pdf, Source_Target.pdf
>
>
> I will explain what I want to do.
> 1. I have a PDF Document with Fields and let us call this 'Source_Original.PDF'. The field names in this PDF document have to be renamed and stored as 'Source_Target.PDF'. I then have to set/change the values of form-fields in 'Source_Target.PDF'.
> The issue I am facing is given below:
> 1. I renamed the form fields in 'Source_Original.PDF" using the code given in my earlier mail (below) and saved it as 'Source_Target.PDF'.
> 2. I checked the form fields in 'Source_Target.PDF" and form-fields were renamed correctly.
> 3. However when I tried to set/change values of form-fields in 'Source_Target.PDF' using PDFBox code, I was not able to do so.
> I used iText to set/change values of form-fields in 'Source_Target.PDF' and was successful. But we want to use only PDFBox.
> To summarize - We are not able to set/change values of form fields of a PDF Document whose form-fields have been renamed. There is no issue if the form-fields are renamed manually using Adobe Acrobat 9. The issue is only
> when the form-fields are renamed using PDFBox option - setPartialName(newFieldName);
> > Only to be sure, changing values in 'Source_Original.PDF'  works with the same code you use to 
> > manipulate 'Source_Target.PDF'??
> Yes
> I have attached the 2 files - "Source_Original.PDF' and 'Source_Target.PDF',
> ----- Code
> 				try
> 				{
> 					PDDocument pdfDocument = PDDocument.load(pdfSource);
> 					try
> 					{
> 						if (pdfDocument.isEncrypted())
> 						{
> 							pdfDocument.decrypt("");
> 						}
> 						PDDocumentCatalog docCatalog = pdfDocument.getDocumentCatalog();
> 						PDAcroForm acroForm = docCatalog.getAcroForm();
> 						if (acroForm != null)
> 						{
> 							List pdfFields = acroForm.getFields();
> 							if (pdfFields != null)
> 							{
> 								PDField pdfField;
> 								for (int i = 0; i < pdfFields.size(); i++)
> 								{
> 									pdfField = (PDField) pdfFields.get(i);
> 									String fieldName = pdfField.getPartialName();
> 									if( pdfFieldNames.containsKey(fieldName) ){
> 										String newFieldName = (String) pdfFieldNames.get(fieldName);
> 										pdfField.setPartialName(newFieldName);
> 									}
> 								}
> 								pdfDocument.save(pdfOutput);
> 							} else {
> 								return "No Acro Form Fields found in PDF Document " + pdfSource + "!";
> 							}
> 						} else {
> 							return "PDF document " + pdfSource + " not able to access!";
> 						}
> 					} catch (Exception e) {
> 						return "PDF Document " + pdfSource + " is encrypted! Cannot process.";
> 					}
> 					pdfDocument.close();
> 				} catch (Exception e) {
> 					return "PDF Document " + pdfSource + " cannot be found!";
> 				}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (PDFBOX-481) renaming a field and not able to set value to the saved PDF document ...

Posted by "Venkatesh Prasad.B.K. (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PDFBOX-481?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Venkatesh Prasad.B.K. updated PDFBOX-481:
-----------------------------------------

    Attachment: Source_Target.pdf
                Source_Original.pdf

Files attached as requested by Mr.Andreas.

> renaming a field and not able to set value to the saved PDF document ...
> ------------------------------------------------------------------------
>
>                 Key: PDFBOX-481
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-481
>             Project: PDFBox
>          Issue Type: Bug
>          Components: PDModel.AcroForm
>    Affects Versions: 0.7.3
>         Environment: Windows XP Professional SP3, jre1.6.0_07/jdk1.6.0_11 , PDFBox-0.7.3.jar
>            Reporter: Venkatesh Prasad.B.K.
>             Fix For: 0.7.3
>
>         Attachments: Source_Original.pdf, Source_Target.pdf
>
>
> I will explain what I want to do.
> 1. I have a PDF Document with Fields and let us call this 'Source_Original.PDF'. The field names in this PDF document have to be renamed and stored as 'Source_Target.PDF'. I then have to set/change the values of form-fields in 'Source_Target.PDF'.
> The issue I am facing is given below:
> 1. I renamed the form fields in 'Source_Original.PDF" using the code given in my earlier mail (below) and saved it as 'Source_Target.PDF'.
> 2. I checked the form fields in 'Source_Target.PDF" and form-fields were renamed correctly.
> 3. However when I tried to set/change values of form-fields in 'Source_Target.PDF' using PDFBox code, I was not able to do so.
> I used iText to set/change values of form-fields in 'Source_Target.PDF' and was successful. But we want to use only PDFBox.
> To summarize - We are not able to set/change values of form fields of a PDF Document whose form-fields have been renamed. There is no issue if the form-fields are renamed manually using Adobe Acrobat 9. The issue is only
> when the form-fields are renamed using PDFBox option - setPartialName(newFieldName);
> > Only to be sure, changing values in 'Source_Original.PDF'  works with the same code you use to 
> > manipulate 'Source_Target.PDF'??
> Yes
> I have attached the 2 files - "Source_Original.PDF' and 'Source_Target.PDF',
> ----- Code
> 				try
> 				{
> 					PDDocument pdfDocument = PDDocument.load(pdfSource);
> 					try
> 					{
> 						if (pdfDocument.isEncrypted())
> 						{
> 							pdfDocument.decrypt("");
> 						}
> 						PDDocumentCatalog docCatalog = pdfDocument.getDocumentCatalog();
> 						PDAcroForm acroForm = docCatalog.getAcroForm();
> 						if (acroForm != null)
> 						{
> 							List pdfFields = acroForm.getFields();
> 							if (pdfFields != null)
> 							{
> 								PDField pdfField;
> 								for (int i = 0; i < pdfFields.size(); i++)
> 								{
> 									pdfField = (PDField) pdfFields.get(i);
> 									String fieldName = pdfField.getPartialName();
> 									if( pdfFieldNames.containsKey(fieldName) ){
> 										String newFieldName = (String) pdfFieldNames.get(fieldName);
> 										pdfField.setPartialName(newFieldName);
> 									}
> 								}
> 								pdfDocument.save(pdfOutput);
> 							} else {
> 								return "No Acro Form Fields found in PDF Document " + pdfSource + "!";
> 							}
> 						} else {
> 							return "PDF document " + pdfSource + " not able to access!";
> 						}
> 					} catch (Exception e) {
> 						return "PDF Document " + pdfSource + " is encrypted! Cannot process.";
> 					}
> 					pdfDocument.close();
> 				} catch (Exception e) {
> 					return "PDF Document " + pdfSource + " cannot be found!";
> 				}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (PDFBOX-481) renaming a field and not able to set value to the saved PDF document ...

Posted by "Andreas Lehmkühler (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PDFBOX-481?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andreas Lehmkühler updated PDFBOX-481:
--------------------------------------

    Attachment: PDFBOX481-Source_Target_filled.pdf

I've filled some fields of the acroform using pdfbox. Due to an issue displaying this pdf you have to use some other viewer like acrobat

> renaming a field and not able to set value to the saved PDF document ...
> ------------------------------------------------------------------------
>
>                 Key: PDFBOX-481
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-481
>             Project: PDFBox
>          Issue Type: Bug
>          Components: PDModel.AcroForm
>    Affects Versions: 0.7.3
>         Environment: Windows XP Professional SP3, jre1.6.0_07/jdk1.6.0_11 , PDFBox-0.7.3.jar
>            Reporter: Venkatesh Prasad.B.K.
>             Fix For: 0.7.3
>
>         Attachments: PDFBOX481-Source_Target_filled.pdf, Source_Original.pdf, Source_Target.pdf
>
>
> I will explain what I want to do.
> 1. I have a PDF Document with Fields and let us call this 'Source_Original.PDF'. The field names in this PDF document have to be renamed and stored as 'Source_Target.PDF'. I then have to set/change the values of form-fields in 'Source_Target.PDF'.
> The issue I am facing is given below:
> 1. I renamed the form fields in 'Source_Original.PDF" using the code given in my earlier mail (below) and saved it as 'Source_Target.PDF'.
> 2. I checked the form fields in 'Source_Target.PDF" and form-fields were renamed correctly.
> 3. However when I tried to set/change values of form-fields in 'Source_Target.PDF' using PDFBox code, I was not able to do so.
> I used iText to set/change values of form-fields in 'Source_Target.PDF' and was successful. But we want to use only PDFBox.
> To summarize - We are not able to set/change values of form fields of a PDF Document whose form-fields have been renamed. There is no issue if the form-fields are renamed manually using Adobe Acrobat 9. The issue is only
> when the form-fields are renamed using PDFBox option - setPartialName(newFieldName);
> > Only to be sure, changing values in 'Source_Original.PDF'  works with the same code you use to 
> > manipulate 'Source_Target.PDF'??
> Yes
> I have attached the 2 files - "Source_Original.PDF' and 'Source_Target.PDF',
> ----- Code
> 				try
> 				{
> 					PDDocument pdfDocument = PDDocument.load(pdfSource);
> 					try
> 					{
> 						if (pdfDocument.isEncrypted())
> 						{
> 							pdfDocument.decrypt("");
> 						}
> 						PDDocumentCatalog docCatalog = pdfDocument.getDocumentCatalog();
> 						PDAcroForm acroForm = docCatalog.getAcroForm();
> 						if (acroForm != null)
> 						{
> 							List pdfFields = acroForm.getFields();
> 							if (pdfFields != null)
> 							{
> 								PDField pdfField;
> 								for (int i = 0; i < pdfFields.size(); i++)
> 								{
> 									pdfField = (PDField) pdfFields.get(i);
> 									String fieldName = pdfField.getPartialName();
> 									if( pdfFieldNames.containsKey(fieldName) ){
> 										String newFieldName = (String) pdfFieldNames.get(fieldName);
> 										pdfField.setPartialName(newFieldName);
> 									}
> 								}
> 								pdfDocument.save(pdfOutput);
> 							} else {
> 								return "No Acro Form Fields found in PDF Document " + pdfSource + "!";
> 							}
> 						} else {
> 							return "PDF document " + pdfSource + " not able to access!";
> 						}
> 					} catch (Exception e) {
> 						return "PDF Document " + pdfSource + " is encrypted! Cannot process.";
> 					}
> 					pdfDocument.close();
> 				} catch (Exception e) {
> 					return "PDF Document " + pdfSource + " cannot be found!";
> 				}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (PDFBOX-481) renaming a field and not able to set value to the saved PDF document ...

Posted by "Jukka Zitting (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PDFBOX-481?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jukka Zitting updated PDFBOX-481:
---------------------------------

    Fix Version/s:     (was: 0.7.3)

> renaming a field and not able to set value to the saved PDF document ...
> ------------------------------------------------------------------------
>
>                 Key: PDFBOX-481
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-481
>             Project: PDFBox
>          Issue Type: Bug
>          Components: PDModel.AcroForm
>    Affects Versions: 0.7.3
>         Environment: Windows XP Professional SP3, jre1.6.0_07/jdk1.6.0_11 , PDFBox-0.7.3.jar
>            Reporter: Venkatesh Prasad.B.K.
>         Attachments: PDFBOX481-Source_Target_filled.pdf, Source_Original.pdf, Source_Target.pdf
>
>
> I will explain what I want to do.
> 1. I have a PDF Document with Fields and let us call this 'Source_Original.PDF'. The field names in this PDF document have to be renamed and stored as 'Source_Target.PDF'. I then have to set/change the values of form-fields in 'Source_Target.PDF'.
> The issue I am facing is given below:
> 1. I renamed the form fields in 'Source_Original.PDF" using the code given in my earlier mail (below) and saved it as 'Source_Target.PDF'.
> 2. I checked the form fields in 'Source_Target.PDF" and form-fields were renamed correctly.
> 3. However when I tried to set/change values of form-fields in 'Source_Target.PDF' using PDFBox code, I was not able to do so.
> I used iText to set/change values of form-fields in 'Source_Target.PDF' and was successful. But we want to use only PDFBox.
> To summarize - We are not able to set/change values of form fields of a PDF Document whose form-fields have been renamed. There is no issue if the form-fields are renamed manually using Adobe Acrobat 9. The issue is only
> when the form-fields are renamed using PDFBox option - setPartialName(newFieldName);
> > Only to be sure, changing values in 'Source_Original.PDF'  works with the same code you use to 
> > manipulate 'Source_Target.PDF'??
> Yes
> I have attached the 2 files - "Source_Original.PDF' and 'Source_Target.PDF',
> ----- Code
> 				try
> 				{
> 					PDDocument pdfDocument = PDDocument.load(pdfSource);
> 					try
> 					{
> 						if (pdfDocument.isEncrypted())
> 						{
> 							pdfDocument.decrypt("");
> 						}
> 						PDDocumentCatalog docCatalog = pdfDocument.getDocumentCatalog();
> 						PDAcroForm acroForm = docCatalog.getAcroForm();
> 						if (acroForm != null)
> 						{
> 							List pdfFields = acroForm.getFields();
> 							if (pdfFields != null)
> 							{
> 								PDField pdfField;
> 								for (int i = 0; i < pdfFields.size(); i++)
> 								{
> 									pdfField = (PDField) pdfFields.get(i);
> 									String fieldName = pdfField.getPartialName();
> 									if( pdfFieldNames.containsKey(fieldName) ){
> 										String newFieldName = (String) pdfFieldNames.get(fieldName);
> 										pdfField.setPartialName(newFieldName);
> 									}
> 								}
> 								pdfDocument.save(pdfOutput);
> 							} else {
> 								return "No Acro Form Fields found in PDF Document " + pdfSource + "!";
> 							}
> 						} else {
> 							return "PDF document " + pdfSource + " not able to access!";
> 						}
> 					} catch (Exception e) {
> 						return "PDF Document " + pdfSource + " is encrypted! Cannot process.";
> 					}
> 					pdfDocument.close();
> 				} catch (Exception e) {
> 					return "PDF Document " + pdfSource + " cannot be found!";
> 				}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PDFBOX-481) renaming a field and not able to set value to the saved PDF document ...

Posted by "Andreas Lehmkühler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PDFBOX-481?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12717045#action_12717045 ] 

Andreas Lehmkühler commented on PDFBOX-481:
-------------------------------------------

I've tried to set several values in the Source_Target.pdf and it works fine. I'm using the trunk version of pdfbox but I guess 0.7.3. should work too.  But the problem is, pdfbox can't display the whole pdf with PDFReader because of some problems with the PDSeperation during setting the nonstroking color (see stacktrace). This issue doesn't depend on the modifications done to the acroform, the NPE already appears if you try to display Source_Original.pdf.

Jun 7, 2009 5:21:21 PM org.apache.pdfbox.util.PDFStreamEngine processOperator
WARNING: java.lang.NullPointerException
 at
org.apache.pdfbox.util.operator.SetNonStrokingSeparation.process(SetNonStrokingSeparation.java:51)
org.apache.pdfbox.util.operator.SetStrokingColor.process(SetStrokingColor.java:61)
org.apache.pdfbox.util.PDFStreamEngine.processOperator(PDFStreamEngine.java:500)
org.apache.pdfbox.util.PDFStreamEngine.processSubStream(PDFStreamEngine.java:220)
org.apache.pdfbox.util.PDFStreamEngine.processStream(PDFStreamEngine.java:179)
org.apache.pdfbox.pdfviewer.PageDrawer.drawPage(PageDrawer.java:90)
org.apache.pdfbox.pdfviewer.PDFPagePanel.paint(PDFPagePanel.java:76)



> renaming a field and not able to set value to the saved PDF document ...
> ------------------------------------------------------------------------
>
>                 Key: PDFBOX-481
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-481
>             Project: PDFBox
>          Issue Type: Bug
>          Components: PDModel.AcroForm
>    Affects Versions: 0.7.3
>         Environment: Windows XP Professional SP3, jre1.6.0_07/jdk1.6.0_11 , PDFBox-0.7.3.jar
>            Reporter: Venkatesh Prasad.B.K.
>             Fix For: 0.7.3
>
>         Attachments: Source_Original.pdf, Source_Target.pdf
>
>
> I will explain what I want to do.
> 1. I have a PDF Document with Fields and let us call this 'Source_Original.PDF'. The field names in this PDF document have to be renamed and stored as 'Source_Target.PDF'. I then have to set/change the values of form-fields in 'Source_Target.PDF'.
> The issue I am facing is given below:
> 1. I renamed the form fields in 'Source_Original.PDF" using the code given in my earlier mail (below) and saved it as 'Source_Target.PDF'.
> 2. I checked the form fields in 'Source_Target.PDF" and form-fields were renamed correctly.
> 3. However when I tried to set/change values of form-fields in 'Source_Target.PDF' using PDFBox code, I was not able to do so.
> I used iText to set/change values of form-fields in 'Source_Target.PDF' and was successful. But we want to use only PDFBox.
> To summarize - We are not able to set/change values of form fields of a PDF Document whose form-fields have been renamed. There is no issue if the form-fields are renamed manually using Adobe Acrobat 9. The issue is only
> when the form-fields are renamed using PDFBox option - setPartialName(newFieldName);
> > Only to be sure, changing values in 'Source_Original.PDF'  works with the same code you use to 
> > manipulate 'Source_Target.PDF'??
> Yes
> I have attached the 2 files - "Source_Original.PDF' and 'Source_Target.PDF',
> ----- Code
> 				try
> 				{
> 					PDDocument pdfDocument = PDDocument.load(pdfSource);
> 					try
> 					{
> 						if (pdfDocument.isEncrypted())
> 						{
> 							pdfDocument.decrypt("");
> 						}
> 						PDDocumentCatalog docCatalog = pdfDocument.getDocumentCatalog();
> 						PDAcroForm acroForm = docCatalog.getAcroForm();
> 						if (acroForm != null)
> 						{
> 							List pdfFields = acroForm.getFields();
> 							if (pdfFields != null)
> 							{
> 								PDField pdfField;
> 								for (int i = 0; i < pdfFields.size(); i++)
> 								{
> 									pdfField = (PDField) pdfFields.get(i);
> 									String fieldName = pdfField.getPartialName();
> 									if( pdfFieldNames.containsKey(fieldName) ){
> 										String newFieldName = (String) pdfFieldNames.get(fieldName);
> 										pdfField.setPartialName(newFieldName);
> 									}
> 								}
> 								pdfDocument.save(pdfOutput);
> 							} else {
> 								return "No Acro Form Fields found in PDF Document " + pdfSource + "!";
> 							}
> 						} else {
> 							return "PDF document " + pdfSource + " not able to access!";
> 						}
> 					} catch (Exception e) {
> 						return "PDF Document " + pdfSource + " is encrypted! Cannot process.";
> 					}
> 					pdfDocument.close();
> 				} catch (Exception e) {
> 					return "PDF Document " + pdfSource + " cannot be found!";
> 				}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.