PDF minangka format file serbaguna sing digawe dening Adobe sing menehi wong cara sing gampang lan dipercaya kanggo nampilake lan ijol-ijolan dokumen - ora preduli saka piranti lunak, hardware, utawa sistem operasi sing digunakake. Salajengipun, PDF/A minangka format arsip PDF sing ngemot kabeh font sing digunakake ing dokumen ing file PDF. Uga, amarga file PDF / A ngemot kabeh sing dibutuhake kanggo nampilake lan ora ana sing bisa mengaruhi tampilan, mula akeh pangguna sing pengin ngekspor PDF menyang PDF / A. Dadi ing pandhuan langkah-langkah iki, kita bakal njelajah rincian kanggo ngowahi PDF dadi PDF / A nggunakake Java.
- API Konversi PDF
- PDF menyang PDF / A nggunakake Java
- PDF Ngonversi menyang PDF / A nggunakake printah cURL
API Konversi PDF
Aspose.PDF Cloud nyedhiyakake kapabilitas kanggo nggawe, nyunting lan ngapusi dokumen PDF. Nawakake fitur kanggo mbukak file PDF lan ngowahi dadi akeh format sing didhukung. Saiki kanggo nggunakake SDK, pisanan kita kudu nambah referensi Aspose.PDF Cloud SDK kanggo Jawa ing aplikasi Java kita kanthi nyakup rincian ing 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>
Sawise referensi SDK wis ditambahake, kita kudu njupuk kredensial klien saka Cloud Dashboard. Yen sampeyan durung ndhaptar, mangga ndhaftar nganggo alamat email sing bener lan njupuk kredensial pribadi sampeyan.
PDF menyang PDF / A nggunakake Java
Bagean iki nyedhiyakake kabeh rincian sing dibutuhake kanggo mbukak dokumen PDF saka panyimpenan awan lan ngowahi menyang format PDF/A. Elinga yen API saiki ndhukung format PDF/A ing ngisor iki (PDF/A1-A, PDF/A1-B, PDF/A-3A).
- Kaping pisanan, gawe conto PdfApi sing menehi kredensial pribadi minangka argumen
- Kapindho, waca PDF input nggunakake conto File lan upload menyang awan nggunakake metode uploadFile(…) PdfAPi
- Katelu, nemtokake jinis PDF / A minangka PDFA1A nggunakake variabel string
- Pungkasan, nelpon metode putPdfInStorageToPdfA(…) kanggo ngowahi PDF dadi PDF/A lan simpen output menyang panyimpenan awan
// kanggo conto liyane, bukak https://github.com/aspose-pdf-cloud/aspose-pdf-cloud-java/tree/master/Examples/src/main/java/com/aspose/asposecloudpdf/examples
try
{
// Entuk ClientID lan ClientSecret saka https://dashboard.aspose.cloud/
String clientId = "bbf94a2c-6d7e-4020-b4d2-b9809741374e";
String clientSecret = "1c9379bb7d701c26cc87e741a29987bb";
// nggawe conto PdfApi
PdfApi pdfApi = new PdfApi(clientSecret,clientId);
// jeneng input dokumen PDF
String name = "PdfWithAcroForm.pdf";
// maca isi file PDF input
File file = new File("/Users/Downloads/"+name);
// upload PDF menyang panyimpenan maya
pdfApi.uploadFile("input.pdf", file, null);
// asil PDF / jinis A
String type = "PDFA1A";
// nelpon API kanggo ngowahi PDF menyang PDF / format A. Simpen output ing panyimpenan maya
pdfApi.putPdfInStorageToPdfA("input.pdf", "Converted.pdf", type, null, null);
// pesen sukses print
System.out.println("PDF to PDF/A conversion successful !");
}catch(Exception ex)
{
System.out.println(ex);
}
PDF Ngonversi menyang PDF / A nggunakake printah cURL
Kita uga duwe pilihan kanggo nindakake konversi PDF menyang PDF / A nggunakake perintah cURL. Dadi prasyarat kanggo pendekatan iki yaiku ngasilake token akses JWT (adhedhasar kredensial klien) nggunakake printah ing ngisor iki.
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"
Sawise JWT digawe, kita kudu nglakokake printah ing ngisor iki kanggo mbukak PDF saka panyimpenan Cloud lan ngowahi menyang format PDF/A-1b. Sawise konversi, kita bakal nyimpen output ing drive lokal.
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"
Kesimpulan
Ing artikel iki, kita wis ngliwati kabeh langkah sing perlu kanggo nggunakake Java REST API kanggo ngowahi PDF dadi format PDF/A. Proses lengkap wis prasaja lan langsung, lan bisa gampang digabungake menyang anyar utawa ing aplikasi Java sing wis ana. Salah siji sampeyan kudu ngowahi PDF siji utawa nindakake pangolahan kumpulan saka macem-macem formulir, pandhuan iki nggampangake kanggo ngowahi PDF menyang PDF / A format selaras.
Disaranake banget njelajah Dokumentasi Produk, amarga ngemot kabeh informasi babagan fitur API liyane sing nyenengake. Yen sampeyan pengin entuk akses menyang kode sumber Cloud SDK, kasedhiya ing GitHub (diterbitake ing lisensi MIT). Pungkasan, yen sampeyan nemoni masalah nalika nggunakake API, hubungi kita liwat [Forum Dhukungan Produk] gratis 9.
Artikel sing gegandhengan
Mangga bukak link ing ngisor iki kanggo mangerteni sing luwih lengkap babagan: