Notice: This has been fixed in Laserfiche 11. Please upgrade if you are experiencing issues.
TL;DR: (Updated)
PDFs generated by the latest version of the PDFKit.NET library (used by contract generation platforms like DocuSign) generate files that are incompatible with LF10's PDFViewNET library (e.g. the part that generates text/pages upon import). A workaround is posted a few posts below (turn off generate pages/text on import). Alternatively, upgrade to LF11 when it is released later this month. According to LF due to the complexity of updating the PDFViewNET library, a LF10 hotfix will not be produced for this issue.
Original Issue/Post Below
We have identified that some PDFs generated by a recent (December 2020) backend update by the cloud service DocuSign is causing the Laserfiche Forms "Save to Repository" function to fail with a non-descript "502 Unexpected Error".
As the error-causing files are viewable without any visible errors or issues in Adobe Acrobat (and Pro), we believe there is some kind of corruption at the XML level which Laserfiche's save to repository function is tripping up on.
We are unsure why these PDFs are causing the process to fail, however, manually opening and reprinting these files (via Print to PDF in Adobe Acrobat) and re-uploading them to the Forms process will allow it to save to the repository without failing. We've tried to pinpoint which version of PDFKit DocuSign are using to create the PDFs but we cannot seem to discern any logic as to why some document packages are corrupted while others are not.
The current work arounds are as follows: (see a later post for permanent workaround)
1) In DocuSign download the document "package". Open each PDF individually (e.g. the contract, the cover letter etc) and print it by using the Print to Adobe PDF option. Note, the corruption stops you from saving the PDF as other PDF formats e.g. PDF-A etc, hence needing to virtually print the documents. Once you have 'reprinted' each of the files, upload them to your forms process and retry the Save to Repository task. It should now work.
2) Alternatively, in DocuSign, if your package contains multiple documents, use the "Combine Documents" function to force DocuSign to regenerate all of the documents as a single combined document using "todays" build of their PDF generator (in case they update their SDK). We don't know why, but regenerating and combining seems to fix XML corruption. This isn't ideal because we then have to dissect the documents into individual files manually in Adobe Acrobat Pro as to attach the contract, cover letter, proposal etc to the various fields within the contract management process.
So what is being done about it?
We have reported this issue to Laserfiche Support and they were able to reproduce the error. They have advised the SDK used by Snapshot will be updated in Laserfiche 11 released later this month. Specifically their resolution for our support ticket was initially: "Known issue in bug 172178. Will be fixed in Laserfiche 11 with PDFViee4NET 6.1.2.11."
As this issue is affecting our users in production, and the problem is growing, we have requested a hotfix. If this issue crops up for you in any business critical capacity, be sure to reach out to Laserfiche support for assistance.
I am posting this to answers so that others are aware of this very frustrating issue and so that they can use the above workarounds in the meantime (saving themselves many hours of investigation).
Has anyone else encountered this issue with PDFs or DocuSign and the Save to Repository Task in Laserfiche Forms? Please share your story if you have.
To help with others searching for this error, a copy of the error from forms is below:
Stack Trace:
Caught exception: Laserfiche.Forms.CommonUtils.Exceptions.LFFormsException
Message: An error occurred during the execution of the Save to Repository service task. [LFF5426-ErrorExecuteSTR]
at Laserfiche.Forms.Routing.SaveToLaserficheService.Execute(Int32 instanceId, IRoutingContext routingContext, RoutingInstanceStatus OriginalStatus)
at Laserfiche.Forms.Routing.ServiceTask.Execute(Int32 instanceId, IRoutingContext routingContext)
Inner exception: System.NullReferenceException
Message: Object reference not set to an instance of an object.
at Laserfiche.PdfServices.PdfExtractor.LoadFile(Stream pdfStream)
at Laserfiche.PdfServices.PdfExtractor.ImportPDFPagesFromStream(Stream pdfStream, DocumentInfo doc)
at Laserfiche.PdfServices.PdfExtractor.ImportPDFStream(Stream pdfStream, DocumentInfo doc, DateTime dtLastModified)
at Laserfiche.Forms.CommonUtils.LFHelper.TryImportAttachment(Session sess, cf_bp_attachment_data attachment, FolderInfo parentFolder, String volume, String attachmentName, String ext)
at FormsModel.RoutingModels.Services.SaveFormToLaserficheStrategy.SaveAttachmentToLaserfiche(Session session, XmlDocument datasetXml, STLConfigurationObj conf, DocumentInfo rootddoc, String timeZone, String rootFolderPath)
at FormsModel.RoutingModels.Services.SaveFormToLaserficheStrategy.SaveToLaserfiche(Session session, XmlDocument datasetXml, List`1 STLConfigList, SaveToLaserficheParameters saveToLaserficheParameters)
at FormsModel.RoutingModels.Services.SaveToLaserficheHelper.OpenSessionAndSave(IEntityContext _AppContext, Int32 STLRepositoryId, List`1 STLConfigList, XmlDocument datasetXml, ISaveToLaserficheStrategy saveToLaserficheStrategy, String timeZone)
at FormsModel.RoutingModels.Services.SaveToLaserficheHelper.SaveToLaserfiche(IEntityContext _AppContext, Int32 STLRepositoryId, List`1 STLConfigList, XmlDocument datasetXml, ISaveToLaserficheStrategy saveToLaserficheStrategy, String timeZone)
at Laserfiche.Forms.Routing.SaveToLaserficheService.Execute(Int32 instanceId, IRoutingContext routingContext, RoutingInstanceStatus OriginalStatus)