Hello,
I just upgraded from Merger v4.0 to v5.0 and noticed that I had to rewrite some code for appending merge documents and my code for setting a form field is no longer working.
For the append:
In V4.0 this used to work:
mdPDF = new MergeDocument();
introductionPDF = new MergeDocument(Server.MapPath("~") + "\\DocumentGenerators\\AssociatedDocuments\\FormularyDirectory\\Introduction_Closed_2009.pdf");
mdPDF.Append(coverPagePDF);
But in V5.0 I cannot append a MergeDocument to another MergeDocument?
For the form field:
This worked in v4.0
introductionPDF.Form.Fields["txtCurrentAsOf"].Value = DateTime.Now.ToString("MM/dd/yyyy");
But now there is no ".Value" option of the fields?
How do I do this in v5.0 of the Merger?
Thanks!
Matt L.
Where did Form.Field.Value and MergeDocument.Append(MergeDocument) Go in V5.0?
Re: Where did Form.Field.Value and MergeDocument.Append(MergeDocument) Go in V5.0?
Forum member · Aug 29, 2008Please note that I have a misspelling in my code above, the actual code is correct (coverPagePDF should be introductionPDF)... just messed up on the copy/paste.
Thanks!
Matt L.
Re: Where did Form.Field.Value and MergeDocument.Append(MergeDocument) Go in V5.0?
Forum member · Aug 29, 2008Okay, I found the issue. The .Value option is available on objects of type MergeDocument. I had to change my code to make the introductionPDF a PdfDocument object in order to append to my main MergeDocument. In doing this, I removed the .Value option from use.
Do you have a workaround?
I need to be able to merge multiple documents together and I had previously merged multiple MergeDocument objects. Now however, it seems as though I can't do this anymore but I need the MergeDocument form field functionality.
Any ideas?
Thanks!
Matt L.
Re: Where did Form.Field.Value and MergeDocument.Append(MergeDocument) Go in V5.0?
Support · Aug 29, 2008Hello Matt,
You can append PDF documents using the Append method of the MergeDocument object. Below is the sample code:
MergeDocument document = new MergeDocument("DocA.pdf");
document.Append("DocB.pdf");
Document.Form.Fields["FieldName"].Value = "Hello";
Document.DrawToWeb();
Thanks,
ceTe Software Support Team
Re: Where did Form.Field.Value and MergeDocument.Append(MergeDocument) Go in V5.0?
Forum member · Aug 29, 2008I tried that but it would not let me append a MergeDocument object to another MergeDocument. For example, this was my code:
MergeDocument mainDoc;
MergeDocument docToAppend;
mainDoc = new MergeDocument();
docToAppend = new MergeDocument("C:\Test.pdf");
mainDoc.Append(docToAppend); <-- Gives me an error
What I ended up doing was creating a memory stream from my MergeDocuments, then creating PdfDocument objects from the streams, then appending them to the main MergeDocument and everything works well.
Thanks!
Matt L.
Re: Where did Form.Field.Value and MergeDocument.Append(MergeDocument) Go in V5.0?
Support · Aug 29, 2008Hello Matt,
Yes in v5.0 you can no longer use the Append method that takes another MergeDocument. However you can append s many PDF documents as you like using the Append method and passing in th file path.
Thanks,
ceTe Software Support Team