PDF פקודות
מדריך זה מראה כיצד להשתמש בכיתות פקדים ממוקדות במשימה org.aspose.pdf.facades כל פקטה עוקבת אחר אותו מחזור חיים: bindPdf() → פעולות → save().תוכל ללמוד להדביק את ההערות, ניהול תוויות, החלפת טקסט, מסמכים מוצפנים, הוספת טקס ומספר עמודים.
פסטה דפוס
כל הכיתות במקומות org.aspose.pdf.facades עוקבים אחר אותו מחזור חיים: bindPdf() → פעולות → save().הם מקבלים מסלולי קובץ, זרמים או Document אובייקטים.
PdfAnnotationEditor
לחצו, למחוק או לספור את ההערות לאורך כל המסמך. flattenAnnotations() שילוב של כל ההערות לתוך זרימת התוכן של הדף, כך שהם יוכלו להיות קבועים ובלתי מתוקנים:
try (PdfAnnotationEditor editor = new PdfAnnotationEditor()) {
editor.bindPdf("input.pdf");
editor.flattenAnnotations();
editor.save("output.pdf");
}deleteAnnotations(annotationType) מוחק סוג מסוים של הערה לפי שם.
PdfBookmarkEditor
יצירת ומחיקת כניסות PDF (מונחים ספרים). deleteBookmarks() הסרת כל ההודעות המוצגות מהמסמך הקשור לפני שמור:
try (PdfBookmarkEditor editor = new PdfBookmarkEditor()) {
editor.bindPdf("input.pdf");
editor.deleteBookmarks();
editor.save("output.pdf");
}PdfContentEditor
החלפת טקסט בתוכן PDF זורמים לאורך כל המסמך או בדף מסוים. replaceText(searchString, replacement) מצא ומחליף את כל שורות הטקסט המתאימות:
try (PdfContentEditor editor = new PdfContentEditor()) {
editor.bindPdf("template.pdf");
editor.replaceText("{{Name}}", "John Smith");
editor.save("output.pdf");
}PdfFileSecurity
הצפנת מסמך עם AES-256 והגדרת הרשאות גישה באמצעות DocumentPrivilege. encryptFile(userPass, ownerPass, privilege, keySize) יש להקפיד על הצפנה ולכתוב התוצאה של הקובץ היציאה המורכב:
try (PdfFileSecurity security = new PdfFileSecurity("input.pdf", "out.pdf")) {
DocumentPrivilege priv = DocumentPrivilege.getForbidAll();
priv.setAllowPrint(true);
security.encryptFile("user", "owner", priv, KeySize.x256);
}PdfExtractor
להוציא דף טקסט לפי דף מסמך PDF. extractText(),• שימוש hasNextPageText() ו getNextPageText() כדי לזהות את התוכן המוצא של כל דף:
try (PdfExtractor extractor = new PdfExtractor()) {
extractor.bindPdf("document.pdf");
extractor.extractText();
while (extractor.hasNextPageText()) {
String text = extractor.getNextPageText();
System.out.println(text);
}
}PdfFileStamp
הוספת מספר עמודים לדפים PDF באמצעות addPageNumber(FormattedText).עבר א FormattedText דוגמה המכילה את התווית מספר הדף:
try (PdfFileStamp stamp = new PdfFileStamp("in.pdf", "out.pdf")) {
stamp.addPageNumber(new FormattedText("Page #"));
stamp.close();
}שימוש addHeader(FormattedText, float) או addFooter(FormattedText, float) להוסיף טקסט חוזר על שער מסוים מלמעלה או מתחת לכל דף.