Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Wed Aug 23, 2023 8:35 pm

I recently updated my project to the latest version of Spire.PDF of version 9.8.5, my web code was using SaveToHttpResponse, but after updating and using .Net 4.8 build, it states that the SaveToHttpResponse doesn't exist, so it broke my project. I then tried to use SaveToStream with the following code, reportid is just a converted GUID.
Code: Select all
try
{
  Response.Clear();
  Response.ContentType = "application/pdf";
  Response.AddHeader("content-disposition", "attachment;filename=" + reportid + ".pdf");
  newDoc.SaveToStream(Response.OutputStream, FileFormat.PDF);
  Response.Flush();
  Response.End();
}
catch (Exception ex)
{
  Response.Write(ex.Message);
}


Nothing happens but an error, I have emailed support today the full method for review, but honestly I just want SaveToHttpResponse back.

JonathanWood
 
Posts: 26
Joined: Fri Feb 26, 2016 2:19 am

Thu Aug 24, 2023 9:03 am

Hi Jonathan,

Thanks for your inquiry.
Due to significant limitations caused by updates on different platforms, the SaveToHttpResponse method that we previously encapsulated has been removed. We apologize for any inconvenience this may have caused you.

We now recommend that customers design such a method based on their specific use cases, for example, something like the following code snippet. Hope you can understand.

Code: Select all
response.ClearContent();
MemoryStream ms = new MemoryStream();
newDoc.SaveToStream(ms, FileFormat.PDF);
ms.Position = 0;
response.Clear();
response.AddHeader("Content-Disposition", String.Format("attachment; filename=\"{0}.{1}\"", fileName, extension));
response.AppendHeader("Content-Length", ms.ToArray().Length.ToString());
response.ContentType = "application/pdf";
response.BinaryWrite(ms.ToArray());
HttpContext.Current.ApplicationInstance.CompleteRequest();
response.Flush();
response.End();
ms.Close();


Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 3043
Joined: Wed Jun 27, 2012 8:50 am

Thu Aug 24, 2023 2:43 pm

Thank you for the update, however, deprecation of a method puts those who used it at a disadvantage, replacing the method source with the recommended source would have been a better solution in this case, so that the method in use didn't break. This is the same with with regards to the License method, originally, the License method to set the license, which is also on the License page was as follows:

Spire.License.LicenseProvider.SetLicenseKey(“mykey”);
Spire.License.LicenseProvider.LoadLicense();

This is also deprecated, and no longer exists as a functional way of setting licenses per product line, the new way to do it is based on the product line that is purchased, in our instance we own Spire.PDF and Spire.XLS but do not own Spire.Office or Spire.Doc, as such in all cases we now have to use:

Spire.PDF.License.LicenseProvider.SetLicenseKey(“mykey”);
Spire.PDF.License.LicenseProvider.LoadLicense();

Spire.Xls.License.LicenseProvider.SetLicenseKey(“mykey”);
Spire.Xls.License.LicenseProvider.LoadLicense();

Because the developers removed Spire.License.LicenseProvider, it literally no longer exists and the web documentation on the license section doesn't cover this change, not as of 8/24/23.

A recommendation would be to keep the current methods and have them work with any new recommendations, but not delete them, but create new ones to recommend as a replacement, but not remove what works for users of the libraries.

This is breaking backward compatibility on product lines, and we can't keep up with the loss of no backward compatibility methods.

JonathanWood
 
Posts: 26
Joined: Fri Feb 26, 2016 2:19 am

Fri Aug 25, 2023 7:40 am

Dear Jonathan,

Thank you for expressing your concerns regarding the deprecation of certain methods and the impact it has on users. We understand that this change has caused inconvenience for you, and we apologize for any difficulties you have faced.

We will soon update our webpage https://www.e-iceblue.com/Tutorials/Licensing/Licensing.html#Apply_two_Licenses to reflect these changes for applying licenses.

Regarding SaveToHttpResponse method, I have communicated with the developers, and due to various considerations, I apologize that this method cannot be synchronized into the new version anymore. We will consider your suggestions for making adjustments to future methods.

If you have any further questions or require assistance, please don't hesitate to reach out to us.

Once again, we apologize for any inconvenience caused and appreciate your understanding.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 3043
Joined: Wed Jun 27, 2012 8:50 am

Fri Aug 25, 2023 1:52 pm

Thanks again for your consideration as to how to update methods.
It is best practice that if you're going to deprecate a method with a new one, you mark it as deprecated but leave it in the source and note on the deprecated version that it is no longer supported and give the name of the new method that replaces it, this is across the entire library. We, as users of the library's, rely on what you have written to stay backward compatible, if we put in a new build and it no longer contains a method that we used, it will kill our ability to build our project that was working prior to the change of whatever method is changed.

This is for all product lines, let's assume you change how to change the font size and move the method into a sub class, but our code is using the original class/method pair, and then all of a sudden it breaks because we update our libraries to the latest build, with no idea how to fix that particular problem since the support/documentation is based on the old way to do something and no idea the new way to do it, it becomes a nightmare to maintain, so please have the developers take into account backward compatibility, it is very important.

Thanks again for your help.

JonathanWood
 
Posts: 26
Joined: Fri Feb 26, 2016 2:19 am

Mon Aug 28, 2023 8:58 am

Hi Jonathan,

Sorry for the delay response as the different time zones.

Thank you for your input and concerns regarding backward compatibility. It's indeed a best practice to mark deprecated methods and provide clear documentation on the new method that replaces it. Backward compatibility is crucial for maintaining the functionality of existing projects when updating libraries.
I will relay it to every department in our development team.

Thanks again.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 3043
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.PDF

cron