Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save aspose-pdf/531368565ace35fc131f3e7b44b4e322 to your computer and use it in GitHub Desktop.
Save aspose-pdf/531368565ace35fc131f3e7b44b4e322 to your computer and use it in GitHub Desktop.
Aspose_Cloud_PDF_Android
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "Sample-Annotation.pdf";
int pageNumber = 1;
String storage = "";
String folder = "";
File inputFile = Utils.stream2file("sample1","pptx", context.getResources().openRawResource(R.raw.Sample_Annotation));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",inputFile);
// Invoke Aspose.PDF Cloud SDK API to get all annotations from pdf page
AnnotationsResponse apiResponse = pdfApi.GetPageAnnotations(fileName, pageNumber, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
for (Link annotatonLink : apiResponse.getAnnotations().getLinks())
{
System.out.println("Annotation Link :: " + annotatonLink.getHref());
}
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "Sample-Annotation.pdf";
int pageNumber = 1;
String storage = "";
String folder = "";
File inputFile = Utils.stream2file("Sample-Annotation","pdf", context.getResources().openRawResource(R.raw.Sample_Annotation));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", inputFile);
// Invoke Aspose.PDF Cloud SDK API to get annotations count from Pdf page
AnnotationsResponse apiResponse = pdfApi.GetPageAnnotations(fileName, pageNumber, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
int count = apiResponse.getAnnotations().getLinks().size();
System.out.println("Annotation Count :: " + count);
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "Sample-Annotation.pdf";
int pageNumber = 1;
int annotationNumber = 1;
String storage = "";
String folder = "";
File inputFile = Utils.stream2file("sample1","pptx", context.getResources().openRawResource(R.raw.sample1));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",inputFile);
// Invoke Aspose.PDF Cloud SDK API to get specific annotation from pdf page
AnnotationResponse apiResponse = pdfApi.GetPageAnnotation(fileName, pageNumber, annotationNumber, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
Annotation annotation = apiResponse.getAnnotation();
System.out.println("Annotation Content" + annotation.getContents());
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String name = "SampleAttachment";
String fileName = name + ".pdf";
int attachmentIndex = 1;
String storage = "";
String folder = "";
File inputFile = Utils.stream2file("SampleAttachment","pdf", context.getResources().openRawResource(R.raw.SampleAttachment));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", inputFile);
// Invoke Aspose.PDF Cloud SDK API to download specific attachment from a pdf
ResponseMessage apiResponse = pdfApi.GetDownloadDocumentAttachmentByIndex(fileName, attachmentIndex, storage, folder);
if (apiResponse != null)
{
System.out.println("Download a specific Attachment from a PDF, Done!");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "SampleAttachment.pdf";
String storage = "";
String folder = "";
File inputFile = Utils.stream2file("SampleAttachment","pdf", context.getResources().openRawResource(R.raw.SampleAttachment));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", inputFile);
// Invoke Aspose.PDF Cloud SDK API to get all attachments from a pdf
AttachmentsResponse apiResponse = pdfApi.GetDocumentAttachments(fileName, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
System.out.println("Get all Attachments from a PDF, Done!");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "SampleAttachment.pdf";
String storage = "";
String folder = "";
File inputFile = Utils.stream2file("SampleAttachment","pdf", context.getResources().openRawResource(R.raw.SampleAttachment));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", inputFile);
// Invoke Aspose.PDF Cloud SDK API to get attachment count from a pdf
AttachmentsResponse apiResponse = pdfApi.GetDocumentAttachments(fileName, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
Attachments attachments = apiResponse.getAttachments();
int count = attachments.getList().size();
System.out.println("Count :: " + count);
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String name = "SampleAttachment";
String fileName = name + ".pdf";
int attachmentIndex = 1;
String storage = "";
String folder = "";
File input = Utils.stream2file("sample1","pptx", context.getResources().openRawResource(R.raw.sample1));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// Invoke Aspose.PDF Cloud SDK API to get specific attachment from a pdf
AttachmentResponse apiResponse = pdfApi.GetDocumentAttachmentByIndex(fileName, attachmentIndex, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
Attachment attach = apiResponse.getAttachment();
System.out.println("Name :: " + attach.getName());
System.out.println("MimeType :: " + attach.getMimeType());
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "Sample-Bookmark.pdf";
String storage = "";
String folder = "";
File input = Utils.stream2file("Bookmark","pdf", context.getResources().openRawResource(R.raw.Sample_Bookmark));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// Invoke Aspose.PDF Cloud SDK API to get all bookmarks from pdf
BookmarksResponse apiResponse = pdfApi.GetDocumentBookmarks(fileName, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
Bookmarks bookmarks = apiResponse.getBookmarks();
System.out.println("Get all Bookmarks from a PDF,Done!");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "Sample-Bookmark.pdf";
String storage = "";
String folder = "";
File input = Utils.stream2file("Sample-Bookmark","pdf", context.getResources().openRawResource(R.raw.Sample_Bookmark));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// Invoke Aspose.PDF Cloud SDK API to get bookmark count from pdf
BookmarksResponse apiResponse = pdfApi.GetDocumentBookmarks(fileName, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
Bookmarks bookmarks = apiResponse.getBookmarks();
int count = bookmarks.getList().size();
System.out.println("Bookmark Count :: " + count);
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "Sample-Bookmark.pdf";
String bookmarkPath = "1";
String storage = "";
String folder = "";
File input = Utils.stream2file("Sample-Bookmark","pdf", context.getResources().openRawResource(R.raw.Sample_Bookmark));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// Invoke Aspose.PDF Cloud SDK API to get specific bookmark
BookmarkResponse apiResponse = pdfApi.GetDocumentBookmarksChildren(fileName, bookmarkPath, storage, folder);
if (apiResponse != null)
{
System.out.println("Get Specific Bookmark from a PDF,Done!");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
public static final String apiKey="a165298dc077f8852d5eb6e5bf49310d";
public static final String appSID="1c7a12ca-efa8-466e-b83d-234d9d5e2309";
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "Sample.pdf";
int startPage = 2;
int endPage = 3;
String storage = "";
String folder = "";
String appendFileName = "sample1-input.pdf";
AppendDocument body = new AppendDocument();
body.setDocument (appendFileName);
body.setStartPage (2);
body.setEndPage (3);
File input = Utils.stream2file("Sample_input","pdf", context.getResources().openRawResource(R.raw.sample_input));
File appendFile = Utils.stream2file("sample1","pdf", context.getResources().openRawResource(R.raw.sample1));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
storageApi.PutCreate(appendFileName, "", "",appendFile);
// Invoke Aspose.PDF Cloud SDK API to append pdf file
DocumentResponse apiResponse = pdfApi.PostAppendDocument(fileName, "test", startPage, endPage, storage, folder, body);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
System.out.println("Append PDF Files, Done!");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String name = "123";
String fileName = name + ".pdf";
String format = "TIFF";
String url = "https://github.com/farooqsheikhpk/Aspose_Pdf_Cloud/raw/master/SDKs/Aspose.Pdf_Cloud_SDK_for_Java/src/test/resources/" + fileName;
String outPath = "";
File input = Utils.stream2file("123","pdf", context.getResources().openRawResource(R.raw.sample_input));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
ResponseMessage apiResponse = pdfApi.PutConvertDocument(format, url, outPath, input);
if (apiResponse != null)
{
System.out.println("Convert PDF from Remote Server to TIFF, Done!");
}
format = "DOC";
// Invoke Aspose.PDF Cloud SDK API to pdf file to doc format
apiResponse = pdfApi.PutConvertDocument(format, url, outPath, input);
if (apiResponse != null)
{
System.out.println("Convert PDF from Remote Server to DOC, Done!");
}
format = "HTML";
// Invoke Aspose.PDF Cloud SDK API to convert pdf to HTML format
apiResponse = pdfApi.PutConvertDocument(format, url, outPath, input);
if (apiResponse != null)
{
System.out.println("Convert PDF from Remote Server to HTML, Done!");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "input.pdf";
String format = "TIFF";
String url = "";
String outPath = "";
File input = Utils.stream2file("input","pdf", context.getResources().openRawResource(R.raw.sample_input));
try {
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// Invoke Aspose.PDF Cloud SDK API to convert pdf to other formats
ResponseMessage apiResponse = pdfApi.PutConvertDocument(format, url, outPath, input);
if (apiResponse != null) {
System.out.println("Convert PDF to TIFF, Done!");
}
format = "DOC";
apiResponse = pdfApi.PutConvertDocument(format, url, outPath, input);
if (apiResponse != null) {
System.out.println("Convert PDF to DOC, Done!");
}
format = "html";
apiResponse = pdfApi.PutConvertDocument(format, url, outPath, input);
if (apiResponse != null) {
System.out.println("Convert PDF to HTML, Done!");
}
} catch (Exception ex) {
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "input.pdf";
String format = "TIFF";
String storage = "";
String folder = "";
String outPath = "";
File inputFile = Utils.stream2file("input","pdf", context.getResources().openRawResource(R.raw.sample_input));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", inputFile);
// Invoke Aspose.PDF Cloud SDK API to convert pdf to images
ResponseMessage apiResponse = pdfApi.GetDocumentWithFormat(fileName, format, storage, folder, outPath);
if (apiResponse != null)
{
System.out.println("Convert PDF to TIFF, Done!");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "input.pdf";
String templateFile = "";
String dataFile = "";
String templateType = "";
String storage = "";
String folder = "";
File input = Utils.stream2file("input","pdf", context.getResources().openRawResource(R.raw.sample_input));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// Invoke Aspose.PDF Cloud SDK API to create empty pdf file
DocumentResponse apiResponse = pdfApi.PutCreateDocument(fileName, templateFile, dataFile, templateType, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
System.out.println("Create Empty PDF, Done!");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "input.pdf";
String templateFile = "sample1.html";
String dataFile = "";
String templateType = "html";
String storage = "";
String folder = "";
Path inputFile = Utils.getPath(CreatePDFFromHtmlExample.class, fileName);
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(templateFile, "", "", input);
// Invoke Aspose.PDF Cloud SDK API to create pdf file from HTML
DocumentResponse apiResponse = pdfApi.PutCreateDocument(fileName, templateFile, dataFile, templateType, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
System.out.println("Create Empty HTML, Done!");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "sample1-tiff.pdf";
String templateFile = "Sample.tiff";
String dataFile = "";
String templateType = "tiff";
String storage = "";
String folder = "";
//Path inputFile = Utils.getPath(CreatePDFFromJPGExample.class, fileName);
File inputFile = Utils.stream2file("sample1-tiff","pdf", context.getResources().openRawResource(R.raw.sample1));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(templateFile, "", "", inputFile);
// Invoke Aspose.PDF Cloud SDK API to create pdf from TIFF
DocumentResponse apiResponse = pdfApi.PutCreateDocument(fileName, templateFile, dataFile, templateType, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
System.out.println("Create PDF from TIFF, Done!");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "input.pdf";
String templateFile = "sample.xsl";
String dataFile = "sample.xml";
String templateType = "xml";
String storage = "";
String folder = "";
//Path templateFilePath = Utils.getPath(CreatePDFFromXMLExample.class, templateFile);
//Path dataFilePath = Utils.getPath(CreatePDFFromXMLExample.class, dataFile);
File templateFilePath = Utils.stream2file("sample","xsl", context.getResources().openRawResource(R.raw.sample));
File dataFilePath = Utils.stream2file("sample","xml", context.getResources().openRawResource(R.raw.sampleXML));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(templateFile, "", "", templateFilePath);
storageApi.PutCreate(dataFile, "", "", dataFilePath);
// Invoke Aspose.PDF Cloud SDK API to create Pdf from XML
DocumentResponse apiResponse = pdfApi.PutCreateDocument(fileName, templateFile, dataFile, templateType, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
System.out.println("Create PDF from XML, Done!");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "sample1-svg.pdf";
String templateFile = "Example.svg";
String dataFile = "";
String templateType = "svg";
String storage = "";
String folder = "";
File fileNameFile = Utils.stream2file("sample1-svg","pdf", context.getResources().openRawResource(R.raw.sample1));
File templateFileFile = Utils.stream2file("Example","svg", context.getResources().openRawResource(R.raw.Example));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(templateFile, "", "",fileNameFile);
// Invoke Aspose.PDF Cloud SDK API to create pdf from SVG
DocumentResponse apiResponse = pdfApi.PutCreateDocument(fileName, templateFile, dataFile, templateType, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
System.out.println("Create PDF from SVG, Done!");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "sample1-merged.pdf";
String storage = "";
String folder = "";
MergeDocuments body = new MergeDocuments();
String[] fileNames={ "sample1.pdf", "input.pdf" };
body.setList(Arrays.asList(fileNames)) ;
//Path sampleFilePath = Utils.getPath(MergeMultiplePDFFiles.class, "sample1.pdf");
//Path dataFilePath = Utils.getPath(MergeMultiplePDFFiles.class, "input.pdf");
File sampleFilePath = Utils.stream2file("sample","pdf", context.getResources().openRawResource(R.raw.Sample));
File dataFilePath = Utils.stream2file("test","pdf", context.getResources().openRawResource(R.raw.test));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate("sample1.pdf", "", "", sampleFilePath);
storageApi.PutCreate("input.pdf", "", "", dataFilePath);
// Invoke Aspose.PDF Cloud SDK API to merge pdf files
DocumentResponse apiResponse = pdfApi.PutMergeDocuments(fileName, storage, folder, body);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
System.out.println("Merge Multiple PDF Files, Done!");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "sample1-input.pdf";
String signatureFileName = "pkc7-sample1.pfx";
int pageNumber = 1;
String storage = "";
String folder = "";
Signature body = new Signature();
body.setAuthority( "Naeem Akram");
body.setLocation ( "Gojra");
body.setContact( "naeem.akram@aspose.com");
body.setDate ("06/24/2015 2:00:00.000 AM");
body.setFormFieldName ( "Signature1");
body.setPassword ( "aspose");
Rectangle rect = new Rectangle();
rect.setX (100);
rect.setY (100);
rect.setHeight ( 100);
rect.setWidth ( 200);
body.setRectangle ( rect);
body.setSignaturePath( signatureFileName);
body.setSignatureType ( "PKCS7");
body.setVisible(true);
//Path inputFile = Utils.getPath(SignPDFDocumentsExample.class, fileName);
//Path signitureFilePath = Utils.getPath(SignPDFDocumentsExample.class, fileName);
File input = Utils.stream2file("sample1-input","pdf", context.getResources().openRawResource(R.raw.sample_input));
File signitureFilePath = Utils.stream2file("pkc7-sample1","pfx", context.getResources().openRawResource(R.raw.pkc7_sample));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
storageApi.PutCreate(signatureFileName, "", "", signitureFilePath);
// Invoke Aspose.PDF Cloud SDK API to sign Pdf document
SaaSposeResponse apiResponse = pdfApi.PostSignPage(fileName, pageNumber, storage, folder, body);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
System.out.println("Sign PDF Documents, Done!");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "input.pdf";
String format = "pdf";
int from = 1;
int to = 2;
String storage = "";
String folder = "";
File inputFile = Utils.stream2file("input","pdf", context.getResources().openRawResource(R.raw.sample_input));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", inputFile);
// Invoke Aspose.PDF Cloud SDK API to split pdf files
SplitResultResponse apiResponse = pdfApi.PostSplitDocument(fileName, format, from, to, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
System.out.println("Split PDF Files, Done!");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "sample1-field.pdf";
String storage = "";
String folder = "";
File input = Utils.stream2file("input","pdf", context.getResources().openRawResource(R.raw.sample_field));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// Invoke Aspose.PDF Cloud SDK API to get all fields from pdf document
FieldsResponse apiResponse = pdfApi.GetFields(fileName, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
for (Field field : apiResponse.getFields().getList())
{
System.out.println("Name:" + field.getName());
System.out.println("Value:" + field.getValues().get(0));
}
System.out.println("Get all Form Fields from the PDF Document, Done!");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "sample1-field.pdf";
String storage = "";
String folder = "";
File input = Utils.stream2file("input","pdf", context.getResources().openRawResource(R.raw.sample_field));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// Invoke Aspose.PDF Cloud SDK API to get field count
FieldsResponse apiResponse = pdfApi.GetFields(fileName, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
int count = apiResponse.getFields().getList().size();
System.out.println("Count" + count);
System.out.println("Get Form Field Count from a PDF Document, Done!");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "sample1-field.pdf";
String fieldName = "textbox1";
String storage = "";
String folder = "";
File input = Utils.stream2file("input","pdf", context.getResources().openRawResource(R.raw.sample_field));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// Invoke Aspose.PDF Cloud SDK API to get particular field
FieldResponse apiResponse = pdfApi.GetField(fileName, fieldName, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
Field field = apiResponse.getField();
System.out.println("Name" + field.getName());
System.out.println("Value" + field.getValues().get(0));
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "sample1-field.pdf";
String fieldName = "textbox1";
String storage = "";
String folder = "";
Field body = new Field();
body.setName ("textbox1");
String[] names={ "Aspose" };
body.setValues(Arrays.asList(names));
File input = Utils.stream2file("input","pdf", context.getResources().openRawResource(R.raw.sample_field));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// Invoke Aspose.PDF Cloud SDK API to update form field
FieldResponse apiResponse = pdfApi.PutUpdateField(fileName, storage, folder, fieldName, body);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
Field field = apiResponse.getField();
System.out.println("Name" + field.getName());
System.out.println("Value" + field.getValues().get(0));
System.out.println("Update a Form Field in a PDF Document, Done!");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "sample1-jpeg.pdf";
String templateFile = "Einstein_JPEG.jpg";
String dataFile = "";
String templateType = "jpeg";
String storage = "";
String folder = "";
File input = Utils.stream2file("Einstein_JPEG","jpg", context.getResources().openRawResource(R.raw.Einstein_JPEG));
File output=Utils.createTempFile("sample1-jpeg","pdf");
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(templateFile, "", "", input);
// Invoke Aspose.PDF Cloud SDK API to create pdf from JPEG
DocumentResponse apiResponse = pdfApi.PutCreateDocument(fileName, templateFile, dataFile, templateType, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
System.out.println("Create PDF from JPEG, Done!");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String name = "SampleImage";
String fileName = name + ".pdf";
int pageNumber = 1;
int imageNumber = 1;
String format = "jpeg";
int width = 0;
int height = 0;
String storage = "";
String folder = "";
File input = Utils.stream2file("input","pdf", context.getResources().openRawResource(R.raw.SampleImage));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// Invoke Aspose.PDF Cloud SDK API to extract particular image with default size
ResponseMessage apiResponse = pdfApi.GetImageWithFormat(fileName, pageNumber, imageNumber, format, width, height, storage, folder);
if (apiResponse != null)
{
System.out.println("Extract a Particular Image from a PDF Page with Default Size, Done!");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String name = "SampleImage";
String fileName = name + ".pdf";
int pageNumber = 1;
int imageNumber = 1;
String format = "jpeg";
int width = 200;
int height = 200;
String storage = "";
String folder = "";
File input = Utils.stream2file("input","pdf", context.getResources().openRawResource(R.raw.SampleImage));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// Invoke Aspose.PDF Cloud SDK API to extract particular image with specified size
ResponseMessage apiResponse = pdfApi.GetImageWithFormat(fileName, pageNumber, imageNumber, format, width, height, storage, folder);
if (apiResponse != null)
{
System.out.println("Extract a Particular Image from a PDF Page with Specified Size, Done!");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "SampleImage.pdf";
int pageNumber = 1;
String storage = "";
String folder = "";
File input = Utils.stream2file("input","pdf", context.getResources().openRawResource(R.raw.SampleImage));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// Invoke Aspose.PDF Cloud SDK API to get image count
ImagesResponse apiResponse = pdfApi.GetImages(fileName, pageNumber, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
int count = apiResponse.getImages().getList().size();
System.out.println("Image Count " + count);
System.out.println("Get Image Count from a PDF Page, Done!");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "SampleImage.pdf";
int pageNumber = 1;
String storage = "";
String folder = "";
File input = Utils.stream2file("input","pdf", context.getResources().openRawResource(R.raw.SampleImage));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// Invoke Aspose.PDF Cloud SDK API to get image count
ImagesResponse apiResponse = pdfApi.GetImages(fileName, pageNumber, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
int count = apiResponse.getImages().getList().size();
System.out.println("Image Count " + count);
System.out.println("Get Image Count from a PDF Page, Done!");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String name = "SampleImage";
String fileName = name + ".pdf";
int pageNumber = 1;
int imageNumber = 1;
String imageFile = "aspose-cloud.png";
String storage = "";
String folder = "";
File input = Utils.stream2file("input","pdf", context.getResources().openRawResource(R.raw.SampleImage));
try {
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// Invoke Aspose.PDF Cloud SDK API to replace image using local
// image stream
ImageResponse apiResponse = pdfApi.PostReplaceImage(fileName, pageNumber, imageNumber, imageFile, storage,
folder, input);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
System.out.println("Replace Image in a PDF file using Local Image Stream, Done!");
}
} catch (Exception ex) {
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String name = "SampleImage";
String fileName = name + ".pdf";
int pageNumber = 1;
int imageNumber = 1;
String imageFile = "aspose-cloud.png";
String storage = "";
String folder = "";
File input = Utils.stream2file("input","pdf", context.getResources().openRawResource(R.raw.SampleImage));
try {
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// Invoke Aspose.PDF Cloud SDK API to replace image using image file
ImageResponse apiResponse = pdfApi.PostReplaceImage(fileName, pageNumber, imageNumber, imageFile, storage,
folder, input);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
System.out.println("Replace Image in a PDF File using Image File, Done!");
}
} catch (Exception ex) {
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "sample1-input.pdf";
String storage = "";
String folder = "";
File input = Utils.stream2file("input","pdf", context.getResources().openRawResource(R.raw.sample1));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// Invoke Aspose.PDF Cloud SDK API to add new page
DocumentPagesResponse apiResponse = pdfApi.PutAddNewPage(fileName, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
System.out.println("Add a New Page in PDF, Done!");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String name = "sample1-input";
String fileName = name + ".pdf";
int pageNumber = 1;
String format = "jpeg";
int width = 0;
int height = 0;
String storage = "";
String folder = "";
File input = Utils.stream2file("input","pdf", context.getResources().openRawResource(R.raw.sample1));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// Invoke Aspose.PDF Cloud SDK API to convert pdf page to image with defualt size
ResponseMessage apiResponse = pdfApi.GetPageWithFormat(fileName, pageNumber, format, width, height, storage, folder);
if (apiResponse != null)
{
System.out.println("Convert a PDF Page to Image with Default Size, Done!");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String name = "sample1-input";
String fileName = name + ".pdf";
int pageNumber = 1;
String format = "jpeg";
int width = 300;
int height = 300;
String storage = "";
String folder = "";
File input = Utils.stream2file("input","pdf", context.getResources().openRawResource(R.raw.sample1));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// Invoke Aspose.PDF Cloud SDK API to convert pdf page to image with specified size
ResponseMessage apiResponse = pdfApi.GetPageWithFormat(fileName, pageNumber, format, width, height, storage, folder);
if (apiResponse != null)
{
System.out.println("Convert a PDF Page to Image with Specified Size, Done!");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "sample1-input.pdf";
int pageNumber = 1;
String storage = "";
String folder = "";
File input = Utils.stream2file("input","pdf", context.getResources().openRawResource(R.raw.sample1));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// Invoke Aspose.PDF Cloud SDK API to delete page from Pdf
SaaSposeResponse apiResponse = pdfApi.DeletePage(fileName, pageNumber, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
System.out.println("Delete Page from PDF, Done!");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "sample1-input.pdf";
String storage = "";
String folder = "";
File input = Utils.stream2file("input","pdf", context.getResources().openRawResource(R.raw.sample1));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// Invoke Aspose.PDF Cloud SDK API to get page count from pdf document
DocumentPagesResponse apiResponse = pdfApi.GetPages(fileName, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
int count = apiResponse.getPages().getList().size();
System.out.println("Total Page Count :: " + count);
System.out.println("Get PDF Document Page Count, Done!");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "sample1-merged.pdf";
int pageNumber = 1;
int newIndex = 2;
String storage = "";
String folder = "";
File input = Utils.stream2file("input","pdf", context.getResources().openRawResource(R.raw.sample1));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// Invoke Aspose.PDF Cloud SDK API to move pages to new location
SaaSposeResponse apiResponse = pdfApi.PostMovePage(fileName, pageNumber, newIndex, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
System.out.println("Move PDF Pages to New Locations in a PDF File, Done!");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "Sample-Annotation.pdf";
String storage = "";
String folder = "";
File input = Utils.stream2file("input","pdf", context.getResources().openRawResource(R.raw.Sample_Annotation));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// Invoke Aspose.PDF Cloud SDK API to get all document properies
DocumentPropertiesResponse apiResponse = pdfApi.GetDocumentProperties(fileName, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
for (DocumentProperty docProp : apiResponse.getDocumentProperties().getList())
{
System.out.println(docProp.getName() + " :: " + docProp.getValue());
}
System.out.println("Get All Document Properties from a PDF, Done!");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "Sample-Annotation.pdf";
String propertyName = "Creator";
String storage = "";
String folder = "";
File input = Utils.stream2file("input","pdf", context.getResources().openRawResource(R.raw.Sample_Annotation));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// Invoke Aspose.PDF Cloud SDK API to get particular document property
DocumentPropertyResponse apiResponse = pdfApi.GetDocumentProperty(fileName, propertyName, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
DocumentProperty docProp = apiResponse.getDocumentProperty();
System.out.println(docProp.getName() + " :: " + docProp.getValue());
System.out.println("Get a Particular Document Property from a PDF, Done!");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "Sample-Annotation.pdf";
String propertyName = "author";
String storage = "";
String folder = "";
DocumentProperty body = new DocumentProperty();
body.setName ("author");
body.setValue ("Naeem Akram");
body.setBuiltIn (true);
File input = Utils.stream2file("input","pdf", context.getResources().openRawResource(R.raw.Sample_Annotation));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",input);
// Invoke Aspose.PDF Cloud SDK API to set single pdf document property
DocumentPropertyResponse apiResponse = pdfApi.PutSetProperty(fileName, propertyName, storage, folder, body);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
DocumentProperty docProp = apiResponse.getDocumentProperty();
System.out.println(docProp.getName() + " :: " + docProp.getValue());
System.out.println("Set a Single Document Property in a PDF, Done!");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "Sample-Annotation.pdf";
String storage = "";
String folder = "";
File input = Utils.stream2file("input","pdf", context.getResources().openRawResource(R.raw.Sample_Annotation));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// Invoke Aspose.PDF Cloud SDK API to remove all document properties
SaaSposeResponse apiResponse = pdfApi.DeleteProperties(fileName, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
System.out.println("Remove All Document Properties from a PDF, Done!");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "sample1-input.pdf";
int pageNumber = 1;
int fragmentNumber = 1;
String withEmpty = "";
String storage = "";
String folder = "";
File input = Utils.stream2file("input","pdf", context.getResources().openRawResource(R.raw.Sample_Annotation));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// Invoke Aspose.PDF Cloud SDK API to get text from particular fragment of pdf document
TextItemsResponse apiResponse = pdfApi.GetFragment(fileName, pageNumber, fragmentNumber, withEmpty, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
for (TextItem textItem : apiResponse.getTextItems().getList())
{
System.out.println("Text:" + textItem.getText());
}
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "sample1-input.pdf";
int pageNumber = 1;
String withEmpty = "";
String storage = "";
String folder = "";
File input = Utils.stream2file("input","pdf", context.getResources().openRawResource(R.raw.Sample_Annotation));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",input);
// Invoke Aspose.PDF Cloud SDK API to get text items from pdf page
TextItemsResponse apiResponse = pdfApi.GetPageTextItems(fileName, pageNumber, withEmpty, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
for(TextItem textItem : apiResponse.getTextItems().getList())
{
System.out.println("Text:" + textItem.getText());
}
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "sample1-input.pdf";
String withEmpty = "";
String storage = "";
String folder = "";
File input = Utils.stream2file("input","pdf", context.getResources().openRawResource(R.raw.Sample_Annotation));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// Invoke Aspose.PDF Cloud SDK API to get text items from pdf document
TextItemsResponse apiResponse = pdfApi.GetTextItems(fileName, withEmpty, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
for (TextItem textItem : apiResponse.getTextItems().getList())
{
System.out.println("Text:" + textItem.getText());
}
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "sample1-input.pdf";
int pageNumber = 1;
int fragmentNumber = 1;
String withEmpty = "";
String storage = "";
String folder = "";
File input = Utils.stream2file("input","pdf", context.getResources().openRawResource(R.raw.Sample_Annotation));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// Invoke Aspose.PDF Cloud SDK API to get segment count from a pdf fragment
TextItemsResponse apiResponse = pdfApi.GetFragments(fileName, fragmentNumber, withEmpty, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
System.out.println("Fragment Count :" + apiResponse.getTextItems().getList().size());
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "sample1-input.pdf";
int pageNumber = 1;
int fragmentNumber = 1;
String withEmpty = "";
String storage = "";
String folder = "";
File input = Utils.stream2file("input","pdf", context.getResources().openRawResource(R.raw.Sample_Annotation));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// Invoke Aspose.PDF Cloud SDK API to get segment count from a pdf fragment
TextItemsResponse apiResponse = pdfApi.GetSegments(fileName, pageNumber, fragmentNumber, withEmpty, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
System.out.println("Segment Count :" + apiResponse.getTextItems().getList().size());
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "sample1-input.pdf";
int pageNumber = 1;
int fragmentNumber = 1;
String storage = "";
String folder = "";
File input = Utils.stream2file("input","pdf", context.getResources().openRawResource(R.raw.Sample_Annotation));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// Invoke Aspose.PDF Cloud SDK API to get text format of pdf fragment
TextFormatResponse apiResponse = pdfApi.GetFragmentTextFormat(fileName, pageNumber, fragmentNumber, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
TextFormat segTextFormat = apiResponse.getTextFormat();
System.out.println("Segment Font Name - " + segTextFormat.getFontName());
System.out.println("Segment Font Size - " + segTextFormat.getFontSize().floatValue());
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "segments.pdf";
int pageNumber = 1;
int fragmentNumber = 1;
int segmentNumber = 1;
String storage = "";
String folder = "";
File input = Utils.stream2file("input","pdf", context.getResources().openRawResource(R.raw.Sample_Annotation));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// Invoke Aspose.PDF Cloud SDK API to get text format of particular segment
TextFormatResponse apiResponse = pdfApi.GetSegmentTextFormat(fileName, pageNumber, fragmentNumber, segmentNumber, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
TextFormat segTextFormat = apiResponse.getTextFormat();
System.out.println("Segment Font Name - " + segTextFormat.getFontName());
System.out.println("Segment Font Size - " + segTextFormat.getFontSize().floatValue());
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "sample1-input.pdf";
int pageNumber = 1;
String withEmpty = "";
String storage = "";
String folder = "";
File input = Utils.stream2file("input","pdf", context.getResources().openRawResource(R.raw.Sample_Annotation));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// Invoke Aspose.PDF Cloud SDK API to get fragment count from a pdf page
TextItemsResponse apiResponse = pdfApi.GetFragments(fileName, pageNumber, withEmpty, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
System.out.println("Fragment Count :" + apiResponse.getTextItems().getList().size());
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "sample1-input.pdf";
int pageNumber = 1;
String storage = "";
String folder = "";
TextReplace body = new TextReplace();
body.setOldValue ( "Sample PDF");
body.setNewValue ( "Sample Aspose PDF");
File input = Utils.stream2file("input","pdf", context.getResources().openRawResource(R.raw.Sample_Annotation));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// Invoke Aspose.PDF Cloud SDK API to replace text in a pdf page
PageTextReplaceResponse apiResponse = pdfApi.PostPageReplaceText(fileName, pageNumber, storage, folder, body);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
System.out.println("Replace Text in a PDF Page, Done!");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "sample1-input.pdf";
int pageNumber = 1;
String storage = "";
String folder = "";
TextReplaceListRequest body = new TextReplaceListRequest();
TextReplace tr1 = new TextReplace();
tr1.setOldValue("Sample");
tr1.setNewValue("Aspose Sample");
TextReplace tr2 = new TextReplace();
tr2.setOldValue ( "PDF");
tr2.setNewValue ( "PDF Document");
TextReplace[] arr={ tr1, tr2 };
body.setTextReplaces ( new ArrayList<TextReplace> (Arrays.asList(arr)));
File input = Utils.stream2file("input","pdf", context.getResources().openRawResource(R.raw.Sample_Annotation));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",input);
// Invoke Aspose.PDF Cloud SDK API to replace mutiple text in pdf page
PageTextReplaceResponse apiResponse = pdfApi.PostPageReplaceTextList(fileName, pageNumber, storage, folder, body);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
System.out.println("Replace Multiple Texts in a PDF Page, Done!");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "sample1-input.pdf";
String storage = "";
String folder = "";
TextReplaceListRequest body = new TextReplaceListRequest();
TextReplace tr1 = new TextReplace();
tr1.setOldValue( "Sample");
tr1.setNewValue ( "Aspose Sample");
TextReplace tr2 = new TextReplace();
tr2.setOldValue ("PDF");
tr2.setNewValue ( "PDF Document");
TextReplace[] arr={ tr1, tr2 };
body.setTextReplaces ( new ArrayList<TextReplace> (Arrays.asList(arr)));
File input = Utils.stream2file("input","pdf", context.getResources().openRawResource(R.raw.Sample_Annotation));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// Invoke Aspose.PDF Cloud SDK API to replace multiple text in PDF
DocumentTextReplaceResponse apiResponse = pdfApi.PostDocumentReplaceTextList(fileName, storage, folder, body);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
System.out.println("Replace Multiple Texts in a PDF, Done!");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "sample1-input.pdf";
String storage = "";
String folder = "";
TextReplace body = new TextReplace();
body.setOldValue ( "Sample PDF");
body.setNewValue ( "Sample Aspose PDF");
File input = Utils.stream2file("input","pdf", context.getResources().openRawResource(R.raw.Sample_Annotation));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// Invoke Aspose.PDF Cloud SDK API to replace text in a pdf file
DocumentTextReplaceResponse apiResponse = pdfApi.PostDocumentReplaceText(fileName, storage, folder, body);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
System.out.println("Replace Text in a PDF File, Done!");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "sample1-input.pdf";
String storage = "";
String folder = "";
TextReplace body = new TextReplace();
body.setOldValue ( "Sample PDF");
body.setNewValue ( "Sample Aspose PDF");
File input = Utils.stream2file("input","pdf", context.getResources().openRawResource(R.raw.Sample_Annotation));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// Invoke Aspose.PDF Cloud SDK API to replace text in a pdf file
DocumentTextReplaceResponse apiResponse = pdfApi.PostDocumentReplaceText(fileName, storage, folder, body);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
System.out.println("Replace Text in a PDF File, Done!");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "sample1-input.pdf";
String imageFile = "aspose-cloud.png";
int pageNumber = 1;
String storage = "";
String folder = "";
Stamp body = new Stamp();
body.setFileName ( imageFile);
body.setBackground ( true);
body.setType ( "Image");
body.setPageIndex ( 0);
body.setLeftMargin ( 0.0);
body.setOpacity ( 0.5);
body.setRightMargin ( 0.0);
body.setTopMargin ( 0.0);
body.setYIndent ( 100.0);
body.setXIndent ( 100.0);
body.setZoom ( 1.0);
body.setTextState ( null);
body.setWidth ( 300.0);
body.setHeight ( 300.0);
File inputFile = Utils.stream2file("sample1-input","pdf", context.getResources().openRawResource(R.raw.sample1));
File inputImage = Utils.stream2file("aspose-cloud","png", context.getResources().openRawResource(R.raw.aspose_cloud));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",inputFile);
storageApi.PutCreate(imageFile, "", "", inputImage);
// Invoke Aspose.PDF Cloud SDK API to add image stamp to a pdf page
SaaSposeResponse apiResponse = pdfApi.PutPageAddStamp(fileName, pageNumber, storage, folder, body);
if (apiResponse != null)
{
System.out.println("Add Image Stamp (Watermark) to a PDF Page, Done!");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
// For complete examples and data files, please go to
// https://github.com/aspose-tasks/Aspose.Tasks-for-Java
String fileName = "sample1-input.pdf";
String pdfName = "Sample.pdf";
int pageNumber = 1;
String storage = "";
String folder = "";
Stamp body = new Stamp();
body.setFileName(pdfName);
body.setBackground(true);
body.setType("Image");
body.setPageIndex(0);
body.setLeftMargin(0.0);
body.setOpacity(0.5);
File inputFile = Utils.stream2file("sample1-input","pdf", context.getResources().openRawResource(R.raw.sample1));
File inputImage = Utils.stream2file("aspose-cloud","png", context.getResources().openRawResource(R.raw.aspose_cloud));
try {
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", inputFile);
storageApi.PutCreate(pdfName, "", "", inputFile);
// Invoke Aspose.PDF Cloud SDK API to add pdf page as stamp to a pdf
// page
SaaSposeResponse apiResponse = pdfApi.PutPageAddStamp(fileName, pageNumber, storage, folder, body);
if (apiResponse != null) {
System.out.println("Add PDF Page as Stamp (Watermark) to a PDF Page, Done!");
}
} catch (Exception ex) {
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "sample1-input.pdf";
String pdfName = "Sample.pdf";
int pageNumber = 1;
String storage = "";
String folder = "";
Stamp body = new Stamp();
body.setFileName ( pdfName);
body.setBackground ( true);
body.setType ( "Image");
body.setPageIndex ( 0);
body.setLeftMargin ( 0.0);
body.setOpacity ( 0.5);
body.setRightMargin ( 0.0);
body.setTopMargin ( 0.0);
body.setYIndent ( 100.0);
body.setXIndent ( 100.0);
body.setZoom ( 1.0);
body.setTextState ( null);
body.setWidth ( 300.0);
body.setHeight ( 300.0);
File inputFile = Utils.stream2file("sample1-input","pdf", context.getResources().openRawResource(R.raw.sample1));
File inputImage = Utils.stream2file("aspose-cloud","png", context.getResources().openRawResource(R.raw.aspose_cloud));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", inputFile);
storageApi.PutCreate(pdfName, "", "",inputFile);
// Invoke Aspose.PDF Cloud SDK API to add pdf page as stamp to a pdf page
SaaSposeResponse apiResponse = pdfApi.PutPageAddStamp(fileName, pageNumber, storage, folder, body);
if (apiResponse != null)
{
System.out.println("Add PDF Page as Stamp (Watermark) to a PDF Page, Done!");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-Cloud
String fileName = "sample1-input.pdf";
int pageNumber = 1;
String storage = "";
String folder = "";
Stamp body = new Stamp();
body.setValue ("Aspose.com");
body.setBackground ( true);
body.setType ("Text");
File inputFile = Utils.stream2file("sample1-input","pdf", context.getResources().openRawResource(R.raw.sample1));
File inputImage = Utils.stream2file("aspose-cloud","png", context.getResources().openRawResource(R.raw.aspose_cloud));
try
{
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
PdfApi pdfApi = new PdfApi(Configuration.apiKey, Configuration.appSID, true);
// Upload source file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", inputFile);
// Invoke Aspose.PDF Cloud SDK API to add text stamp to a pdf page
SaaSposeResponse apiResponse = pdfApi.PutPageAddStamp(fileName, pageNumber, storage, folder, body);
if (apiResponse != null)
{
System.out.println("Add Text Stamp (Watermark) to a PDF Page, Done!");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment