cancel
Showing results for 
Search instead for 
Did you mean: 

Error in iWorkFlowScript

Michael_Kinnell
Champ on-the-rise
Champ on-the-rise

I have an iWorkFlowScript and I'm getting an error when I trigger it in a Workflow using the Run Unity Script action

Message: An error occurred within the Unity API: Page # 1 does not exist on document: Document: 1851070 Revision: 0 Rendition: 13

The script is trying to save a copy of the document with Notes to a network location

The exception is thrown at line 41

using (PageData pageData = pdfDataProvider.GetDocument(args.Document.DefaultRenditionOfLatestRevision, properties))

[embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:6bde07f5-6a9e-469e-8f96-d815ea977ec8:type=text&text=%2F%2F%20Skeleton%20generated%20by%20Hyland%20Unity%20Editor%20on%208%2F14%2F2017%202%3A59%3A48%20PM%0D%0Anamespace%20TestExportNoteValue%0D%0A%7B%0D%0A%20%20%20%20using%20System%3B%0D%0A%20%20%20%20using%20System.Text%3B%0D%0A%09using%20System.IO%3B%0D%0A%20%20%20%20using%20Hyland.Unity%3B%0D%0A%20%20%20%20using%20Hyland.Unity.CodeAnalysis%3B%0D%0A%20%20%20%20using%20Hyland.Unity.Workflow%3B%0D%0A%20%20%20%20%0D%0A%20%20%20%20%0D%0A%20%20%20%20%2F%2F%2F%20%3Csummary%3E%0D%0A%20%20%20%20%2F%2F%2F%20Export%20a%20note%20value%20as%20a%20PDF%20from%20the%20document%20ID%20passed%20in%20by%20the%20WorkFlow%2C%20File%20exported%20to%20Filename%20and%20FilePath%20passed%20in%20the%20PropretyBag%20%0D%0A%20%20%20%20%2F%2F%2F%20%3C%2Fsummary%3E%0D%0A%20%20%20%20public%20class%20TestExportNoteValue%20%3A%20Hyland.Unity.IWorkflowScript%0D%0A%20%20%20%20%7B%0D%0A%20%20%20%20%23region%20IWorkflowScript%0D%0A%20%20%20%20%20%20%20%20%2F%2F%2F%20%3Csummary%3E%0D%0A%20%20%20%20%20%20%20%20%2F%2F%2F%20Implementation%20of%20%3Csee%20cref%3D%22IWorkflowScript.OnWorkflowScriptExecute%22%20%2F%3E.%0D%0A%20%20%20%20%20%20%20%20%2F%2F%2F%20%3Cseealso%20cref%3D%22IWorkflowScript%22%20%2F%3E%0D%0A%20%20%20%20%20%20%20%20%2F%2F%2F%20%3C%2Fsummary%3E%0D%0A%20%20%20%20%20%20%20%20%2F%2F%2F%20%3Cparam%20name%3D%22app%22%3E%3C%2Fparam%3E%0D%0A%20%20%20%20%20%20%20%20%2F%2F%2F%20%3Cparam%20name%3D%22args%22%3E%3C%2Fparam%3E%0D%0A%20%20%20%20%20%20%20%20public%20void%20OnWorkflowScriptExecute%28Hyland.Unity.Application%20app%2C%20Hyland.Unity.WorkflowEventArgs%20args%29%0D%0A%09%09%7B%0D%0A%20%20%20%20%20%20%20%20%09string%20FileName%20%3D%22%20%22%3B%0D%0A%20%20%20%20%20%20%20%20%09string%20FilePath%20%3D%22%20%22%3B%0D%0A%09%09%09PropertyBag%20propertyBag%20%3D%20args.SessionPropertyBag%3B%0D%0A%09%09%09propertyBag.TryGetValue%28%22FileName%22%2Cout%20FileName%29%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20propertyBag.TryGetValue%28%22FilePath%22%2Cout%20FilePath%29%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20PDFDataProvider%20pdfDataProvider%20%3D%20app.Core.Retrieval.PDF%3B%0D%0A%09%20%20%20%20%09PDFGetDocumentProperties%20properties%20%3D%20pdfDataProvider.CreatePDFGetDocumentProperties%28%29%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%09properties.CompressionQuality%20%3D%20100%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%09properties.Overlay%20%3D%20true%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%09if%20%28properties.Overlay%29%0D%0A%20%20%20%09%20%20%20%20%20%20%20%20%09properties.OverlayAllPages%20%3D%20true%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%09PageRangeSet%20pageRange%20%3D%20pdfDataProvider.CreatePageRangeSet%28%221%20-%203%22%29%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%09properties.PageRanges%20%3D%20pageRange%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%09properties.RenderNoteText%20%3D%20true%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%09properties.RenderNoteAnnotations%20%3D%20true%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%09using%20%28PageData%20pageData%20%3D%20pdfDataProvider.GetDocument%28args.Document.DefaultRenditionOfLatestRevision%2C%20properties%29%29%0D%0A%20%20%20%20%20%20%20%20%20%20%20%09%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%09using%20%28Stream%20stream%20%3D%20pageData.Stream%29%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%09%7B%0D%0A%20%20%09%20%20%20%20%20%20%20%20%20%20%20%20%20%09Utility.WriteStreamToFile%28stream%2C%20%40FilePath%2BFileName%2B%22.pdf%22%29%3B%0D%0A%20%20%20%20%09%20%20%20%20%20%20%20%09%7D%0D%0A%20%20%20%20%20%20%20%20%20%20%20%09%7D%0D%0A%09%09%7D%20%20%20%20%0D%0A%09%23endregion%0D%0A%20%20%20%20%7D%0D%0A%7D]

1 ACCEPTED ANSWER

Michael_Kinnell
Champ on-the-rise
Champ on-the-rise

Solved it!

The  "PDFDataProvider.GetDocument Method (Rendition, PDFGetDocumentProperties)" page in the SDK had this remark"

"This method does not support the PageRange property off of PDFGetDocumentProperties for PDF documents; it will return the full PDF document regardless."

I removed lines 37 & 38 and all is well

[emoticon:c4563cd7d5574777a71c318021cbbcc8]

View answer in original post

1 REPLY 1

Michael_Kinnell
Champ on-the-rise
Champ on-the-rise

Solved it!

The  "PDFDataProvider.GetDocument Method (Rendition, PDFGetDocumentProperties)" page in the SDK had this remark"

"This method does not support the PageRange property off of PDFGetDocumentProperties for PDF documents; it will return the full PDF document regardless."

I removed lines 37 & 38 and all is well

[emoticon:c4563cd7d5574777a71c318021cbbcc8]