Developer Tools
|
Office Productivity Applications
|
Platform-Agnostic APIs
|
Home | Online Demos | Downloads | Buy Now | Support | About Us | News | Working Together | Contact Us
Gnostice Document Studio .NET |
PDFOne .NET |
Gnostice Document Studio Java |
PDFOne (for Java) |
Gnostice Document Studio Delphi |
eDocEngine VCL |
PDFtoolkit VCL |
StarDocs Web APIs |
Select the language for the code snippets
In this article we cover the steps required to get started using the StarDocs APIs in your application by showing you the process of setting up the development environment, uploading a document, getting information about the uploaded document and finally downloading it back.
Before we begin, if you don't already have the trial keys for StarDocs Cloud API, obtain them by signing up for a free trial here.
<script src="jquery-1.11.0.min.js"></script> <script src="URI.min.js"></script> <script src="stardocs-sdk.min.js"></script>
// Set up connection details var starDocs = new Gnostice.StarDocs( new Gnostice.ConnectionInfo( 'https://api.gnostice.com/stardocs/v1', '<API Key>', '<API Secret>'), new Preferences( // Force full permissions on PDF files protected // with an permissions/owner/master password new DocPasswordSettings(true)) ); // Authenticate starDocs.auth.loginApp() .done(function(response) { /* Success */ }) .fail(function(httpStatusCode, httpErrorMessage, response) { /* Handle error */ });
//... using Gnostice.StarDocsSDK; //... // Set up connection details StarDocs starDocs = new StarDocs( new ConnectionInfo( new Uri("https://api.gnostice.com/stardocs/v1"), "<API Key>", "<API Secret>"), new Preferences( // Force full permissions on PDF files protected // with an permissions/owner/master password new DocPasswordSettings(true)) ); // Authenticate try { starDocs.Auth.loginApp(); } catch (StarDocsException e) { // Handle error // e.HttpStatusCode contains the HTTP status code // e.ErrorCode contains the StarDocs error code (if any) // e.Documents contains the array of documents related to the error ( // if applicable) // e.Message contains the error message }Note: From here on, exception handling will not be shown to retain brevity of code.
//... import com.gnostice.stardocssdk.*; //... // Set up connection details StarDocs starDocs = new StarDocs(); starDocs.getConnectionInfo().setApiServerUrl(new java.net.URI("https://api.gnostice.com/stardocs/v1")); starDocs.getConnectionInfo().setApiKey("Note: From here on, exception handling will not be shown to retain brevity of code."); starDocs.getConnectionInfo().setApiSecret(" "); // Force full permissions on PDF files protected // with an permissions/owner/master password starDocs.getPreferences().getDocPasswordSettings().setForceFullPermission(true); // Authenticate try { starDocs.auth.loginApp(); } catch (StarDocsException e) { // Handle error // e.getHttpStatusCode() returns the HTTP status code // e.getErrorCode() returns the StarDocs error code (if any) // e.getDocuments() returns the array of documents related to the error ( // if applicable) // e.getMessage() contains the error message }
var StarDocs: TgtStarDocsSDK; begin try // Set up connection details StarDocs := TgtStarDocsSDK.Create(nil); StarDocs.ConnectionSettings.ApiServerUri := 'http://api.gnostice.com/stardocs/v1'; StarDocs.ConnectionSettings.ApiKey := '<API Key>'; StarDocs.ConnectionSettings.ApiSecret := '<API Secret>'; // Whether to force full permissions on PDF files protected // with an permissions/owner/master password StarDocs.Preferences.DocPassword.ForceFullPermission := True; // Authenticate try StarDocs.Auth.loginApp; except on E: EgtStarDocsException do // Handle error // E.HttpStatusCode contains the HTTP status code // E.ErrorCode contains the StarDocs error code (if applicable) // E.Documents contains the array of documents related to the // error (if applicable) // E.Message contains the error message end; finally StarDocs.Free; end; end;Note: From here on, exception handling will not be shown to retain brevity of code.
<input type="file">after the user has selected a file. See here for details of the File object and here for explanation of how to obtain the file object. An optional password can be supplied if the PDF file is encrypted. After the file is uploaded save the document URL that the server returns.
// Upload file var selectedFile = document.getElementById('input').files[0]; starDocs.storage.upload(selectedFile, "password") .done(function(response) { // Store document URL documentUrl = response.documents[0].url; }) .fail(function(errorThrown, errorCode, errorMessage) { /* Handle error */ });
// Upload by passing file name with path DocObject docObjectBalanceSheet = starDocs.Storage.Upload(@"C:\Documents\BalanceSheet.pdf", "password"); // Upload by passing in stream DocObject docObjectAnnualReport = starDocs.Storage.Upload( new FileStream(@"C:\Documents\AnnualReport.pdf", FileMode.Open), "AnnualReport.pdf", "password");Note that the document operation and viewing APIs can be supplied a filename with path or an input stream directly, so it is not necessary to perform a separate upload operation before performing a document operation or requesting to view a document. The methods will first upload the file and then proceed with the requested operation.
// Upload by passing file name with path DocObject docObjectBalanceSheet = starDocs.storage.upload("C:\\Documents\\BalanceSheet.pdf", "password"); // Upload by passing an input stream DocObject docObjectAnnualReport = starDocs.storage.upload( new FileInputStream("C:\\Documents\\AnnualReport.pdf"), "AnnualReport.pdf", "password");Note that the document operation and viewing APIs can be supplied a filename with path or an input stream directly, so it is not necessary to perform a separate upload operation before performing a document operation or requesting to view a document. The methods will first upload the file and then proceed with the requested operation.
var InFileStream: TFileStream; DocObjectBalanceSheet: TgtDocObject; DocObjectAnnualReport: TgtDocObject; begin InFileStream := nil; DocObjectBalanceSheet := nil; DocObjectAnnualReport := nil; try // Upload by passing file name with path DocObjectBalanceSheet := StarDocs.Storage.Upload( 'C:\Documents\BalanceSheet.pdf', 'password'); // Upload by passing in stream InFileStream := TFileStream.Create( 'C:\webapi_testing\datafiles\One-Page-SOPA.pdf', fmOpenRead); DocObjectAnnualReport := StarDocs.Storage.Upload( InFileStream, 'AnnualReport.pdf', 'password'); finally if Assigned(DocObjectAnnualReport) then FreeAndNil(DocObjectAnnualReport); if Assigned(DocObjectBalanceSheet) then FreeAndNil(DocObjectBalanceSheet); if Assigned(InFileStream) then FreeAndNil(InFileStream); end; end;Note that the document operation and viewing APIs can be supplied a filename with path or an input stream directly, so it is not necessary to perform a separate upload operation before performing a document operation or requesting to view a document. The methods will first upload the file and then proceed with the requested operation.
starDocs.docOperations.getDocInfo(documentUrl, "password") .done(function(response) { /* response has the following properties: url: URL of the document fileName: Filename of the document fileSize: The size of the file in bytes fileExpiry: The number of seconds since epoch when file will be deleted from the server. Null if there is no expiry set mimeType: MIME type of the document unsupportedMimeTypeOrCorrupt: True if the document is either corrupted or if it is of a type not currently supported by StarDocs. The remaining properties shown below of the response are valid only if this property is set to false passwordProtected: True if the document requires a password to be opened passwordCorrect: True if StarDocs has the correct password to open the document. Valid only if passwordProtected is true. The other properties shown below of the response are valid only if passwordProtected is false or this property is set to true pageCount: Number of pages contained in the document. Note that this property may not be valid for certain types of documents (ex. flow-based documents such as DOCX) */ }) .fail(function(httpStatusCode, httpErrorMessage, response) { /* Handle error */ });
GetDocumentInfoResponse response = starDocs.DocOperations.GetDocumentInfo( docObjectBalanceSheet, "password"); /* response has the following properties: Url: URL of the document FileName: Filename of the document FileSize: The size of the file in bytes FileExpiry: The number of seconds since epoch when file will be deleted from the server. Null if there is no expiry set MimeType: MIME type of the document UnsupportedMimeTypeOrCorrupt: True if the document is either corrupted or if it is of a type not currently supported by StarDocs. The remaining properties shown below of the response are valid only if this property is set to false PasswordProtected: True if the document requires a password to be opened PasswordCorrect: True if StarDocs has the correct password to open the document. Valid only if PasswordProtected is true. The other properties shown below of the response are valid only if PasswordProtected is false or this property is set to true PageCount: Number of pages contained in the document. Note that this property may not be valid for certain types of documents (ex. flow-based documents such as DOCX) */
GetDocumentInfoResponse response = starDocs.docOperations.getDocumentInfo( docObjectBalanceSheet, "password"); /* Following properties can be obtained from the response: getUrl(): URL of the document getFileName(): Filename of the document getFileSize(): The size of the file in bytes getFileExpiry(): The number of seconds since epoch when file will be deleted from the server. Null if there is no expiry set getMimeType(): MIME type of the document getUnsupportedMimeTypeOrCorrupt(): True if the document is either corrupted or if it is of a type not currently supported by StarDocs. The remaining properties shown below of the response are valid only if this property is set to false getPasswordProtected(): True if the document requires a password to be opened getPasswordCorrect(): True if StarDocs has the correct password to open the document. Valid only if PasswordProtected is true. The other properties shown below of the response are valid only if PasswordProtected is false or this property is set to true getPageCount(): Number of pages contained in the document. Note that this property may not be valid for certain types of documents (ex. flow-based documents such as DOCX) */
var GetDocumentInfoResponse: TgtGetDocumentInfoResponse; begin try GetDocumentInfoResponse := StarDocs.DocOperations.GetDocumentInfo( DocObjectAnnualReport, 'password'); finally GetDocumentInfoResponse.Free; end; /* GetDocumentInfoResponse has the following properties: Url: URL of the document FileName: Filename of the document FileSize: The size of the file in bytes FileExpiry: The number of seconds since epoch when file will be deleted from the server. Null if there is no expiry set MimeType: MIME type of the document UnsupportedMimeTypeOrCorrupt: True if the document is either corrupted or if it is of a type not currently supported by StarDocs. The remaining properties shown below of the response are valid only if this property is set to false PasswordProtected: True if the document requires a password to be opened PasswordCorrect: True if StarDocs has the correct password to open the document. Valid only if PasswordProtected is true. The other properties shown below of the response are valid only if PasswordProtected is false or this property is set to true PageCount: Number of pages contained in the document. Note that this property may not be valid for certain types of documents (ex. flow-based documents such as DOCX) */ end;
starDocs.storage.download(documentUrl) .done(function() { /* Success */ }) .fail(function(httpStatusCode, httpErrorMessage, response) { /* Handle error */ });
starDocs.Storage.Download(docObjectBalanceSheet, @"c:\documents");
starDocs.storage.download(docObjectBalanceSheet, "c:\\documents\\");
StarDocs.Storage.Download(DocObjectAnnualReport, 'c:\documents');
Short videos demonstrating the integration of StarDocs Multi-format Document Viewer in your web applications.
---o0O0o---
Our .NET Developer Tools | |
---|---|
![]() Gnostice Document Studio .NETMulti-format document-processing component suite for .NET developers. |
![]() PDFOne .NETA .NET PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, and bookmark PDF documents in .NET applications. |
Our Delphi/C++Builder developer tools | |
---|---|
![]() Gnostice Document Studio DelphiMulti-format document-processing component suite for Delphi/C++Builder developers, covering both VCL and FireMonkey platforms. |
![]() eDocEngine VCLA Delphi/C++Builder component suite for creating documents in over 20 formats and also export reports from popular Delphi reporting tools. |
![]() PDFtoolkit VCLA Delphi/C++Builder component suite to edit, enhance, view, print, merge, split, encrypt, annotate, and bookmark PDF documents. |
Our Java developer tools | |
---|---|
![]() Gnostice Document Studio JavaMulti-format document-processing component suite for Java developers. |
![]() PDFOne (for Java)A Java PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, bookmark PDF documents in Java applications. |
Our Platform-Agnostic Cloud and On-Premises APIs | |
---|---|
![]() StarDocsCloud-hosted and On-Premises REST-based document-processing and document-viewing APIs |
Privacy | Legal | Feedback | Newsletter | Blog | Resellers | © 2002-2025 Gnostice Information Technologies Private Limited. All rights reserved. |