BoldSignEasily embed eSignatures in your .NET applications. Free sandbox with native SDK available.
publicstaticStreamCreateAndOpenPdfWithFormFieldValues(TypereferenceType,stringembeddedResourcePath,stringfilename,Dictionary<String,string> values =null,boolopenAfterCreate =false)
{
try
{
StreamdocStream = referenceType.GetTypeInfo().Assembly.GetManifestResourceStream(embeddedResourcePath);
vardocument =newPdfLoadedDocument(docStream);
PdfLoadedFormloadedForm = document.Form;
if(values !=null)
{
foreach(varfieldinloadedForm.Fields.OfType<PdfLoadedTextBoxField>())
{
if(!values.ContainsKey(field.Name))continue;
field.Text = values[field.Name] ??string.Empty;
}
}
MemoryStreamstream =newMemoryStream();
document.Save(stream);
document.Close(true);
if(openAfterCreate)
{
Xamarin.Forms.DependencyService.Get<ISaveFile>().Save(filename,"application/pdf", stream);
}
returnstream;
}
catch(Exceptionex)
{
}
}
publicstaticStreamMergePdfDocuments(IEnumerable<Stream> docStreams,stringfileName,boolopenAfterCreate =false)
{
PdfDocumentmergedDocument =newPdfDocument();
foreach(vardocStreamindocStreams)
{
vardocument =newPdfLoadedDocument(docStream);
PdfDocument.Merge(mergedDocument, document);
}
MemoryStreamstream =newMemoryStream();
mergedDocument.Save(stream);
mergedDocument.Close(true);
if(openAfterCreate)
{
Xamarin.Forms.DependencyService.Get<ISaveFile>().Save(fileName,"application/pdf", stream);
}
returnstream;
}
Thanks for reply Sowmiya. It was only displaying issue. I was viewing created pdf with Microsoft Edge. I installed Adobe PDF viewer. Now everytihng is perfect.