Metin Ek Açıklamaları eklemek için, Java platformu için zengin özelliklere sahip, güçlü ve kullanımı kolay bir dönüşüm API’si olan Java için Aspose.PDF API’sini kullanacağız. En son sürümünü doğrudan Maven adresinden indirebilir vepom.xml öğesine aşağıdaki yapılandırmaları ekleyerek Maven tabanlı projenize yükleyebilirsiniz.
<repository>
<id>AsposeJavaAPI</id>
<name>Aspose Java AP</name>
<url>https://releases.aspose.com/java/repo/</url>
</repository>
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-pdf</artifactId>
<version>version of aspose-pdf API</version>
</dependency>
Java aracılığıyla PDF belgesinde Ek Açıklamalar oluşturun
Ortamınızdaki kodu denemek için Java için Aspose.PDF gerekir.
- PDF’yi Document sınıfının bir örneğinde yükleyin.
- PDF’ye eklemek istediğiniz bir açıklama oluşturun.
- Ek açıklamayı Page nesnesinin Ek Açıklamalar koleksiyonuna ekleyin.
- PDF dosyasını kaydedin.
PDF Metin Ek Açıklamaları - Java.
Document document = new Document(_dataDir + "sample.pdf");
Page page = document.getPages().get_Item(1);
Rectangle rect = new Rectangle(200, 750, 400, 790);
TextAnnotation textAnnotation = new TextAnnotation(page, rect);
textAnnotation.setTitle("Aspose User");
textAnnotation.setSubject("Sample Subject");
textAnnotation.setState (AnnotationState.Accepted);
textAnnotation.setContents("Sample contents for the annotation");
textAnnotation.setOpen(true);
textAnnotation.setIcon(TextIcon.Circle);
Border border = new Border(textAnnotation);
border.setWidth(5);
border.setDash(new Dash(1, 1));
textAnnotation.setBorder(border);
textAnnotation.setRect(rect);
page.getAnnotations().add(textAnnotation);
document.save(_dataDir + "sample_textannot.pdf");