pdf zuwa jpg

Maida pdf zuwa jpg ta amfani da Cloud SDK Java

PDF ana amfani da fayiloli sosai akan intanit don bayanai da raba bayanai. Yanzu don duba waɗannan takaddun, muna buƙatar amfani da takamaiman aikace-aikace amma idan muka adana PDF azaman JPG, ana iya duba shi akan kowace dandamali da kowace na’ura. Hakanan, girman fayil ɗin yana raguwa sosai. Bugu da ƙari, za mu iya haɓaka mai duba PDF cikin sauƙi saboda, da zarar mun adana PDF a matsayin hoto, za mu iya loda hoton a kowane mai bincike. Don haka, a cikin wannan labarin, za mu tattauna cikakkun bayanai don canza PDF zuwa JPG akan layi ta amfani da Cloud API.

API ɗin Canjin JPG zuwa PDF

Aspose.PDF Cloud SDK don Java samfuri ne mai ban mamaki wanda ke ba mu damar aiwatar da ƙirƙirar fayil ɗin PDF, magudi, da jujjuya zuwa nau’ikan tsararrun tallafi a cikin aikace-aikacen Java. Hakanan yana ba ku damar canza PDF zuwa Hoto. Don haka don amfani da SDK, da farko muna buƙatar shigar da shi ta hanyar ƙara cikakkun bayanai a cikin pom.xml na maven build type project.

<repositories>
    <repository>
        <id>AsposeJavaAPI</id>
        <name>Aspose Cloud Repository</name>
        <url>https://repository.aspose.cloud/repo/</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
		<groupId>com.aspose</groupId>
		<artifactId>aspose-pdf-cloud</artifactId>
		<version>21.11.0</version>
	</dependency>
</dependencies>

Yanzu muna buƙatar ƙirƙirar asusun kyauta ta ziyartar Aspose.Cloud dashboard. Kuna iya yin rajista ta amfani da asusun GitHub ɗinku ko Google, ko danna maɓallin Ƙirƙiri sabon Asusu don kammala biyan kuɗi.

Canza PDF zuwa JPG a Java

Da fatan za a bi umarnin da aka kayyade a ƙasa don cika buƙatun don sauya PDF zuwa JPG akan layi.

  • Na farko, ƙirƙiri misali na ajin PdfApi inda muke ba da Sirrin Abokin ciniki ID azaman muhawara
  • Abu na biyu, karanta abun ciki na shigarwar PDF daga faifan gida ta amfani da abin Fayil
  • Yanzu shigar da fayil ɗin PDF zuwa ma’ajiyar gajimare ta amfani da hanyar uploadFile(…).
  • Ƙayyade ma’auni don hoton jpg na sakamako (waɗannan dalilai ne na zaɓi)
  • A ƙarshe, kira hanyar putPageConvertToJpeg(…) na PdfApi wanda ke ɗaukar shigar da PDF, lambar shafi don canzawa, haifar da sunan JPG, da girma don sakamakon sakamakon.
// don ƙarin misalai, da fatan za a ziyarci https://github.com/aspose-pdf-cloud/aspose-pdf-cloud-java

try
    {
    // Samu ClientID da ClientSecret daga https://dashboard.aspose.cloud/
    String clientId = "bbf94a2c-6d7e-4020-b4d2-b9809741374e";
    String clientSecret = "1c9379bb7d701c26cc87e741a29987bb";
    
    // ƙirƙirar misali na PdfApi
    PdfApi pdfApi = new PdfApi(clientSecret,clientId);

    // sunan shigar da takaddun PDF
    String inputFile = "45.pdf";
    // sunan sakamakon hoton JPG
    String resultantImage = "Resultant.jpg";
  
    // karanta abun ciki na shigar da fayil ɗin PDF
    File file = new File("c://Users/"+inputFile);
    
    // loda PDF zuwa ma'ajiyar gajimare
    pdfApi.uploadFile("input.pdf", file, null);
        
    // lambar shafi na PDF da za a canza
    int pageNumber = 1;
  
    // Nisa na sakamakon hoton JPG
    int width = 800;
    // tsayin sakamakon hoton JPG
    int height = 1000;
  
    // kira API don canza PDF zuwa JPG
    pdfApi.putPageConvertToJpeg("input.pdf", pageNumber, resultantImage, width, height, null, null);
    
    // buga saƙon matsayi na canji
    System.out.println("PDF to JPG conversion sucessfull !");
		}catch(Exception ex)
		{
			System.out.println(ex);
		}

PDF zuwa Hoto ta amfani da Umarnin CURL

Hakanan zamu iya canza PDF zuwa Tsarin Hoto ta amfani da umarnin cURL akan tashar layin umarni. Koyaya, don samun damar Aspose.PDF Cloud, muna buƙatar fara samar da JSON Yanar Gizo Token (JWT) dangane da takaddun shaidar abokin cinikin ku. Da fatan za a aiwatar da umarni mai zuwa don samar da alamar JWT.

curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=bbf94a2c-6d7e-4020-b4d2-b9809741374e&client_secret=1c9379bb7d701c26cc87e741a29987bb" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"

Da zarar an ƙirƙiri JWT, da fatan za a aiwatar da umarni mai zuwa don canza PDF zuwa hoto da adana abin da aka fitar a cikin ma’ajiyar girgije.

curl -v -X PUT "https://api.aspose.cloud/v3.0/pdf/input.pdf/pages/1/convert/jpeg?outPath=resultant.jpg&width=800&height=1000" \
-H  "accept: application/json" \
-H  "authorization: Bearer <JWT Token>"

Kammalawa

A cikin wannan shafin, kun koyi fasaha mai ban mamaki don canza PDF zuwa JPG ta amfani da snippets code na Java. Hakazalika, kun kuma koyi game da amfani da umarnin cURL don adana PDF zuwa Hoto ta tashar layin umarni. Takaddun Samfuran babban tushe ne don koyan wasu iyakoki masu ban mamaki da API ke bayarwa. Don haka muna ba da shawarar ku gwada amfani da APIs ɗin mu kuma idan kun ci karo da kowace matsala yayin amfani da API, da fatan za ku ji daɗin tuntuɓar Zauren tallafin samfur na Kyauta.

Labarai masu alaka

Muna kuma ba da shawarar ziyartar shafukan yanar gizo masu zuwa don ƙarin cikakkun bayanai game da: