PDF zuwa PDF/A

Maida PDF zuwa PDF/A ta amfani da Java

PDF wani nau’in fayil ne wanda Adobe ya ƙirƙira wanda ke ba mutane hanya mai sauƙi, amintacciyar hanya don gabatarwa da musayar takardu - ba tare da la’akari da software, hardware, ko tsarin aiki ba. Bugu da ƙari, PDF/A tsari ne na tarihin tarihi na PDF wanda ke haɗa duk rubutun da aka yi amfani da shi a cikin takaddar cikin fayil ɗin PDF. Hakanan, kamar yadda fayil ɗin PDF / A ya ƙunshi duk abin da ake buƙata don nuna shi kuma babu abin da zai iya yin tasiri mara kyau ga nuni, yawancin masu amfani suna son fitar da PDF zuwa PDF/A. Don haka a cikin wannan jagorar mataki-mataki, za mu bincika cikakkun bayanai don canza PDF zuwa PDF/A ta amfani da Java.

API ɗin Canjin PDF

Aspose.PDF Cloud yana ba da damar ƙirƙira, gyara da sarrafa takaddun PDF. Yana ba da fasalin don loda fayil ɗin PDF kuma ya canza zuwa plethora na tsararrun tallafi. Yanzu don amfani da SDK, da farko muna buƙatar ƙara bayanin Aspose.PDF Cloud SDK don Java a cikin aikace-aikacen Java ɗin mu ta haɗa da bin cikakkun bayanai a cikin pom.xml (maven build type 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-cloud-pdf</artifactId>
        <version>21.11.0</version>
        <scope>compile</scope>
    </dependency>
</dependencies>

Da zarar an ƙara bayanin SDK, muna buƙatar samun bayanan 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 PDF/A ta amfani da Java

Wannan sashe yana ba da duk cikakkun bayanai masu mahimmanci don loda daftarin aiki na PDF daga ma’ajin gajimare kuma canza zuwa tsarin PDF/A. Lura cewa API ɗin a halin yanzu yana goyan bayan tsarin PDF/A masu zuwa (PDF/A1-A, PDF/A1-B, PDF/A-3A).

  • Da farko, ƙirƙiri misali na PdfApi inda muke ƙaddamar da keɓaɓɓen takaddun shaida azaman muhawara
  • Na biyu, karanta shigar da PDF ta amfani da misalin Fayil kuma loda shi zuwa gajimare ta amfani da hanyar uploadFile(…) na PdfAPi
  • Na uku, ayyana nau’in PDF/A azaman PDFA1A ta amfani da madaidaicin kirtani
  • A ƙarshe, kira hanyar putPdfInStorageToPdfA(…) don canza PDF zuwa PDF/A da adana fitarwa 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 = "PdfWithAcroForm.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);
  
    // sakamakon PDF/A nau'in
    String type = "PDFA1A";
		        
    // kira API don canza PDF zuwa tsarin PDF/A. Ajiye fitarwa a cikin ma'ajiyar gajimare
    pdfApi.putPdfInStorageToPdfA("input.pdf", "Converted.pdf", type, null, null);
  
    // buga sakon nasara
    System.out.println("PDF to PDF/A conversion successful !");
    }catch(Exception ex)
    {
        System.out.println(ex);
    }

Canza PDF zuwa PDF/A ta amfani da Umarnin CURL

Hakanan muna da zaɓi don yin PDF zuwa PDF/A juyawa ta amfani da umarnin CURL. Don haka abin da ake buƙata don wannan hanyar shine 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"

Da zarar an ƙirƙiri JWT, muna buƙatar aiwatar da umarni mai zuwa don loda PDF daga ma’adanar Cloud kuma mu canza zuwa tsarin PDF/A-1b. Bayan tuba, za mu ajiye fitarwa a kan wani gida drive.

curl -X -v GET "https://api.aspose.cloud/v3.0/pdf/PdfWithAcroForm.pdf/convert/pdfa?type=PDFA1B" \
-H "accept: multipart/form-data" \
-H "authorization: Bearer <JWT Token>" \
-o "Resultant.pdf"

Kammalawa

A cikin wannan labarin, mun bi duk matakan da suka dace don amfani da Java REST API don canza PDF zuwa tsarin PDF/A. Cikakken tsari ya kasance mai sauƙi kuma mai sauƙi, kuma ana iya haɗa shi cikin sauƙi cikin sabo ko a cikin aikace-aikacen Java ɗin da kuke da shi. Ko dai kuna buƙatar canza PDF guda ɗaya ko aiwatar da sarrafa tsari na nau’ikan nau’ikan nau’ikan nau’ikan nau’ikan nau’ikan nau’ikan nau’ikan nau’ikan nau’ikan nau’ikan nau’ikan nau’ikan nau’ikan nau’ikan nau’ikan nau’ikan nau’ikan nau’ikan nau’ikan nau’ikan nau’ikan nau’ikan nau’ikan nau’ikan nau’ikan nau’ikan nau’ikan nau’ikan nau’ikan nau’ikan nau’ikan nau’ikan nau’ikan nau’ikan nau’ikan nau’ikan nau’ikan nau’ikan nau’ikan nau’ikan iri da nau’ikan juyar da wannan jagorar da wannan jagorar yana ba ku damar canza PDF zuwa PDF zuwa tsarin yarda."

Muna ba da shawarar sosai bincika Takardun Samfura, saboda yana ƙunshe da duk bayanan game da wasu abubuwan ban sha’awa na API. Idan kuna son samun dama ga lambar tushe na Cloud SDK, ana samun ta akan GitHub (an buga shi ƙ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: