PDFsharp & MigraDoc Foundation https://forum.pdfsharp.net/ |
|
A PDF name must start with a slash (/). https://forum.pdfsharp.net/viewtopic.php?f=2&t=1601 |
Page 1 of 1 |
Author: | npc [ Tue Mar 29, 2011 3:20 pm ] |
Post subject: | A PDF name must start with a slash (/). |
I am following some sample code to fill out an AcroForm and get "A PDF name must start with a slash (/)" Here is my code that was taken from the sample code (the sample throws the same error too) using System; using PdfSharp.Pdf; using PdfSharp.Pdf.AcroForms; using PdfSharp.Pdf.IO; Code: namespace Sandbox.PDFSharp { public partial class Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string filePath = @"H:\Projects\Sandbox\Sandbox\PDFSharp\template_5.pdf"; // Open the template PdfDocument template = PdfReader.Open(filePath, PdfDocumentOpenMode.Modify); // Get the root object of all interactive form fields PdfAcroForm form = template.AcroForm; // Get all form fields of the whole document PdfAcroField.PdfAcroFieldCollection fields = form.Fields; // Get all form fields of the whole document string[] names = fields.Names; names = fields.DescendantNames; // Fill some value in each field for (int i = 0; i < names.Length; i++) { string fqName = names[i]; PdfAcroField field = fields[fqName]; PdfTextField txtField; if ((txtField = field as PdfTextField) != null) txtField.Text = "Hello"; } PdfDocument newDocument = new PdfDocument(); // Save the document... const string filename = @"H:\Projects\Sandbox\Sandbox\PDFSharp\newDocument.pdf"; newDocument.Save(filename); } } } It fails on names = fields.DescendantNames; with "A PDF name must start with a slash (/)." Any ideas on what is wrong? Thanks! Neil |
Author: | tim.kruger [ Fri Oct 05, 2012 11:08 am ] |
Post subject: | Re: A PDF name must start with a slash (/). |
Hi npc I know it's a while since you posted your question, but I found if I commented out names = fields.DescendantNames; on line 91 of the FillFormFields.Program.cs file it seamed to work. Not too sure what that code was meant to do though. Kind Regards, Timothy Kruger |
Author: | dock4400 [ Sun Jan 25, 2015 4:01 am ] |
Post subject: | Re: A PDF name must start with a slash (/). |
yeah, the problem is it doesn't work. I looked into it a bit and found that if there are no DescendantNames then it blows chunks with a message that makes no sense. Considering I found this in the latest greatest 1.32ver in 2015 and you posted 2011 makes me wonder how it ever gets in the the "samples" folder. FYI, don't bother trying the PDFviewerdemo sample either. It uses a namespace that doesn't exist. |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |