SaveAsPDF control errors with "The PDF could not be saved"after upgrading from K2 Blackpearl 4.7 to K2 5.1
kbt156137
PRODUCTIssue
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:
Type:
System.Collections.Generic.KeyNotFoundException
Message:
Key could not be found in the collection.
Source:
SourceCode.Forms.Controls.Web
Method Base
Member Type:
Method
Name:
ExecuteSaveAsPDFMethod
Module
Scope Name:
SourceCode.Forms.Controls.Web.dll
Declaring Type
Full Name:
SourceCode.Forms.Controls.Web.SaveAsPDFRequest
Stack Trace:
at SourceCode.Forms.Controls.Web.SaveAsPDFRequest.ExecuteSaveAsPDFMethod(SaveAsPDFRequest request)
at SourceCode.Forms.Controls.Web.SaveAsPDFHandler.ProcessRequest(HttpContext context)
Symptoms
- 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
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:
9b44fced-4d51-4b7a-962a-2c95c415d5a0
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.