Siffar PDF wani nau’i ne na musamman na PDF wanda ya ƙunshi filayen hulɗa inda za’a iya shigar da bayanan rubutu ko za’a iya zaɓar akwatunan rajista. Ana amfani da wannan tsarin daftarin aiki don tattara bayanai akan intanit. Bayan tattara bayanai, ɗayan zaɓuɓɓuka masu dacewa don adana bayanan shine canza PDF zuwa tsarin FDF. Fayil FDF (Forms Data Format) takaddar rubutu ce wacce aka samo ta ta hanyar fitar da bayanai daga filayen sigar fayil ɗin PDF. Ya ƙunshi bayanan filayen rubutu kawai waɗanda aka ciro daga filayen fom ɗin da ke cikin fayil ɗin PDF. Bugu da ƙari kuma, fayil ɗin FDF mai ɗauke da bayanan tsari don nau’in PDF ya fi ƙanƙanta fiye da fayil ɗin da ke ɗauke da sigar PDF ɗin kansa, don haka adana fayilolin FDF yana buƙatar ƙarancin sararin ajiya fiye da adana fayilolin PDF. Yanzu a cikin wannan labarin, za mu tattauna cikakkun bayanai don canza PDF zuwa fayil ɗin FDF ba tare da Adobe Acrobat ba.
API ɗin Canjin PDF
Ɗaya daga cikin ingantattun mafitacin mu yana ba da damar ƙirƙirar, gyara da sarrafa takaddun PDF shine Aspose.PDF Cloud. Hakanan yana ba ku damar loda fayil ɗin PDF kuma ku canza zuwa tsararrun tsararrun tallafi. Hakazalika, yana da ikon loda fayilolin PDF kuma yana ba mu damar fitar da bayanan tsari cikin tsarin FDF. Yanzu za mu ƙara bayanin Aspose.PDF Cloud SDK don Java a cikin aikace-aikacen Java ta hanyar haɗa 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>
Muhimmin mataki 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 FDF a Java
Yanzu za mu koyi matakai kan yadda ake loda daftarin aiki na PDF daga ma’ajiyar gajimare kuma mu canza zuwa fayil ɗin FDF.
- Ƙirƙiri wani abu na PdfApi yayin ƙaddamar da keɓaɓɓen takaddun shaida azaman muhawara
- Na biyu, karanta abubuwan da ke cikin takaddun PDF ta amfani da misalin Fayil kuma loda zuwa ma’ajiyar girgije ta amfani da hanyar uploadFile(…) na PdfAPi
- Yanzu kawai kira hanyar putExportFieldsFromPdfToFdfInStorage(…) don canza PDF zuwa fayil FDF. Ana adana fayil ɗin sakamakon a cikin ma’ajin gajimare
// 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);
// sunan babban fayil don adana fayil ɗin fitarwa
String folder = null;
// kira API don canza PDF zuwa tsarin FDF
AsposeResponse response =pdfApi.putExportFieldsFromPdfToFdfInStorage("input.pdf", "myExported.fdf", null,folder);
// buga sakon nasara
System.out.println("PDF sucessfully converted to DOC format !");
}catch(Exception ex)
{
System.out.println(ex);
}
Kuna iya yin la’akari da zazzage sigar shigarwar PDF daga PdfWithAcroForm.pdf.
Fitar da PDF zuwa Adobe FDF ta amfani da Umarnin CURL
Wani zaɓi don samun dama ga APIs REST shine ta umarnin cURL. Don haka za mu fitar da bayanan Form na PDF zuwa fayil ɗin FDF ta amfani da umarnin cURL. Yanzu abubuwan da ake buƙata kafin su 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 shigar da PDF daga ma’ajiyar girgije da fitarwa zuwa tsarin FDF. Bugu da ƙari, maimakon adana kayan aikin Adobe FDF zuwa ma’ajiyar girgije, za mu adana shi akan tuƙi na gida.
curl -v -X GET "https://api.aspose.cloud/v3.0/pdf/input.pdf/export/fdf" \
-H "accept: multipart/form-data" \
-H "authorization: Bearer <JWT Token>" \
-o "Exported.fdf"
Kammalawa
A cikin wannan jagorar, mun nuna matakan amfani da Java REST API don musanya siffofin PDF zuwa FDF (Forms Data Format). Cikakken tsari ya kasance mai sauƙi kuma mai sauƙi, kuma ana iya haɗa shi cikin sauƙi cikin aikace-aikacen Java ɗin da kuke da shi. Ko kuna buƙatar sauya nau’i na PDF guda ɗaya ko tsarin tsari da yawa, jagoranmu yana sauƙaƙa canza PDF zuwa FDF da fitar da bayanan sigar PDF zuwa tsarin FDF.
Muna kuma ba da shawarar bincika Takardun Samfura wanda shine tushen bayanai mai ban mamaki don koyo game da wasu abubuwan ban sha’awa. Idan kuna buƙatar zazzagewa da canza lambar tushe na Cloud SDK, ana samunta akan GitHub (an buga ƙarƙashin lasisin MIT). A ƙarshe, idan kun haɗu da kowace matsala yayin amfani da API, kuna iya yin la’akari da kusantar mu don ƙuduri mai sauri ta hanyar dandalin tallafi na kyauta 9.
Labarai masu alaka
Da fatan za a ziyarci hanyoyin haɗin yanar gizon don ƙarin koyo game da: