public static void Run() { // ExStart:1 PdfApi pdfApi = new PdfApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); String fileName = "SampleAttachment.pdf"; String storage = ""; String folder = ""; try { // Upload source file to aspose cloud storage storageApi.PutCreate(fileName, "", "", System.IO.File.ReadAllBytes(Common.GetDataDir() + fileName)); // Invoke Aspose.PDF Cloud SDK API to get attachment count from a pdf AttachmentsResponse apiResponse = pdfApi.GetDocumentAttachments(fileName, storage, folder); if (apiResponse != null && apiResponse.Status.Equals("OK")) { Com.Aspose.PDF.Model.Attachments attachments = apiResponse.Attachments; int count = attachments.List.Count; Console.WriteLine("Count :: " + count); Console.ReadKey(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); } // ExEnd:1 }
public void Pdf_Attachments_Tests() { try { AttachmentsResponse attachmentsResponse = pdfService.Attachments.ReadDocumentAttachmentsInfo("pdf-sample.pdf", Utils.CloudStorage_Input_Folder); AttachmentResponse AttachmentResponse = pdfService.Attachments.ReadDocumentAttachmentInfoByItsIndex("pdf-sample.pdf", 1, Utils.CloudStorage_Input_Folder); pdfService.Attachments.DownloadDocumentAttachmentContentByItsIndex("pdf-sample.pdf", 1, Utils.CloudStorage_Input_Folder, Utils.Local_Output_Path + "pdf-out-attach.png"); } catch (Exception ex) { Assert.Fail(ex.Message); } }