Haɗa PowerPoint Kan layi

Haɗa PowerPoint | Haɗa PPT PPTX ta amfani da Java Cloud SDK

A cikin wannan labarin, za mu tattauna cikakkun bayanai kan yadda ake haɗa yawancin PowerPoints cikin fayil ɗin gabatarwa ɗaya. Ana amfani da PowerPoints don wakilcin bayanai da taƙaitaccen bayani a cikin al’adun kamfanoni, haka kuma ƴan kasuwa da ɗalibai suna amfani da su don shirye-shiryen nunin faifai. Wani bangare na shahararru shine ƙirƙirar koyawa, fayilolin dijital, raye-raye na asali, ko nunin faifan hoto yana nuna halitta. Koyaya, lokacin da ƙungiyoyi ke aiki a cikin mahalli da aka rarraba, ƙila mu sami buƙatu don haɗa gabatarwar PowerPoint. Don haka wannan labarin yana ba da haske kan cikakkun bayanai don haɗa yawancin PowerPoints zuwa Gabatarwa ɗaya ta amfani da Java Cloud SDK.

Haɗa PowerPoint API

Don ƙirƙira da tsari, shirya da fitarwa PPT ko PPTX zuwa PDF, JPEG, PNG ko GIF da dai sauransu, mun ƙirƙiri ƙaramin lambar API mai suna Aspose.Slides Cloud. Gine-gine na tushen REST yana ba ku damar kiran ayyukan API na yau da kullun akan kowane dandamali. Yanzu don aiwatar da fasalin don haɗa gabatarwar PowerPoint a cikin aikace-aikacen Java, mun ƙirƙiri musamman Aspose.Slides Cloud SDK don Java. Don haka don amfani da SDK, duk abin da kuke buƙatar yi shine ƙara bayanin sa a cikin pom.xml na maven build project.

<repositories> 
    <repository>
        <id>aspose-cloud</id>
        <name>artifact.aspose-cloud-releases</name>
        <url>https://artifact.aspose.cloud/repo</url>
    </repository>   
</repositories>

<dependencies>
    <dependency>
        <groupId>com.aspose</groupId>
        <artifactId>aspose-slides-cloud</artifactId>
        <version>22.9.0</version>
    </dependency>
</dependencies>

Da zarar an ƙara bayanin SDK, mataki mai mahimmanci na gaba shine tabbatarwa tare da Aspose Cloud. Idan ba ku da asusun da ke akwai, da fatan za a ƙirƙiri asusun kyauta ta amfani da adireshin imel mai aiki. Sannan shiga ta amfani da sabon asusun da aka ƙirƙira kuma bincika/ƙirƙiri ID na abokin ciniki da Sirrin Abokin ciniki a Cloud Dashboard. Ana buƙatar waɗannan cikakkun bayanai don dalilai na tantancewa a cikin sassan masu zuwa.

Haɗa PowerPoint a cikin Java

Wannan sashe yana bayani dalla-dalla kan yadda za mu iya haɗa abubuwan gabatarwa ta amfani da Java Cloud SDK. Lura cewa don haɗa PowerPoint, shigar da PowerPoint za a iya loda shi daga faifan gida, loda shi daga ma’ajiyar girgije ko ma loda shi kai tsaye daga URL na yanar gizo. Da fatan za a bi umarnin da aka ƙayyade a ƙasa.

  • Da farko, ƙirƙiri wani abu na SlidesApi yayin samar da ClientID da sirrin Abokin ciniki azaman muhawara.
  • Abu na biyu, ƙirƙirar wani abu na FileInfo inda muke samar da bayanai don PowerPoint na farko
  • Na uku, ƙirƙiri misali na ArrayList wanda zai riƙe jerin fayilolin PPT waɗanda za a haɗa su
  • Mataki na gaba shine ƙirƙirar wani abu daban na PresentationToMerge don kowane PowerPoint don haɗuwa
  • Yanzu don loda PowerPoint daga ma’ajiyar gida, muna buƙatar amfani da ƙimar KYAUTA daga ƙididdigar PresentationToMerge
  • Domin tantance takamaiman nunin faifai a cikin PowerPoint da za a haɗe, muna amfani da hanyar saitaSlides(…)
  • Mataki na gaba shine saita tsari don haɗa fayilolin gabatarwa kuma don wannan dalili, za mu yi amfani da abun OrderedMergeRequest kuma muyi amfani da hanyar saitiPresentations(..)
  • A ƙarshe kira hanyar mergeAndSaveOnline(…) don haɗa abubuwan gabatarwar wutar lantarki da adana fayil ɗin sakamako a cikin ma’ajin gajimare.
try
    {	    
        // Samu ClientID da ClientSecret daga https://dashboard.aspose.cloud/
	String clientId = "7ef10407-c1b7-43bd-9603-5ea9c6db83cd";
	String clientSecret = "ba7cc4dc0c0478d7b508dd8ffa029845";

	// ƙirƙirar misali na SlidesApi
	SlidesApi slidesApi = new SlidesApi(clientId,clientSecret);
        
	// Tattara abubuwan gabatarwa don haɗawa.
	FileInfo fileInfo = new FileInfo();
	// karanta gabatarwar shigarwa 
	fileInfo.setData(Files.readAllBytes(Paths.get("TemplateCV.pptx")));
	// saita sunan tushen PowerPoint
	fileInfo.setName("TemplateCV.pptx");

	// Ƙirƙiri Jerin Tsari na Abun FayilInfo
	List<FileInfo> files = new ArrayList<FileInfo>();
	// ƙara abu FileInfo zuwa jerin tsararru
	files.add(fileInfo);

	// Shirya bayanai don gabatarwar farko don haɗawa.
	PresentationToMerge presentation1 = new PresentationToMerge();
	// karanta PowerPoint daga faifan gida
	presentation1.setSource(PresentationToMerge.SourceEnum.REQUEST);
	// saita hanya don fayil ɗin PowerPoint na farko
	presentation1.setPath("TemplateCV.pptx");
	// saka nunin faifai na PowerPoint waɗanda muke buƙatar haɗa su
	presentation1.setSlides(Arrays.asList(1, 2));
	       
	// Shirya bayanai don gabatarwar farko don haɗawa.
	PresentationToMerge presentation2 = new PresentationToMerge();
	presentation2.setPath("Presentation1.pptx");
	// saita bayanan kalmar sirri idan PowerPoint yana kare kalmar sirri
	///presentation2.setPassword("my_password");
	// saka tushen azaman Cloud ajiya
	presentation2.setSource(PresentationToMerge.SourceEnum.STORAGE);

	// Shirya bayanai don gabatarwar farko don haɗawa.
	PresentationToMerge presentation3 = new PresentationToMerge();
	// hanyar PowerPoint azaman URL na yanar gizo
	presentation3.setPath("https://github.com/aspose-slides-cloud/aspose-slides-cloud-java/blob/master/TestData/test-unprotected.pptx");
	presentation3.setSlides(Arrays.asList(1));
	// saita darajar hanya azaman URL
	presentation3.setSource(PresentationToMerge.SourceEnum.URL);

        // Shirya buƙatar haɗuwa.
	OrderedMergeRequest request = new OrderedMergeRequest();
	// saita odar haɗuwa don gabatarwar PowerPoint
	request.setPresentations(Arrays.asList(presentation1, presentation2));//, presentation3));
  
        // kira API don haɗa PowerPoint da adana fitarwa a cikin ma'ajin gajimare
	slidesApi.mergeAndSaveOnline("Merged.pptx", files, request, "internal");  // mergeOnline(files, request, null);
        
        System.out.println("Merge PowerPoint successful !");
	}catch(Exception ex)
	{
	    System.out.println(ex);
	}
Haɗa samfotin PowerPoint

Hoto 1: - Haɗa Preview PowerPoint

Za a iya sauke samfurin fayilolin da aka yi amfani da su a cikin misalin sama daga TemplateCV.pptx, Presentation1.pptx da Merged.ppt.

Haɗa PowerPoint ta amfani da Umarnin CURL

Umarnin CURL masu zaman kansu ne kuma ana iya aiwatar da su akan kowane dandamali. Don haka wannan sashe yana raba cikakkun bayanai kan yadda ake haɗa gabatarwar PowerPoint ta amfani da umarnin cURL. Don haka akan abubuwan da ake buƙata don wannan hanyar, da farko muna buƙatar samar da alamar samun damar JWT (dangane da shaidar abokin ciniki) yayin aiwatar da umarni mai zuwa.

curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=bb959721-5780-4be6-be35-ff5c3a6aa4a2&client_secret=4d84d5f6584160cbd91dba1fe145db14" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"

Da zarar mun sami alamar JWT, mataki na gaba shine haɗa gabatarwar PowerPoint ta amfani da umarni mai zuwa. Lura cewa a cikin bin umarni, muna haɗa faifan farko daga gabatarwar farko kuma daga gabatarwa na biyu, nunin faifai na 1 da na 3 sun haɗu. An adana haɗin PPTX a cikin ma’ajin gajimare.

curl -v -X PUT "https://api.aspose.cloud/v3.0/slides/merge?outPath=newResultant.pptx" \
-H  "accept: application/json" \
-H  "authorization: Bearer <JWT Token>" \
-H  "Content-Type: application/json" \
-d "{  \"Presentations\": [    {      \"Path\": \"Presentation1.pptx\",      \"Password\": \"string\",      \"Slides\": [        1      ],      \"Source\": \"Storage\"    },    {      \"Path\": \"test-unprotected.pptx\",      \"Password\": \"string\",      \"Slides\": [        1,3      ],      \"Source\": \"Storage\"    }  ]}"

Kammalawa

Wannan labarin ya haskaka mana cikakkun bayanai don haɗa gabatarwar PowerPoint ta amfani da Java Cloud SDK. Ban da snippet code na Java, mun kuma koyi game da cikakkun bayanai kan yadda ake haɗa wuraren wuta da yawa zuwa ɗaya ta amfani da umarnin cURL. Bugu da ƙari, muna ba da shawarar bincika samfuri Takardu don koyo game da plethora na abubuwan ban mamaki da Cloud API ke bayarwa. Hakanan, da fatan za a lura cewa ana buga duk SDK ɗin mu a ƙarƙashin lasisin MIT, don haka kuna iya yin la’akari da zazzage cikakkiyar lambar tushe daga GitHub kuma gyara ta gwargwadon buƙatun ku. A cikin kowane matsala, kuna iya la’akari da kusantar mu don ƙuduri mai sauri ta hanyar [Tallafin tallafin samfur 9.

Labarai masu alaka

Da fatan za a ziyarci hanyoyin haɗin yanar gizon don ƙarin koyo game da: