SaveAsPDF control errors with "The PDF could not be saved"after upgrading from K2 Blackpearl 4.7 to K2 5.1

  • 15 February 2022
  • 0 replies

Userlevel 5
Badge +19

SaveAsPDF control errors with "The PDF could not be saved"after upgrading from K2 Blackpearl 4.7 to K2 5.1


K2 Five 5.1
K2 Five 5.1
This article was created in response to a support issue logged with K2. The content may include typographical errors and may be revised at any time without notice. This article is not considered official documentation for K2 software and is provided "as is" with no warranties.
This article has been archived, and/or refers to legacy products, components or features. The content in this article is offered "as is" and will no longer be updated. Archived content is provided for reference purposes only. This content does not infer that the product, component or feature is supported, or that the product, component or feature will continue to function as described herein.


After an upgrade from 4.7 to 5.1, when you are attempting to run the Save As PDF control's Save As PDF or Save as PDF Async method on a SmartForm, you will get the error below and the PDF is not created:


The PDF could not be saved.
Key could not be found in the collection.
Method Base
Member Type:
Scope Name:
Declaring Type
Full Name:
Stack Trace:

at SourceCode.Forms.Controls.Web.SaveAsPDFRequest.ExecuteSaveAsPDFMethod(SaveAsPDFRequest request)

at SourceCode.Forms.Controls.Web.SaveAsPDFHandler.ProcessRequest(HttpContext context)


  • This same form design worked before the upgrade on K2 Blackpearl 4.7.
  • All forms/views with the Save as PDF control will exhibit this behavior. Creating a new form/view does not show any different behavior.
  • Running the PDFConverter SmartObject outside of a form/view (i.e. in the SmartObject Tester Tool or K2 Management Site) will properly create a PDF.
  • You will note that the PDF Converter SmartObject's Properties do not match that of the Service Object:




Troubleshooting Steps

This behavior is due to the fact that the SmartObject backing the SaveAsPDF Control was not properly refreshed during the upgrade process to K2 Five. This SmartObject is named PDFConverter. In K2 Five we added 4 new properties to this SmartObject for Left Margin, Right Margin, Top Margin, Bottom Margin.

Steps to Resolve:

1. Open the SmartObject Tester tool ("C:Program Files (x86)K2 blackpearlBinSmartObject Service Tester.exe")
2. Expand ServiceObject Explorer > PDF Converter Service instance > PDF Converter Service Object. Right-click on the Service Object and select create SmartObject.
3. On this window, click the Get Existing GUID button. The GUID should be:


4. In the Category box, add the path to the PDFConverter SmartObject which is:

SystemControlsSave as PDF

5. Click Publish SmartObject. Click yes to overwriting the SmartObject.
6. Go to the SmartObject and confirm that the SmartObject now shows the 4 Margin Properties (Left, Right, Top, Bottom) on the properties and methods.
7. Test the form behavior by saving a PDF. The error should now be gone and the PDF will be created as expected.

0 replies

Be the first to reply!