PDF zuwa MobiXML

Maida PDF zuwa MobiXML a Java

PDF yana ba da fa’idodi na musamman akan sauran tsarin fayil kamar yadda zai iya canza ayyukan kasuwanci, takaddun hukuma a cikin tsari wanda ke adana shimfida / tsara lokacin da aka duba shi akan kowane dandamali. Yana tabbatar da duk masu kallo suna ganin takarda kamar yadda aka yi niyya, ba tare da la’akari da aikace-aikacen asali ba, mai kallo, tsarin aiki, ko na’urar da ake amfani da ita. Amma, tsarin MobiXML shine bayanin kansa wanda ke nufin tsarin eBook MobiXML Standard kuma kusan duk masu karanta e-readers na zamani suna goyan bayansu, na’urorin hannu masu ƙarancin bandwidth. Don haka a cikin wannan labarin, za mu bincika cikakkun bayanai kan Yadda ake canza PDF zuwa MobiXML ta amfani da REST API.

API ɗin Processing PDF

Domin sarrafa fayil ɗin PDF da tsari, mun ƙirƙiri wani tushen bayani na REST mai suna Aspose.PDF Cloud. Yana ba ku damar ƙirƙira, shiryawa, sarrafa da canza takaddun PDF zuwa nau’ikan nau’ikan tsararrun tallafi. Yanzu kamar yadda muke buƙatar ƙarfin jujjuya PDF a cikin aikace-aikacen Java, don haka muna buƙatar ƙara bayanin Aspose.PDF Cloud SDK don Java a cikin aikace-aikacen Java ɗin mu ta haɗa da cikakkun bayanai a cikin pom.xml (maven build type project) .

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

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

Na gaba shine samun takaddun shaidar abokin ciniki daga Cloud Dashboard. Idan ba a riga ka yi rajista ba, da fatan za a yi rajista ta amfani da adireshin imel mai inganci kuma ka ɗauki keɓaɓɓen takaddun shaidarka.

PDF zuwa Mobi Converter a Java

Domin haɓaka PDF zuwa Mobi mai musanya ta amfani da Java, da fatan za a bi umarnin da aka kayyade a ƙasa. Lura cewa waɗannan matakan suna juyar da daftarin aiki na PDF (wanda ke kan ma’ajiyar gajimare) zuwa tsarin MOBIXML kuma a loda ma’ajin ZIP na sakamakon zuwa ma’ajiyar gajimare.

  • Ƙirƙiri misali na PdfApi inda muka ƙaddamar da keɓaɓɓen takaddun shaida azaman muhawara
  • Karanta shigar da PDF ta amfani da misalin Fayil kuma loda shi zuwa ma’ajiyar gajimare ta amfani da hanyar uploadFile(…) na ajin PdfAPi
  • Ƙirƙiri wani abu mai kirtani mai riƙon sunan don fayil ɗin MobiXML na sakamako
  • A ƙarshe, kira hanyar putPdfInStorageToMobiXml(…) don juyar da PDF zuwa Mobi akan layi da adana kayan sarrafawa zuwa ma’ajiyar girgije.
// don ƙarin misalai, da fatan za a ziyarci https://github.com/aspose-pdf-cloud/aspose-pdf-cloud-java/tree/master/Examples/src/main/java/com/aspose/asposecloudpdf/examples

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 name = "input.pdf";
		        
    // karanta abun ciki na shigar da fayil ɗin PDF
    File file = new File("/Users/Downloads/"+name);
		
    // loda PDF zuwa ma'ajiyar gajimare
    pdfApi.uploadFile("input.pdf", file, null);
  
    // resultant sunan fayil
    String resultantFile = "resultant.mobi";
		        
    // kira API don canza PDF zuwa MobiXML. An ajiye sakamakon fayil ɗin a cikin ma'ajin gajimare
    pdfApi.putPdfInStorageToMobiXml("input.pdf", resultantFile, null, null);
  
    // buga sakon nasara
    System.out.println("PDF to Mobi conversion successful !");
    }catch(Exception ex)
    {
        System.out.println(ex);
    }

PDF zuwa Mobi Kindle ta amfani da Umarnin CURL

Wani zaɓi don samun damar APIs REST shine ta umarnin cURL. Don haka a cikin wannan sashe, za mu canza PDF zuwa tsarin Mobi Kindle ta amfani da umarnin CURL. Yanzu a matsayin abin da ake buƙata, muna buƙatar fara samar da alamar samun damar JWT (bisa ga shaidar abokin ciniki) ta amfani 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"

Yanzu aiwatar da umarni mai zuwa wanda ke loda fayil ɗin PDF daga Ma’ajiyar girgije kuma yana adana sakamakon MobiXML zuwa faifan gida.

curl -v -X GET "https://api.aspose.cloud/v3.0/pdf/input.pdf/convert/mobixml" \
-H "accept: multipart/form-data" \
-H "authorization: Bearer <JWT Token>" \
-o "Resultant.mobi"

Tukwici mai sauri

Domin duba fayilolin Mobi akan layi, da fatan za a gwada amfani da Mai duba Mobi Kyauta.

Kammalawa

Mun wuce duk matakan da suka dace na amfani da REST API don sauya tsarin PDF zuwa tsarin Mobi (MobiXML). Wataƙila kun lura cewa cikakken tsari ya kasance mai sauƙi kuma mai sauƙi. Ko dai kuna iya canza PDF guda ɗaya ko aiwatar da tsari akan fayilolin PDF da yawa. Muna ba ku shawarar bincika Takardun Samfura wanda ya ƙunshi bayanin game da duk abubuwan ban sha’awa da API ke tallafawa a halin yanzu.

Idan kuna son samun dama ga lambar tushen Cloud SDK, ana samun ta akan GitHub (an buga ƙarƙashin lasisin MIT). A ƙarshe, idan kun ci karo da kowace matsala yayin amfani da API, da fatan za ku ji daɗin tuntuɓar mu ta [Zauren Tallafin Samfura] kyauta 9.

Labarai masu alaka

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