cancel
Showing results for 
Search instead for 
Did you mean: 

Aspose PDF for .NET

Gerald_Granath
Star Contributor
Star Contributor

Does anyone have experience using Aspose PDF for .NET? I have been unable to successfully import the Aspose.PDF.dll as an assembly for use in a Scheduled Unity Script without encountering an Exception

 

"System.NullReferenceException: Object reference not set to an instance of an object.

at Hyland.Unity.Configuration.ServiceAccess.ImportAssembly(CompiledAssembly assembly, AssemblyType type, String displayName, String description, List`1 references)"

 

or a complaint about not being able to load Aspose.Imaging depending on which version I attempt to impoer.

 

The reason I'm exploring using Aspose PDF is I have been unable to create a new PDF document from an existing one using the Unity API. When I use:

 

long startPg = 1;

long endPg = lastPageStatement;

pagesRange.AddRange(startPg, endPg);

 

using (PageDataList pageDataPages = pdfDataProvider.GetPages(commissionsDocRendition, pagesRange))

{

newMnthlyStatementDoc = app.Core.Storage.StoreNewDocument(pageDataPages, storeMnthlyStatementDocumentProperties);

app.Diagnostics.Write("New Monthly Statement Doc ID: {0}", newMnthlyStatementDoc.ID.ToString());

}

 

a new PDF document is stored but it only has one page from the original document even though pagesRange specifies a range of pages.

 

With Aspose PDF for .NET I'm able to successfully create new PDFs from a range of pages.

 

OnBase 22.1.6.1000

Aspose PDF for .NET (I've tried versions 23.8, 23.7, 22.1, 21.8, 21.5, 21.4, 20.12)

7 REPLIES 7

Chris_Boultingh
Confirmed Champ
Confirmed Champ

I can't help with your actual error, but you might explore using the iText library instead. I've been using it for a couple of years now to handle PDF file creation via the Unity API.

I've been trying to import various assemblies to get iText7. Could you share how you were able to do so? I used nuGet to get the package and found the dll, then tried that and failed.

Joseph_Artuso
Confirmed Champ
Confirmed Champ

You shouldn't have to specify the pages, unless you only want to extract certain pages from the original document. Try using GetDocument instead of GetPages:

 

public static void CopyDocument(long docId){    var app = ConnectToOnBase();    var storage = app.Core.Storage;    // get the doc to copy and create our new doc props (use the original doc's DocType)    var doc = app.Core.GetDocumentByID(docId);    var newDocProps = storage.CreateStoreNewDocumentProperties(        doc.DocumentType, app.Core.FileTypes.Find(16));    // get the original doc's PageData    var rend = doc.DefaultRenditionOfLatestRevision;    var pageData = app.Core.Retrieval.PDF.GetDocument(rend);    // create the copy    var newDoc = storage.StoreNewDocument(pageData, newDocProps);    app.Diagnostics.Write("New Doc ID: {0}", newDoc.ID);}

 

Scott_McLean
Elite Collaborator
Elite Collaborator

We use Aspose.PDF frequently. We identified (I think as far back as v18) that Hyland surfaces an older version of Aspose.PDF for their internal uses (not accessible to us in Unity scripts), and the conflict it creates prevents importing a newer version of the Aspose DLL. As a result, when we work with it, we wrap the Aspose code in an external application and call it using a System.Diagnostics.Process process object.

 

The suggestion that Chris offered in his comment (using iTextSharp) is one way we've worked around that issue successfully, when we don't need the full functionality of Aspose. And since iTextSharp is under the MIT license, its pricetag (of zero dollars) is a lot less than Aspose as well.

 

Getting started

Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.