
Form alanları, müşteri verileriyle uğraşırken olmazsa olmaz bileşenlerden biridir ve PDF Acro formlarını kullanıcılara dağıtmak kolaylaşır, böylece formları kendi seçtikleri verilerle doldurup geri gönderebilirler. Çeşitli form alanlarının kullanılabildiğini biliyoruz ancak bunların arasında TextBox, CheckBox, RadioButton ve ComboBox’lar oldukça yaygındır. Bu nedenle, veriler Acro formlarına doldurulduktan sonra, arka ofiste form alanlarını ayrıştırarak bunlardan veri çıkarır ve bunları FDF, XML veya doğrudan veritabanlarına kaydederiz.
PDF form oluşturma, form alanları ekleme, form alanları güncelleme etkinliği dahil tüm işlemler manuel olarak gerçekleştirilebilse de, çok sayıda belgeyle uğraşırken, manuel işlem zaman alıcı ve verilerin manuel işlenmesi nedeniyle hataya açık olduğu için uygulanabilir görünmüyor. Bu nedenle, programlama dili aracılığıyla otomatik rutinler uygulanabilir bir çözüm olabilir. Bu nedenle, bir program oluştururken, tüm gereksinimleri karşılamamıza yardımcı olabilecek şirket içi bir çözüm/API kullanma veya form alanlarını ayrıştırmak için bulutta barındırılan REST API’lerini kullanma seçeneğine sahip oluruz.
REST API Avantajları
RESTful API’leri burada bir sıçrama yapıyor çünkü tüm API sürümlerini manuel olarak takip etmenize gerek yok. Ayrıca, sisteminizi API sürümleriyle güncel tutmanız gerekmiyor ve API’lerin belirli bir programlama diliyle uyumluluk sorunları hakkında endişelenmenize gerek yok, vb. Bu nedenle, PDF belgelerini diğer desteklenen dosya biçimlerine oluşturma, düzenleme ve dönüştürme yetenekleri sağlayan Aspose.PDF Cloud SDK for Java‘yı sunuyoruz. Java SDK, cURL komutları kullanılarak kolayca erişilebilen Aspose.PDF Cloud REST API’lerinin üstünde geliştirilmiştir ve SDK’lar, müşterilerimizin belirli bir programlama dilini kullanmasını kolaylaştırmak için geliştirilmiştir.
Bu blogda, farklı form alanlarının nasıl ayrıştırılacağına ışık tutacağız:
- TextBox alanlarını oku, ekle veya güncelle
- CheckBox form alanlarını ayrıştır
- RadioButton alanlarını ekleyin veya güncelleyin
- ComboBox form alanlarını yönetin
TextBox alanlarını oku, ekle veya güncelle
API, TextBox alanlarıyla ilişkili bilgileri okumak için üç yol sunar.
| API | Tür | Açıklama | Swagger Bağlantısı |
| ——————————— | ———– | ——————————— | —————————— |
| /pdf/{name}/fields/textbox | GET | Belge TextBox alanlarını oku | GetDocumentTextBoxFields |
| /pdf/{name}/page/{pageNumber}/fields/textbox | GET | Belirli bir sayfa için belge TextBox alanlarını oku | GetPageTextBoxFields |
| /pdf/{name}/fields/textbox/{fieldName} | GET | Belgenin TextBox alanlarını alan adına göre oku | GetTextBoxField |
TextBox alanlarını okumak için cURL komutu
Dosyalar kişisel bulut depolama alanınızda saklandığından, öncelikle kişiselleştirilmiş İstemci Kimliğinizi ve İstemci Gizli Anahtarınızı gerektiren bir JWT kimlik doğrulama belirteci oluşturmanız gerekir.
curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=xxxx&client_secret=xxxx" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"
curl -X GET "https://api.aspose.cloud/v3.0/pdf/FormDataTextBox.pdf/fields/textbox" \
-H "accept: application/json" \
-H "authorization: Bearer <JWT Token>"
Yukarıdaki örnekte kullanılan örnek FormDataTextBox.pdf.
Cava
// Tam örnekler ve veri dosyaları için lütfen https://github.com/aspose-pdf-cloud/aspose-pdf-cloud-java adresine gidin.
const string clientID = "xxxxxx-1c8e-4ea4-a948-3857547232fa";
const string clientSecret = "xxxxxx613237f013e329cdf5694cc96a";
import com.aspose.asposecloudpdf.ApiException;
import com.aspose.asposecloudpdf.api.PdfApi;
import com.aspose.asposecloudpdf.examples.Common;
import com.aspose.asposecloudpdf.model.FieldResponse;
public class GetFieldTestExample {
public static void main(String[] args) throws ApiException {
String name = "PdfWithAcroForm.pdf";
// PdfAPi nesnesinin bir örneğini oluştur
com.aspose.asposecloudpdf.api.PdfApi pdf = new com.aspose.asposecloudpdf.api.PdfApi(clientSecret,clientID);
// Belgeyi oku TextBox alanları
TextBoxFieldsResponse response = pdf.getDocumentTextBoxFields("FormDataTextBox.pdf",null, null);
// getirilen alanlarla ilgili ayrıntıları yazdır
System.out.println(response.getFields());
}
}
CheckBox form alanlarını ayrıştır
API, Onay Kutuları ile çalışırken, Onay Kutusu değerlerini okuma, yeni bir onay kutusu ekleme veya PDF formundaki mevcut bir onay kutusuyla ilişkili özellikleri güncelleme yeteneklerini de sağlar.
- GetDocumentCheckBoxFields - Read document checkbox fields
- GetPageCheckBoxFields - Read specific page checkbox fields
- CheckBoxAlanınıAl - Read document checkbox field by name
Sayfa 1’deki CheckBox’ı okumak için cURL komutu
curl -X GET "https://api.aspose.cloud/v3.0/pdf/FormDataTextBox.pdf/page/1/fields/checkbox" \
-H "accept: application/json" \
-H "authorization: Bearer <JWT Token>"
Sayfa 1’deki CheckBox’ı güncellemek için CURL komutu
curl -X PUT "https://api.aspose.cloud/v3.0/pdf/FormDataTextBox.pdf/fields/checkbox/Check%20Box1" \
-H "accept: application/json" \
-H "authorization: Bearer <JWT Token>" \
-H "Content-Type: application/json" \
-d "{ \"Links\": [ { \"Href\": \"string\", \"Rel\": \"string\", \"Type\": \"string\", \"Title\": \"string\" } ], \"PartialName\": \"Aspose CheckBox\", \"FullName\": \"Aspose CheckBox\", \"Rect\": { \"LLX\": 88.3573, \"LLY\": 687.617, \"URX\": 97.0198, \"URY\": 695.413 }, \"Value\": \"null\", \"PageIndex\": 1, \"Height\": 12, \"Width\": 12, \"ZIndex\": 0, \"IsGroup\": false, \"IsSharedField\": true, \"Flags\": [ \"Default\" ], \"Color\": { \"A\": 0, \"R\": 150, \"G\": 120, \"B\": 0 }, \"Contents\": \"Field Updated\", \"Margin\": { \"Left\": 0, \"Right\": 0, \"Top\": 0, \"Bottom\": 0 }, \"Highlighting\": \"None\", \"HorizontalAlignment\": \"Left\", \"VerticalAlignment\": \"Center\", \"Border\": { \"Width\": 1, \"EffectIntensity\": 1, \"Style\": \"Solid\", \"Effect\": \"None\", \"Dash\": { \"On\": 1, \"Off\": 2 }, \"Color\": { \"A\": 255, \"R\": 120, \"G\": 120, \"B\": 0 } }, \"AllowedStates\": [ \"Yes\",\"Off\" ], \"Style\": \"Circle\", \"ActiveState\": \"On\", \"Checked\": true, \"ExportValue\": \"Yes\"}"
İstek URL’si
https://api.aspose.cloud/v3.0/pdf/FormDataTextBox.pdf/fields/checkbox/Check%20Box1
Cava
// Tam örnekler ve veri dosyaları için lütfen https://github.com/aspose-pdf-cloud/aspose-pdf-cloud-java adresine gidin.
const string clientID = "xxxxxx-1c8e-4ea4-a948-3857547232fa";
const string clientSecret = "xxxxxx613237f013e329cdf5694cc96a";
import com.aspose.asposecloudpdf.model.Rectangle;
import com.aspose.asposecloudpdf.model.CheckBoxField;
import com.aspose.asposecloudpdf.model.Border;
import com.aspose.asposecloudpdf.model.Color;
import com.aspose.asposecloudpdf.model.CheckBoxFieldResponse;
public class UpdateCheckBoxFieldExample {
public static void main(String[] args) throws ApiException {
// PdfAPi nesnesinin bir örneğini oluştur
com.aspose.asposecloudpdf.api.PdfApi pdf = new com.aspose.asposecloudpdf.api.PdfApi(clientSecret,clientID);
// CheckBox örneği oluştur
CheckBoxField updatedCheckBox = new CheckBoxField();
updatedCheckBox.partialName("Check Box1");
updatedCheckBox.height(12.0);
updatedCheckBox.width(12.0);
// onay kutusu stilini Elmas olarak ayarla
updatedCheckBox.style(com.aspose.asposecloudpdf.model.BoxStyle.DIAMOND);
updatedCheckBox.activeState("On");
// onay kutusu değerini etkinleştir
updatedCheckBox.checked(true);
Rectangle rect = new Rectangle();
rect.setLLX(88.3573);
rect.setLLY(687.617);
rect.setURX(97.0198);
rect.setURY(695.413);
updatedCheckBox.rect(rect);
// sayfa dizini ayrıntılarını belirtin
updatedCheckBox.pageIndex(1);
// CheckBox kenarlık stili ayrıntılarını ayarla
Border border = new Border();
border.width(1);
border.style(com.aspose.asposecloudpdf.model.BorderStyle.SOLID);
border.effect(com.aspose.asposecloudpdf.model.BorderEffect.NONE);
// Sınır için renkli nesne
Color color = new Color();
color.setR(120);
color.setG(220);
color.setB(10);
// CheckBox kenarlık rengini ayarla
border.color(color);
// 1. sayfadaki onay kutusu alanını güncellemek için çağrı yöntemi
CheckBoxFieldResponse response = pdf.putCheckBoxField("FormDataTextBox.pdf", "Check Box1", updatedCheckBox,null,null);
// yanıt durum kodunu yazdır
System.out.print(response.getStatus());
}
}
Komut/kod çalıştırıldığında, onay kutusu 1 alanıyla ilişkili özellikler aşağıdaki görselde gösterildiği gibi güncellenir.

Resim 1:- cURL komutunu kullanarak güncellenen onay kutusu 1’in önizlemesi
RadioButton alanlarını ekleyin veya güncelleyin
TextBox ve CheckBox alanlarına benzer şekilde Cloud SDK, PDF belgelerindeki RadioButton alanlarını okuma ve güncelleme yeteneklerini de sağlar.
PDF belgesinde RadioButton alanlarını okumak için cURL komutu
curl -X GET "https://api.aspose.cloud/v3.0/pdf/FormDataTextBox.pdf/fields/radiobutton" \
-H "accept: application/json" \
-H "authorization: Bearer <JWT Token>"
İstek URL’si
https://api.aspose.cloud/v3.0/pdf/FormDataTextBox.pdf/fields/radiobutton
ComboBox form alanlarını yönetin
ComboBox manipülasyonunun Aspose.PDF for Java Cloud SDK’nın yardımıyla çok kullanışlı hale geldiğini fark edin. Belgedeki mevcut ComboBox alanlarını okuma, yeni bir ComboBox alanı ekleme veya mevcut bir ComboBox’ı güncelleme seçeneğine sahip olursunuz.
- GetDocumentComboBoxFields - Read document combobox fields
- GetPageComboBoxFields - Read particular page combobox fields
- ComboBoxAlanınıAl - Read document combobox field by name
- PostComboBoxAlanları - Add ComboBox field to document
- ComboBoxAlanı Koy - Replace document combobox field
Tüm ComboBox alanlarını okumak için cURL komutu
curl -X GET "https://api.aspose.cloud/v3.0/pdf/FormDataTextBox.pdf/fields/combobox" \
-H "accept: application/json" \
-H "authorization: Bearer <JWT Token>"
İstek URL’si
https://api.aspose.cloud/v3.0/pdf/FormDataTextBox.pdf/fields/combobox
Çözüm
Yukarıdaki makalede açıklandığı gibi, Form alanlarının işlenmesi Cloud API’lerinin yardımıyla oldukça kolay hale geldi. İlgili bir blogu incelemeyi düşünebilirsiniz Form Ayrıştırıcı | Form Tanıyıcı | PDF Doldurma | REST Web API ile form işlemeyi otomatikleştirin.