We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Getting PDF from database

We are currently using the free 30 day trial of Aspose.PDF. I am using a template pdf to fill in some information and then save it to our database. Our goal is to be able to retrieve tis document from the database once it has be prefilled with information. I am not getting errors when creating and filling the form with aspose. I’m also able to save the file the issue comes with retrieving the file from the database. Whenever i try and get the file as a pdf from the database by converting the byte array into a file the pdf opens with an error saying “Failed to load pdf document”

var templateBytes = Documents.Resources.ResourceManager.GetObject(“FILE”) as byte[];
var memoryStream = new MemoryStream(templateBytes);

Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(memoryStream);

TextBoxField textBoxField15 = pdfDocument.Form[“undefined”] as TextBoxField;
TextBoxField textBoxField16 = pdfDocument.Form[“undefined_2”] as TextBoxField;
TextBoxField textBoxField17 = pdfDocument.Form[“undefined_3”] as TextBoxField;

textBoxField15.Value = “111111”;
textBoxField16.Value = “222222”;
textBoxField17.Value = “333333”;

pdfDocument.Save(stream, Aspose.Pdf.SaveFormat.Pdf);

This is how I’m saving/filling the file before saving to the database. We then save it by turning the stream into a byte array and saving that array to our database. Am I missing something is the save process?


Could you please read the PDF from database and save it to disk and try to open it using PDF viewer? If it does not open at your end, it may be possible the saved stream into database is corrupted. If this is the case, you can save the same stream to disk to check it.

If you still face problem, please attach the following resources here for testing:

  • Your input PDF document.
  • Please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.