Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Viewer-Android-V2
package examples.Working_With_Files;
import com.groupdocs.cloud.viewer.api.*;
import com.groupdocs.cloud.viewer.client.ApiException;
import com.groupdocs.cloud.viewer.model.requests.*;
import examples.Utils;
public class Viewer_Android_Copy_File {
public static void main(String[] args) {
FileApi apiInstance = new FileApi(Utils.AppSID, Utils.AppKey);
try {
CopyFileRequest request = new CopyFileRequest("viewers\\one-page.docx",
"viewers\\one-page-copied.docx", Utils.MYStorage, Utils.MYStorage, null);
apiInstance.copyFile(request);
System.out.println(
"Expected response type is Void: 'viewers/one-page1.docx' file copied as 'viewers/one-page-copied.docx'.");
} catch (ApiException e) {
System.err.println("Exception while calling FileApi:");
e.printStackTrace();
}
}
}
package examples.Working_With_Folder;
import com.groupdocs.cloud.viewer.api.*;
import com.groupdocs.cloud.viewer.client.ApiException;
import com.groupdocs.cloud.viewer.model.requests.*;
import examples.Utils;
public class Viewer_Android_Copy_Folder {
public static void main(String[] args) {
FolderApi apiInstance = new FolderApi(Utils.AppSID, Utils.AppKey);
try {
CopyFolderRequest request = new CopyFolderRequest("viewers", "viewers1", Utils.MYStorage,
Utils.MYStorage);
apiInstance.copyFolder(request);
System.out.println("Expected response type is Void: 'viewers' folder copied as 'viewers1'.");
} catch (ApiException e) {
System.err.println("Exception while calling FolderApi:");
e.printStackTrace();
}
}
}
package examples.Working_With_Folder;
import com.groupdocs.cloud.viewer.api.*;
import com.groupdocs.cloud.viewer.client.ApiException;
import com.groupdocs.cloud.viewer.model.requests.*;
import examples.Utils;
public class Viewer_Android_Create_Folder {
public static void main(String[] args) {
FolderApi apiInstance = new FolderApi(Utils.AppSID, Utils.AppKey);
try {
CreateFolderRequest request = new CreateFolderRequest("viewers", Utils.MYStorage);
apiInstance.createFolder(request);
System.out.println("Expected response type is Void: 'viewers' folder created.");
} catch (ApiException e) {
System.err.println("Exception while calling FolderApi:");
e.printStackTrace();
}
}
}
package examples.Working_With_View;
import com.groupdocs.cloud.viewer.api.*;
import com.groupdocs.cloud.viewer.client.ApiException;
import com.groupdocs.cloud.viewer.model.*;
import com.groupdocs.cloud.viewer.model.requests.*;
import examples.Utils;
public class Viewer_Android_Create_View_With_CAD_Options {
public static void main(String[] args) {
ViewApi apiInstance = new ViewApi(Utils.AppSID, Utils.AppKey);
try {
ViewOptions viewOptions = new ViewOptions();
FileInfo fileInfo = new FileInfo();
fileInfo.setFilePath("viewerdocs\\three-layouts.dwf");
fileInfo.setPassword("");
fileInfo.setStorageName(Utils.MYStorage);
viewOptions.setFileInfo(fileInfo);
RenderOptions renderOptions = new RenderOptions();
CadOptions cadOptions = new CadOptions();
cadOptions.setWidth(800);
renderOptions.setCadOptions(cadOptions);
viewOptions.setRenderOptions(renderOptions);
CreateViewRequest request = new CreateViewRequest(viewOptions);
ViewResult response = apiInstance.createView(request);
System.out.println("Expected response type is ViewResult: " + response.getPages().size());
} catch (ApiException e) {
System.err.println("Exception while calling ViewApi:");
e.printStackTrace();
}
}
}
package examples.Working_With_View;
import com.groupdocs.cloud.viewer.api.*;
import com.groupdocs.cloud.viewer.client.ApiException;
import com.groupdocs.cloud.viewer.model.*;
import com.groupdocs.cloud.viewer.model.requests.*;
import examples.Utils;
public class Viewer_Android_Create_View_With_Fonts_Path_Options {
public static void main(String[] args) {
ViewApi apiInstance = new ViewApi(Utils.AppSID, Utils.AppKey);
try {
ViewOptions viewOptions = new ViewOptions();
FileInfo fileInfo = new FileInfo();
fileInfo.setFilePath("viewerdocs\\uses-custom-font.pptx");
fileInfo.setPassword("");
fileInfo.setStorageName(Utils.MYStorage);
viewOptions.setFileInfo(fileInfo);
viewOptions.setViewFormat(ViewOptions.ViewFormatEnum.PNG);
viewOptions.setFontsPath("font\\ttf");
CreateViewRequest request = new CreateViewRequest(viewOptions);
ViewResult response = apiInstance.createView(request);
System.out.println("Expected response type is ViewResult: " + response.getPages().size());
} catch (ApiException e) {
System.err.println("Exception while calling ViewApi:");
e.printStackTrace();
}
}
}
package examples.Working_With_View;
import com.groupdocs.cloud.viewer.api.*;
import com.groupdocs.cloud.viewer.client.ApiException;
import com.groupdocs.cloud.viewer.model.*;
import com.groupdocs.cloud.viewer.model.requests.*;
import examples.Utils;
public class Viewer_Android_Create_View_With_HTML_View_Format {
public static void main(String[] args) {
ViewApi apiInstance = new ViewApi(Utils.AppSID, Utils.AppKey);
try {
ViewOptions viewOptions = new ViewOptions();
FileInfo fileInfo = new FileInfo();
fileInfo.setFilePath("viewerdocs\\one-page.docx");
fileInfo.setPassword("");
fileInfo.setStorageName(Utils.MYStorage);
viewOptions.setFileInfo(fileInfo);
viewOptions.setViewFormat(ViewOptions.ViewFormatEnum.HTML);
CreateViewRequest request = new CreateViewRequest(viewOptions);
ViewResult response = apiInstance.createView(request);
System.out.println("Expected response type is ViewResult: " + response.getPages().size());
} catch (ApiException e) {
System.err.println("Exception while calling ViewApi:");
e.printStackTrace();
}
}
}
package examples.Working_With_View;
import com.groupdocs.cloud.viewer.api.*;
import com.groupdocs.cloud.viewer.client.ApiException;
import com.groupdocs.cloud.viewer.model.*;
import com.groupdocs.cloud.viewer.model.requests.*;
import examples.Utils;
public class Viewer_Android_Create_View_With_HTML_ViewOptions {
public static void main(String[] args) {
ViewApi apiInstance = new ViewApi(Utils.AppSID, Utils.AppKey);
try {
ViewOptions viewOptions = new ViewOptions();
FileInfo fileInfo = new FileInfo();
fileInfo.setFilePath("viewerdocs\\three-layouts.dwf");
fileInfo.setPassword("");
fileInfo.setStorageName(Utils.MYStorage);
viewOptions.setFileInfo(fileInfo);
HtmlOptions renderOptions = new HtmlOptions();
renderOptions.setExternalResources(true);
renderOptions.defaultFontName("Arial");
viewOptions.setRenderOptions(renderOptions);
CreateViewRequest request = new CreateViewRequest(viewOptions);
ViewResult response = apiInstance.createView(request);
System.out.println("Expected response type is ViewResult: " + response.getPages().size());
} catch (ApiException e) {
System.err.println("Exception while calling ViewApi:");
e.printStackTrace();
}
}
}
package examples.Working_With_View;
import com.groupdocs.cloud.viewer.api.*;
import com.groupdocs.cloud.viewer.client.ApiException;
import com.groupdocs.cloud.viewer.model.*;
import com.groupdocs.cloud.viewer.model.requests.*;
import examples.Utils;
public class Viewer_Android_Create_View_With_Image_View_Format {
public static void main(String[] args) {
ViewApi apiInstance = new ViewApi(Utils.AppSID, Utils.AppKey);
try {
ViewOptions viewOptions = new ViewOptions();
FileInfo fileInfo = new FileInfo();
fileInfo.setFilePath("viewerdocs\\one-page.docx");
fileInfo.setPassword("");
fileInfo.setStorageName(Utils.MYStorage);
viewOptions.setFileInfo(fileInfo);
viewOptions.setViewFormat(ViewOptions.ViewFormatEnum.JPG);
CreateViewRequest request = new CreateViewRequest(viewOptions);
ViewResult response = apiInstance.createView(request);
System.out.println("Expected response type is ViewResult: " + response.getPages().size());
} catch (ApiException e) {
System.err.println("Exception while calling ViewApi:");
e.printStackTrace();
}
}
}
package examples.Working_With_View;
import com.groupdocs.cloud.viewer.api.*;
import com.groupdocs.cloud.viewer.client.ApiException;
import com.groupdocs.cloud.viewer.model.*;
import com.groupdocs.cloud.viewer.model.requests.*;
import examples.Utils;
public class Viewer_Android_Create_View_With_Minimal_ViewOptions {
public static void main(String[] args) {
ViewApi apiInstance = new ViewApi(Utils.AppSID, Utils.AppKey);
try {
ViewOptions viewOptions = new ViewOptions();
FileInfo fileInfo = new FileInfo();
fileInfo.setFilePath("viewerdocs\\one-page.docx");
fileInfo.setPassword("");
fileInfo.setStorageName(Utils.MYStorage);
viewOptions.setFileInfo(fileInfo);
CreateViewRequest request = new CreateViewRequest(viewOptions);
ViewResult response = apiInstance.createView(request);
System.out.println("Expected response type is ViewResult: " + response.getPages().size());
} catch (ApiException e) {
System.err.println("Exception while calling ViewApi:");
e.printStackTrace();
}
}
}
package examples.Working_With_View;
import com.groupdocs.cloud.viewer.api.*;
import com.groupdocs.cloud.viewer.client.ApiException;
import com.groupdocs.cloud.viewer.model.*;
import com.groupdocs.cloud.viewer.model.requests.*;
import examples.Utils;
public class Viewer_Android_Create_View_With_OutputPath {
public static void main(String[] args) {
ViewApi apiInstance = new ViewApi(Utils.AppSID, Utils.AppKey);
try {
ViewOptions viewOptions = new ViewOptions();
FileInfo fileInfo = new FileInfo();
fileInfo.setFilePath("viewerdocs\\sample.docx");
fileInfo.setPassword("");
fileInfo.setStorageName(Utils.MYStorage);
viewOptions.setFileInfo(fileInfo);
viewOptions.setOutputPath("viewerdocs");
CreateViewRequest request = new CreateViewRequest(viewOptions);
ViewResult response = apiInstance.createView(request);
System.out.println("Expected response type is ViewResult: " + response.getPages().size());
} catch (ApiException e) {
System.err.println("Exception while calling ViewApi:");
e.printStackTrace();
}
}
}
package examples.Working_With_View;
import com.groupdocs.cloud.viewer.api.*;
import com.groupdocs.cloud.viewer.client.ApiException;
import com.groupdocs.cloud.viewer.model.*;
import com.groupdocs.cloud.viewer.model.requests.*;
import examples.Utils;
import org.threeten.bp.OffsetDateTime;
import org.threeten.bp.ZoneOffset;
public class Viewer_Android_Create_View_With_Project_Options {
public static void main(String[] args) {
ViewApi apiInstance = new ViewApi(Utils.AppSID, Utils.AppKey);
try {
ViewOptions viewOptions = new ViewOptions();
FileInfo fileInfo = new FileInfo();
fileInfo.setFilePath("viewerdocs\\sample.mpp");
fileInfo.setPassword("");
fileInfo.setStorageName(Utils.MYStorage);
viewOptions.setFileInfo(fileInfo);
RenderOptions renderOptions = new RenderOptions();
ProjectManagementOptions projectManagementOptions = new ProjectManagementOptions();
projectManagementOptions.setPageSize("Unknown");
projectManagementOptions.setTimeUnit("Months");
projectManagementOptions.setStartDate(OffsetDateTime.of(2008, 7, 1, 0, 0, 0, 0, ZoneOffset.UTC));
projectManagementOptions.setEndDate(OffsetDateTime.of(2008, 7, 31, 0, 0, 0, 0, ZoneOffset.UTC));
renderOptions.setProjectManagementOptions(projectManagementOptions);
CreateViewRequest request = new CreateViewRequest(viewOptions);
ViewResult response = apiInstance.createView(request);
System.out.println("Expected response type is ViewResult: " + response.getPages().size());
} catch (ApiException e) {
System.err.println("Exception while calling ViewApi:");
e.printStackTrace();
}
}
}
package examples.Working_With_View;
import com.groupdocs.cloud.viewer.api.*;
import com.groupdocs.cloud.viewer.client.ApiException;
import com.groupdocs.cloud.viewer.model.*;
import com.groupdocs.cloud.viewer.model.requests.*;
import examples.Utils;
public class Viewer_Android_Create_View_With_Render_Hidden_Pages {
public static void main(String[] args) {
ViewApi apiInstance = new ViewApi(Utils.AppSID, Utils.AppKey);
try {
ViewOptions viewOptions = new ViewOptions();
FileInfo fileInfo = new FileInfo();
fileInfo.setFilePath("viewerdocs\\two-hidden-pages.vsd");
fileInfo.setPassword("");
fileInfo.setStorageName(Utils.MYStorage);
viewOptions.setFileInfo(fileInfo);
RenderOptions renderOptions = new RenderOptions();
renderOptions.setRenderHiddenPages(true);
viewOptions.setRenderOptions(renderOptions);
CreateViewRequest request = new CreateViewRequest(viewOptions);
ViewResult response = apiInstance.createView(request);
System.out.println("Expected response type is ViewResult: " + response.getPages().size());
} catch (ApiException e) {
System.err.println("Exception while calling ViewApi:");
e.printStackTrace();
}
}
}
package examples.Working_With_View;
import com.groupdocs.cloud.viewer.api.*;
import com.groupdocs.cloud.viewer.client.ApiException;
import com.groupdocs.cloud.viewer.model.*;
import com.groupdocs.cloud.viewer.model.requests.*;
import examples.Utils;
public class Viewer_Android_Create_View_With_Responsive_HTML {
public static void main(String[] args) {
ViewApi apiInstance = new ViewApi(Utils.AppSID, Utils.AppKey);
try {
ViewOptions viewOptions = new ViewOptions();
FileInfo fileInfo = new FileInfo();
fileInfo.setFilePath("viewerdocs\\three-layouts.dwf");
fileInfo.setPassword("");
fileInfo.setStorageName(Utils.MYStorage);
viewOptions.setFileInfo(fileInfo);
HtmlOptions renderOptions = new HtmlOptions();
renderOptions.setIsResponsive(true);
viewOptions.setRenderOptions(renderOptions);
CreateViewRequest request = new CreateViewRequest(viewOptions);
ViewResult response = apiInstance.createView(request);
System.out.println("Expected response type is ViewResult: " + response.getPages().size());
} catch (ApiException e) {
System.err.println("Exception while calling ViewApi:");
e.printStackTrace();
}
}
}
package examples.Working_With_View;
import com.groupdocs.cloud.viewer.api.*;
import com.groupdocs.cloud.viewer.client.ApiException;
import com.groupdocs.cloud.viewer.model.*;
import com.groupdocs.cloud.viewer.model.requests.*;
import examples.Utils;
public class Viewer_Android_Create_View_With_Spreadsheet_Render_Hidden_Rows_Option {
public static void main(String[] args) {
ViewApi apiInstance = new ViewApi(Utils.AppSID, Utils.AppKey);
try {
ViewOptions viewOptions = new ViewOptions();
FileInfo fileInfo = new FileInfo();
fileInfo.setFilePath("viewerdocs\\with-hidden-rows-and-columns.xlsx");
fileInfo.setPassword("");
fileInfo.setStorageName(Utils.MYStorage);
viewOptions.setFileInfo(fileInfo);
RenderOptions renderOptions = new RenderOptions();
SpreadsheetOptions spreadsheetOptions = new SpreadsheetOptions();
spreadsheetOptions.setPaginateSheets(true);
spreadsheetOptions.setCountRowsPerPage(5);
spreadsheetOptions.setRenderHiddenRows(true);
renderOptions.setSpreadsheetOptions(spreadsheetOptions);
viewOptions.setRenderOptions(renderOptions);
CreateViewRequest request = new CreateViewRequest(viewOptions);
ViewResult response = apiInstance.createView(request);
System.out.println("Expected response type is ViewResult: " + response.getPages().size());
} catch (ApiException e) {
System.err.println("Exception while calling ViewApi:");
e.printStackTrace();
}
}
}
package examples.Working_With_View;
import com.groupdocs.cloud.viewer.api.*;
import com.groupdocs.cloud.viewer.client.ApiException;
import com.groupdocs.cloud.viewer.model.*;
import com.groupdocs.cloud.viewer.model.requests.*;
import examples.Utils;
public class Viewer_Android_Create_View_With_SpreadsheetOptions {
public static void main(String[] args) {
ViewApi apiInstance = new ViewApi(Utils.AppSID, Utils.AppKey);
try {
ViewOptions viewOptions = new ViewOptions();
FileInfo fileInfo = new FileInfo();
fileInfo.setFilePath("viewerdocs\\with-hidden-rows-and-columns.xlsx");
fileInfo.setPassword("");
fileInfo.setStorageName(Utils.MYStorage);
viewOptions.setFileInfo(fileInfo);
RenderOptions renderOptions = new RenderOptions();
SpreadsheetOptions spreadsheetOptions = new SpreadsheetOptions();
spreadsheetOptions.setPaginateSheets(true);
spreadsheetOptions.setCountRowsPerPage(5);
renderOptions.setSpreadsheetOptions(spreadsheetOptions);
viewOptions.setRenderOptions(renderOptions);
CreateViewRequest request = new CreateViewRequest(viewOptions);
ViewResult response = apiInstance.createView(request);
System.out.println("Expected response type is ViewResult: " + response.getPages().size());
} catch (ApiException e) {
System.err.println("Exception while calling ViewApi:");
e.printStackTrace();
}
}
}
package examples.Working_With_View;
import com.groupdocs.cloud.viewer.api.*;
import com.groupdocs.cloud.viewer.client.ApiException;
import com.groupdocs.cloud.viewer.model.*;
import com.groupdocs.cloud.viewer.model.requests.*;
import examples.Utils;
public class Viewer_Android_Create_View_With_StartPage_And_CountPages {
public static void main(String[] args) {
ViewApi apiInstance = new ViewApi(Utils.AppSID, Utils.AppKey);
try {
ViewOptions viewOptions = new ViewOptions();
FileInfo fileInfo = new FileInfo();
fileInfo.setFilePath("viewerdocs\\four-pages.docx");
fileInfo.setPassword("");
fileInfo.setStorageName(Utils.MYStorage);
viewOptions.setFileInfo(fileInfo);
RenderOptions renderOptions = new RenderOptions();
renderOptions.setStartPageNumber(2);
renderOptions.setCountPagesToRender(2);
viewOptions.setRenderOptions(renderOptions);
CreateViewRequest request = new CreateViewRequest(viewOptions);
ViewResult response = apiInstance.createView(request);
System.out.println("Expected response type is ViewResult: " + response.getPages().size());
} catch (ApiException e) {
System.err.println("Exception while calling ViewApi:");
e.printStackTrace();
}
}
}
package examples.Working_With_Files;
import com.groupdocs.cloud.viewer.api.*;
import com.groupdocs.cloud.viewer.client.ApiException;
import com.groupdocs.cloud.viewer.model.requests.*;
import examples.Utils;
public class Viewer_Android_Delete_File {
public static void main(String[] args) {
FileApi apiInstance = new FileApi(Utils.AppSID, Utils.AppKey);
try {
DeleteFileRequest request = new DeleteFileRequest("viewers1\\one-page1.docx", Utils.MYStorage, null);
apiInstance.deleteFile(request);
System.out.println("Expected response type is Void: 'viewers1/one-page1.docx' deleted.");
} catch (ApiException e) {
System.err.println("Exception while calling FileApi:");
e.printStackTrace();
}
}
}
package examples.Working_With_Folder;
import com.groupdocs.cloud.viewer.api.*;
import com.groupdocs.cloud.viewer.client.ApiException;
import com.groupdocs.cloud.viewer.model.requests.*;
import examples.Utils;
public class Viewer_Android_Delete_Folder {
public static void main(String[] args) {
FolderApi apiInstance = new FolderApi(Utils.AppSID, Utils.AppKey);
try {
DeleteFolderRequest request = new DeleteFolderRequest("viewers\\viewers1", Utils.MYStorage, true);
apiInstance.deleteFolder(request);
System.out
.println("Expected response type is Void: 'viewers/viewers1' folder deleted recusrsively.");
} catch (ApiException e) {
System.err.println("Exception while calling FolderApi:");
e.printStackTrace();
}
}
}
package examples.Working_With_View;
import com.groupdocs.cloud.viewer.api.*;
import com.groupdocs.cloud.viewer.client.ApiException;
import com.groupdocs.cloud.viewer.model.*;
import com.groupdocs.cloud.viewer.model.requests.*;
import examples.Utils;
public class Viewer_Android_Delete_View_With_Default_ViewFormat {
public static void main(String[] args) {
ViewApi apiInstance = new ViewApi(Utils.AppSID, Utils.AppKey);
try {
DeleteViewOptions viewOptions = new DeleteViewOptions();
FileInfo fileInfo = new FileInfo();
fileInfo.setFilePath("viewerdocs\\one-page.docx");
fileInfo.setPassword("");
fileInfo.setStorageName(Utils.MYStorage);
viewOptions.setFileInfo(fileInfo);
DeleteViewRequest request = new DeleteViewRequest(viewOptions);
apiInstance.deleteView(request);
System.out.println("Expected response type is Void: View deleted with default View Format.");
} catch (ApiException e) {
System.err.println("Exception while calling ViewApi:");
e.printStackTrace();
}
}
}
package examples.Working_With_Files;
import java.io.File;
import com.groupdocs.cloud.viewer.api.*;
import com.groupdocs.cloud.viewer.client.ApiException;
import com.groupdocs.cloud.viewer.model.requests.*;
import examples.Utils;
public class Viewer_Android_Download_File {
public static void main(String[] args) {
FileApi apiInstance = new FileApi(Utils.AppSID, Utils.AppKey);
try {
DownloadFileRequest request = new DownloadFileRequest("viewers\\one-page.docx", Utils.MYStorage, null);
File response = apiInstance.downloadFile(request);
System.err.println("Expected response type is File: " + response.length());
} catch (ApiException e) {
System.err.println("Exception while calling FileApi:");
e.printStackTrace();
}
}
}
package examples.Working_With_Storage;
import com.groupdocs.cloud.viewer.api.*;
import com.groupdocs.cloud.viewer.client.ApiException;
import com.groupdocs.cloud.viewer.model.*;
import com.groupdocs.cloud.viewer.model.requests.*;
import examples.Utils;
public class Viewer_Android_Get_Disc_Usage {
public static void main(String[] args) {
StorageApi apiInstance = new StorageApi(Utils.AppSID, Utils.AppKey);
try {
GetDiscUsageRequest request = new GetDiscUsageRequest(Utils.MYStorage);
DiscUsage response = apiInstance.getDiscUsage(request);
System.out.println("Expected response type is DiscUsage: " + response.getUsedSize());
} catch (ApiException e) {
System.err.println("Exception while calling StorageApi:");
e.printStackTrace();
}
}
}
package examples.Working_With_Storage;
import com.groupdocs.cloud.viewer.api.*;
import com.groupdocs.cloud.viewer.client.ApiException;
import com.groupdocs.cloud.viewer.model.*;
import com.groupdocs.cloud.viewer.model.requests.*;
import examples.Utils;
public class Viewer_Android_Get_File_Versions {
public static void main(String[] args) {
StorageApi apiInstance = new StorageApi(Utils.AppSID, Utils.AppKey);
try {
GetFileVersionsRequest request = new GetFileVersionsRequest("viewers\\one-page.docx", Utils.MYStorage);
FileVersions response = apiInstance.getFileVersions(request);
System.out.println("Expected response type is FileVersions: " + response.getValue().size());
} catch (ApiException e) {
System.err.println("Exception while calling StorageApi:");
e.printStackTrace();
}
}
}
package examples.Working_With_Folder;
import com.groupdocs.cloud.viewer.api.*;
import com.groupdocs.cloud.viewer.client.ApiException;
import com.groupdocs.cloud.viewer.model.FilesList;
import com.groupdocs.cloud.viewer.model.*;
import com.groupdocs.cloud.viewer.model.requests.*;
import examples.Utils;
public class Viewer_Android_Get_Files_List {
public static void main(String[] args) {
FolderApi apiInstance = new FolderApi(Utils.AppSID, Utils.AppKey);
try {
GetFilesListRequest request = new GetFilesListRequest("viewers", Utils.MYStorage);
FilesList response = apiInstance.getFilesList(request);
System.out.println("Expected response type is FilesList.");
for (StorageFile storageFile : response.getValue()) {
System.out.println("Files: " + storageFile.getPath());
}
} catch (ApiException e) {
System.err.println("Exception while calling FolderApi:");
e.printStackTrace();
}
}
}
package examples.Working_With_Document_Information;
import com.groupdocs.cloud.viewer.api.*;
import com.groupdocs.cloud.viewer.client.ApiException;
import com.groupdocs.cloud.viewer.model.*;
import com.groupdocs.cloud.viewer.model.requests.*;
import examples.Utils;
public class Viewer_Android_Get_Info_With_CAD_Options {
public static void main(String[] args) {
InfoApi apiInstance = new InfoApi(Utils.AppSID, Utils.AppKey);
try {
ViewOptions viewOptions = new ViewOptions();
FileInfo fileInfo = new FileInfo();
fileInfo.setFilePath("viewerdocs\\three-layouts.dwf");
fileInfo.setPassword("");
fileInfo.setStorageName(Utils.MYStorage);
viewOptions.setFileInfo(fileInfo);
RenderOptions renderOptions = new RenderOptions();
CadOptions cadOptions = new CadOptions();
cadOptions.setScaleFactor(5.0);
renderOptions.setCadOptions(cadOptions);
viewOptions.setRenderOptions(renderOptions);
GetInfoRequest request = new GetInfoRequest(viewOptions);
InfoResult response = apiInstance.getInfo(request);
System.out.println("Expected response type is InfoResult: " + response.getPages().size());
} catch (ApiException e) {
System.err.println("Exception while calling InfoApi:");
e.printStackTrace();
}
}
}
package examples.Working_With_Document_Information;
import com.groupdocs.cloud.viewer.api.*;
import com.groupdocs.cloud.viewer.client.ApiException;
import com.groupdocs.cloud.viewer.model.*;
import com.groupdocs.cloud.viewer.model.requests.*;
import examples.Utils;
public class Viewer_Android_Get_Info_With_HTML_View_Format {
public static void main(String[] args) {
InfoApi apiInstance = new InfoApi(Utils.AppSID, Utils.AppKey);
try {
ViewOptions viewOptions = new ViewOptions();
FileInfo fileInfo = new FileInfo();
fileInfo.setFilePath("viewerdocs\\one-page.docx");
fileInfo.setPassword("");
fileInfo.setStorageName(Utils.MYStorage);
viewOptions.setFileInfo(fileInfo);
viewOptions.setViewFormat(ViewOptions.ViewFormatEnum.HTML);
GetInfoRequest request = new GetInfoRequest(viewOptions);
InfoResult response = apiInstance.getInfo(request);
System.out.println("Expected response type is InfoResult: " + response.getPages().size());
} catch (ApiException e) {
System.err.println("Exception while calling InfoApi:");
e.printStackTrace();
}
}
}
package examples.Working_With_Document_Information;
import com.groupdocs.cloud.viewer.api.*;
import com.groupdocs.cloud.viewer.client.ApiException;
import com.groupdocs.cloud.viewer.model.*;
import com.groupdocs.cloud.viewer.model.requests.*;
import examples.Utils;
public class Viewer_Android_Get_Info_With_Image_View_Format {
public static void main(String[] args) {
InfoApi apiInstance = new InfoApi(Utils.AppSID, Utils.AppKey);
try {
ViewOptions viewOptions = new ViewOptions();
FileInfo fileInfo = new FileInfo();
fileInfo.setFilePath("viewerdocs\\one-page.docx");
fileInfo.setPassword("");
fileInfo.setStorageName(Utils.MYStorage);
viewOptions.setFileInfo(fileInfo);
viewOptions.setViewFormat(ViewOptions.ViewFormatEnum.JPG);
GetInfoRequest request = new GetInfoRequest(viewOptions);
InfoResult response = apiInstance.getInfo(request);
System.out.println("Expected response type is InfoResult: " + response.getPages().size());
} catch (ApiException e) {
System.err.println("Exception while calling InfoApi:");
e.printStackTrace();
}
}
}
package examples.Working_With_Document_Information;
import com.groupdocs.cloud.viewer.api.*;
import com.groupdocs.cloud.viewer.client.ApiException;
import com.groupdocs.cloud.viewer.model.*;
import com.groupdocs.cloud.viewer.model.requests.*;
import examples.Utils;
public class Viewer_Android_Get_Info_With_Image_View_Options {
public static void main(String[] args) {
InfoApi apiInstance = new InfoApi(Utils.AppSID, Utils.AppKey);
try {
ViewOptions viewOptions = new ViewOptions();
FileInfo fileInfo = new FileInfo();
fileInfo.setFilePath("viewerdocs\\one-page.docx");
fileInfo.setPassword("");
fileInfo.setStorageName(Utils.MYStorage);
viewOptions.setFileInfo(fileInfo);
viewOptions.setViewFormat(ViewOptions.ViewFormatEnum.JPG);
ImageOptions renderOptions = new ImageOptions();
renderOptions.setExtractText(true);
viewOptions.setRenderOptions(renderOptions);
GetInfoRequest request = new GetInfoRequest(viewOptions);
InfoResult response = apiInstance.getInfo(request);
System.out.println("Expected response type is InfoResult: " + response.getPages().size());
} catch (ApiException e) {
System.err.println("Exception while calling InfoApi:");
e.printStackTrace();
}
}
}
package examples.Working_With_Document_Information;
import com.groupdocs.cloud.viewer.api.*;
import com.groupdocs.cloud.viewer.client.ApiException;
import com.groupdocs.cloud.viewer.model.*;
import com.groupdocs.cloud.viewer.model.requests.*;
import examples.Utils;
public class Viewer_Android_Get_Info_With_Minimal_ViewOptions {
public static void main(String[] args) {
InfoApi apiInstance = new InfoApi(Utils.AppSID, Utils.AppKey);
try {
ViewOptions viewOptions = new ViewOptions();
FileInfo fileInfo = new FileInfo();
fileInfo.setFilePath("viewerdocs\\password-protected.docx");
fileInfo.setPassword("password");
fileInfo.setStorageName(Utils.MYStorage);
viewOptions.setFileInfo(fileInfo);
GetInfoRequest request = new GetInfoRequest(viewOptions);
InfoResult response = apiInstance.getInfo(request);
System.out.println("Expected response type is InfoResult: " + response.getPages().size());
} catch (ApiException e) {
System.err.println("Exception while calling InfoApi:");
e.printStackTrace();
}
}
}
package examples.Working_With_Document_Information;
import com.groupdocs.cloud.viewer.api.*;
import com.groupdocs.cloud.viewer.client.ApiException;
import com.groupdocs.cloud.viewer.model.*;
import com.groupdocs.cloud.viewer.model.requests.*;
import examples.Utils;
import org.threeten.bp.OffsetDateTime;
import org.threeten.bp.ZoneOffset;
public class Viewer_Android_Get_Info_With_Project_Options {
public static void main(String[] args) {
InfoApi apiInstance = new InfoApi(Utils.AppSID, Utils.AppKey);
try {
ViewOptions viewOptions = new ViewOptions();
FileInfo fileInfo = new FileInfo();
fileInfo.setFilePath("viewerdocs\\sample.mpp");
fileInfo.setPassword("");
fileInfo.setStorageName(Utils.MYStorage);
viewOptions.setFileInfo(fileInfo);
RenderOptions renderOptions = new RenderOptions();
ProjectManagementOptions projectManagementOptions = new ProjectManagementOptions();
projectManagementOptions.setPageSize("Unknown");
projectManagementOptions.setTimeUnit("Months");
projectManagementOptions.setStartDate(OffsetDateTime.of(2008, 7, 1, 0, 0, 0, 0, ZoneOffset.UTC));
projectManagementOptions.setEndDate(OffsetDateTime.of(2008, 7, 31, 0, 0, 0, 0, ZoneOffset.UTC));
renderOptions.setProjectManagementOptions(projectManagementOptions);
GetInfoRequest request = new GetInfoRequest(viewOptions);
InfoResult response = apiInstance.getInfo(request);
System.out.println("Expected response type is InfoResult: " + response.getPages().size());
} catch (ApiException e) {
System.err.println("Exception while calling InfoApi:");
e.printStackTrace();
}
}
}
package examples.Working_With_Document_Information;
import com.groupdocs.cloud.viewer.api.*;
import com.groupdocs.cloud.viewer.client.ApiException;
import com.groupdocs.cloud.viewer.model.*;
import com.groupdocs.cloud.viewer.model.requests.*;
import examples.Utils;
public class Viewer_Android_Get_Info_With_Render_Hidden_Pages {
public static void main(String[] args) {
InfoApi apiInstance = new InfoApi(Utils.AppSID, Utils.AppKey);
try {
ViewOptions viewOptions = new ViewOptions();
FileInfo fileInfo = new FileInfo();
fileInfo.setFilePath("viewerdocs\\two-hidden-pages.vsd");
fileInfo.setPassword("");
fileInfo.setStorageName(Utils.MYStorage);
viewOptions.setFileInfo(fileInfo);
RenderOptions renderOptions = new RenderOptions();
renderOptions.setRenderHiddenPages(true);
viewOptions.setRenderOptions(renderOptions);
GetInfoRequest request = new GetInfoRequest(viewOptions);
InfoResult response = apiInstance.getInfo(request);
System.out.println("Expected response type is InfoResult: " + response.getPages().size());
} catch (ApiException e) {
System.err.println("Exception while calling InfoApi:");
e.printStackTrace();
}
}
}
package examples.Working_With_Document_Information;
import com.groupdocs.cloud.viewer.api.*;
import com.groupdocs.cloud.viewer.client.ApiException;
import com.groupdocs.cloud.viewer.model.*;
import com.groupdocs.cloud.viewer.model.requests.*;
import examples.Utils;
public class Viewer_Android_Get_Info_With_Spreadsheet_Render_Hidden_Rows_Option {
public static void main(String[] args) {
InfoApi apiInstance = new InfoApi(Utils.AppSID, Utils.AppKey);
try {
ViewOptions viewOptions = new ViewOptions();
FileInfo fileInfo = new FileInfo();
fileInfo.setFilePath("viewerdocs\\with-hidden-rows-and-columns.xlsx");
fileInfo.setPassword("");
fileInfo.setStorageName(Utils.MYStorage);
viewOptions.setFileInfo(fileInfo);
RenderOptions renderOptions = new RenderOptions();
SpreadsheetOptions spreadsheetOptions = new SpreadsheetOptions();
spreadsheetOptions.setPaginateSheets(true);
spreadsheetOptions.setCountRowsPerPage(5);
spreadsheetOptions.setRenderHiddenRows(true);
renderOptions.setSpreadsheetOptions(spreadsheetOptions);
viewOptions.setRenderOptions(renderOptions);
GetInfoRequest request = new GetInfoRequest(viewOptions);
InfoResult response = apiInstance.getInfo(request);
System.out.println("Expected response type is InfoResult: " + response.getPages().size());
} catch (ApiException e) {
System.err.println("Exception while calling InfoApi:");
e.printStackTrace();
}
}
}
package examples.Working_With_Document_Information;
import com.groupdocs.cloud.viewer.api.*;
import com.groupdocs.cloud.viewer.client.ApiException;
import com.groupdocs.cloud.viewer.model.*;
import com.groupdocs.cloud.viewer.model.requests.*;
import examples.Utils;
public class Viewer_Android_Get_Info_With_SpreadsheetOptions {
public static void main(String[] args) {
InfoApi apiInstance = new InfoApi(Utils.AppSID, Utils.AppKey);
try {
ViewOptions viewOptions = new ViewOptions();
FileInfo fileInfo = new FileInfo();
fileInfo.setFilePath("viewerdocs\\with-hidden-rows-and-columns.xlsx");
fileInfo.setPassword("");
fileInfo.setStorageName(Utils.MYStorage);
viewOptions.setFileInfo(fileInfo);
RenderOptions renderOptions = new RenderOptions();
SpreadsheetOptions spreadsheetOptions = new SpreadsheetOptions();
spreadsheetOptions.setPaginateSheets(true);
spreadsheetOptions.setCountRowsPerPage(5);
renderOptions.setSpreadsheetOptions(spreadsheetOptions);
viewOptions.setRenderOptions(renderOptions);
GetInfoRequest request = new GetInfoRequest(viewOptions);
InfoResult response = apiInstance.getInfo(request);
System.out.println("Expected response type is InfoResult: " + response.getPages().size());
} catch (ApiException e) {
System.err.println("Exception while calling InfoApi:");
e.printStackTrace();
}
}
}
package examples.Supported_File_Formats;
import com.groupdocs.cloud.viewer.client.*;
import com.groupdocs.cloud.viewer.model.*;
import com.groupdocs.cloud.viewer.api.InfoApi;
import examples.Utils;
public class Viewer_Android_Get_Supported_Formats {
public static void main(String[] args) {
InfoApi apiInstance = new InfoApi(Utils.AppSID, Utils.AppKey);
try {
FormatsResult response = apiInstance.getSupportedFileFormats();
for (Format format : response.getFormats()) {
System.out.println(format.getFileFormat());
}
} catch (ApiException e) {
System.err.println("Exception while calling InfoApi:");
e.printStackTrace();
}
}
}
package examples.Working_With_Files;
import com.groupdocs.cloud.viewer.api.*;
import com.groupdocs.cloud.viewer.client.ApiException;
import com.groupdocs.cloud.viewer.model.requests.*;
import examples.Utils;
public class Viewer_Android_Move_File {
public static void main(String[] args) {
FileApi apiInstance = new FileApi(Utils.AppSID, Utils.AppKey);
try {
MoveFileRequest request = new MoveFileRequest("viewers\\one-page1.docx", "viewers1\\one-page1.docx",
Utils.MYStorage, Utils.MYStorage, null);
apiInstance.moveFile(request);
System.out.println(
"Expected response type is Void: 'viewers/one-page1.docx' file moved to 'viewers1/one-page1.docx'.");
} catch (ApiException e) {
System.err.println("Exception while calling FileApi:");
e.printStackTrace();
}
}
}
package examples.Working_With_Folder;
import com.groupdocs.cloud.viewer.api.*;
import com.groupdocs.cloud.viewer.client.ApiException;
import com.groupdocs.cloud.viewer.model.requests.*;
import examples.Utils;
public class Viewer_Android_Move_Folder {
public static void main(String[] args) {
FolderApi apiInstance = new FolderApi(Utils.AppSID, Utils.AppKey);
try {
MoveFolderRequest request = new MoveFolderRequest("viewers1", "viewers\\viewers1",
Utils.MYStorage, Utils.MYStorage);
apiInstance.moveFolder(request);
System.out.println(
"Expected response type is Void: 'viewers1' folder moved to 'viewers/viewers1'.");
} catch (ApiException e) {
System.err.println("Exception while calling FolderApi:");
e.printStackTrace();
}
}
}
package examples.Working_With_Storage;
import com.groupdocs.cloud.viewer.api.*;
import com.groupdocs.cloud.viewer.client.ApiException;
import com.groupdocs.cloud.viewer.model.*;
import com.groupdocs.cloud.viewer.model.requests.*;
import examples.Utils;
public class Viewer_Android_Object_Exists {
public static void main(String[] args) {
StorageApi apiInstance = new StorageApi(Utils.AppSID, Utils.AppKey);
try {
ObjectExistsRequest request = new ObjectExistsRequest("viewers\\one-page.docx", Utils.MYStorage, null);
ObjectExist response = apiInstance.objectExists(request);
System.out.println("Expected response type is ObjectExist: " + response.getExists());
} catch (ApiException e) {
System.err.println("Exception while calling StorageApi:");
e.printStackTrace();
}
}
}
package examples.Working_With_Storage;
import com.groupdocs.cloud.viewer.api.*;
import com.groupdocs.cloud.viewer.client.ApiException;
import com.groupdocs.cloud.viewer.model.*;
import com.groupdocs.cloud.viewer.model.requests.*;
import examples.Utils;
public class Viewer_Android_Storage_Exist {
public static void main(String[] args) {
StorageApi apiInstance = new StorageApi(Utils.AppSID, Utils.AppKey);
try {
StorageExistsRequest request = new StorageExistsRequest(Utils.MYStorage);
StorageExist response = apiInstance.storageExists(request);
System.out.println("Expected response type is StorageExist: " + response.getExists());
} catch (ApiException e) {
System.err.println("Exception while calling StorageApi:");
e.printStackTrace();
}
}
}
package examples.Working_With_Files;
import java.io.File;
import java.nio.file.Paths;
import com.groupdocs.cloud.viewer.api.*;
import com.groupdocs.cloud.viewer.client.ApiException;
import com.groupdocs.cloud.viewer.model.*;
import com.groupdocs.cloud.viewer.model.requests.*;
import examples.Utils;
public class Viewer_Android_Upload_File {
public static void main(String[] args) {
FileApi apiInstance = new FileApi(Utils.AppSID, Utils.AppKey);
try {
File fileStream = new File(
Paths.get("src\\main\\resources").toAbsolutePath().toString() + "\\viewers\\one-page.docx");
UploadFileRequest request = new UploadFileRequest("viewers\\one-page1.docx", fileStream,
Utils.MYStorage);
FilesUploadResult response = apiInstance.uploadFile(request);
System.out.println("Expected response type is FilesUploadResult: " + response.getUploaded().size());
} catch (ApiException e) {
System.err.println("Exception while calling FileApi:");
e.printStackTrace();
}
}
}
package examples;
import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import com.groupdocs.cloud.viewer.api.FileApi;
import com.groupdocs.cloud.viewer.client.ApiException;
import com.groupdocs.cloud.viewer.model.requests.*;;
public class Upload_Resoruces {
public static FileApi fileApi = new FileApi(Utils.AppSID, Utils.AppKey);
public static String resourcesPath = Paths.get("src\\main\\resources").toAbsolutePath().toString();
public static void main(String[] args) {
try {
System.out.println("File Upload Processing");
uploadFiles(resourcesPath);
System.out.println("File Upload Process End");
} catch (ApiException e) {
System.err.println("Exception while file uploading:");
e.printStackTrace();
}
}
public static void uploadFiles(String path) throws ApiException {
File directory = new File(path);
File[] files = directory.listFiles();
for (File file : files) {
String relativePath = getRelativePath(file.getAbsolutePath(), resourcesPath);
if (file.isFile()) {
uploadFile(file, relativePath);
} else if (file.isDirectory()) {
uploadFiles(file.getAbsolutePath().toString());
}
}
}
public static String getRelativePath(String absolutePath, String basePath) {
Path absolute = Paths.get(absolutePath);
Path base = Paths.get(basePath);
Path relative = base.relativize(absolute);
return relative.toString();
}
public static void uploadFile(File file, String relativePath) throws ApiException {
String filePath = relativePath.replace("\\", "/");
System.out.println("Uploading File: " + filePath);
UploadFileRequest request = new UploadFileRequest(filePath, file, Utils.MYStorage);
fileApi.uploadFileWithHttpInfo(request);
}
}
package examples;
import com.groupdocs.cloud.viewer.api.FolderApi;
import com.groupdocs.cloud.viewer.client.ApiException;
import com.groupdocs.cloud.viewer.model.FilesList;
import com.groupdocs.cloud.viewer.model.StorageFile;
import com.groupdocs.cloud.viewer.model.requests.GetFilesListRequest;
public class Utils {
// TODO: Get your AppSID and AppKey at https://dashboard.groupdocs.cloud (free
// registration is required).
public static String AppSID = "XXXXX-XXXXX-XXXXX";
public static String AppKey = "XXXXXXXX";
public static String MYStorage = "XXXXX";
public static void getFolderFilesPath(String path) {
FolderApi apiInstance = new FolderApi(Utils.AppSID, Utils.AppKey);
try {
GetFilesListRequest request = new GetFilesListRequest(path, Utils.MYStorage);
FilesList response = apiInstance.getFilesList(request);
for (StorageFile storageFile : response.getValue()) {
System.out.println("Files: " + storageFile.getPath());
}
} catch (ApiException e) {
System.err.println("Exception while calling getFolderFilesPath with FolderApi:");
e.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment