Saving Aspose.Pdf.Facade.Form.Save(Response.OutputStream) not supported

I am trying to save form output to HttpResponse.OutputStream.

But I am getting “Specified Method is not supported” exception. (Refer to the attachment)

I am in process of converting old Aspose.Pdf.Kit to new Aspose.Pdf release on 4/1/2014.
I was able to save to the Response.OutputStream when I was using PDF Kit but the Aspose.Pdf.Facade.Form method doesn’t allow me to save. Is this a bug? And is there a workaround to this problem?

Thanks,

Here is the code.

public void FillTemplate(string pdfTemplate)
{
string fname = Guid.NewGuid().ToString();
string fname1 = fname + “_1.pdf”;
fname = fname + “.pdf”;

string srcFile = Path.Combine(_context.Request.PhysicalApplicationPath,
string.Format(@"{0}{1}", TempOutput, fname1));
string destFile = Path.Combine(_context.Request.PhysicalApplicationPath,
string.Format(@"{0}{1}", TempOutput, fname));

if (!Directory.Exists(Path.GetDirectoryName(srcFile)))
Directory.CreateDirectory(Path.GetDirectoryName(srcFile));

var pdfFileStamp = new PdfFileStamp(pdfTemplate, srcFile);
AddWLNumberToFooters(pdfFileStamp);

var clientCore = new ClientCore(_queryArg.UserSession.GetConnectionString(), _queryArg.ClientId);
var core = new HILFSCore(_queryArg.UserSession.GetConnectionString(), _queryArg.Login);
var sheet = core.FormGet(clientCore.GetSheetIdForClient());

var srcDoc = new Document(srcFile);
var formEditor = new FormEditor(srcDoc) { Facade = new FormFieldFacade { FontSize = 8F } };
bool shouldLockForm = sheet.DataEntryCompleted.HasValue;
AddSubmitButtons(formEditor, new PdfFileInfo(srcFile).Document.Pages.Count, shouldLockForm);
LockGeneralInfo(formEditor, new HILFSGeneralInfo());
formEditor.Save(destFile);

//formEditor = new Kit.FormEditor(new FileStream(destFile, FileMode.Open), _context.Response.OutputStream)
// { Facade = new Kit.FormFieldFacade { FontSize = 8F } };
var form = new Form(destFile);
FillForm(form, sheet);
if (sheet.DataEntryCompleted != null)
LockForm(form);

//formEditor.Save(destFile);
//formEditor.Save();
form.Save(_context.Response.OutputStream);
}

We have a licence and support for the latest Apose products (Aspose.Total).

I found a workaround.

I am now using Document object to save the PDF instead of Form.

document.Save(_context.Response, “output.pdf”, ContentDisposition.Inline, new PdfSaveOptions());

It works.

Hi,


Thanks for contacting support.

I have tried replicating the issue using code snippet which you have shared above I am unable to execute the code because there are lots of custom variables inside it. However, I have simplified the code and when using latest release of Aspose.Pdf for .NET 9.1.0, I am unable to notice any problem. Can you please share some sample application which can help us in replicating this issue at our end. We are sorry for this inconvenience.

[C#]

string fname = Guid.NewGuid().ToString();<o:p></o:p>

string fname1 = fname + "_1.pdf";

fname = fname + ".pdf";

var pdfFileStamp = new PdfFileStamp();

pdfFileStamp.BindPdf("c:/pdftest/FFATT.pdf");

MemoryStream stream = new MemoryStream();

pdfFileStamp.Save(stream);

var srcDoc = new Document(stream);

var formEditor = new FormEditor(srcDoc) { Facade = new FormFieldFacade { FontSize = 8F } };

MemoryStream stream2 = new MemoryStream();

formEditor.Save(stream2);

var form = new Form(stream2);

MemoryStream finalStream = new MemoryStream();

form.Save(finalStream);

Response.Clear();

Response.ClearHeaders();

Response.ClearContent();

Response.Charset = "UTF-8";

Response.AddHeader("Content-Length", finalStream.Length.ToString());

Response.AddHeader("content-disposition", "inline; filename=" + "CreditApp.pdf");

Response.ContentType = "application/pdf";

Response.BinaryWrite(finalStream.ToArray());

Response.Flush();

Response.End();

dance2die:
I found a workaround.
I am now using Document object to save the PDF instead of Form.

document.Save(_context.Response, "output.pdf", ContentDisposition.Inline, new PdfSaveOptions());

It works.
Hi,

We are glad to hear that your problem is resolved while using Document class. Please continue using our API and in the event of any further query, please feel free to contact.