פתרון בעיות

פתרון בעיות

מסמך לא מתקרב - זיכרון נעלם

Document יישום AutoCloseable.תמיד להשתמש בלוק של משאבים עם ניסיון:

try (Document doc = new Document("input.pdf")) {
    // operations
} // doc.close() called automatically

OutOfMemoryError עם קבצים גדולים

עבור מסמכים גדולים, מאפשר דיסק בופר PdfFileEditor:

PdfFileEditor editor = new PdfFileEditor();
editor.setUseDiskBuffer(true);
editor.concatenate(inputFiles, "output.pdf");

PdfFileSecurity: סיסמה לא נכונה

decryptFile(password) חזרה false אם הסיסמה שניתנה אינה נכונה. בדוק תמיד את ערך ההחזר ולעבד את המקרה של כישלון:

try (PdfFileSecurity security = new PdfFileSecurity()) {
    security.setInputFile("encrypted.pdf");
    security.setOutputFile("decrypted.pdf");
    boolean ok = security.decryptFile("ownerPassword");
    if (!ok) {
        System.err.println("Decryption failed — verify the owner password.");
    }
}

תגית: null arguments

PdfFileEditor.resizeContents() הוא מתעלם בשקט מהתגובות אפס במקום לזרוק. אם המסמך המוצא נראה ללא שינוי לאחר resizeContents(),בדוק כי ה ContentsResizeParameters ההסבר אינו אפס והערך הממוצע הוא סכום. עד 100 בדיוק.

אסטרואיד: מפתח לא נכון

AES דורש מפתחות של בדיוק 16, 24, או 32 בייטים (128, 192, או 256 ביטים).עבור מפתח אורך שגוי תוצאות עם יוצא מן התוכנית הבסיסית Java cryptocurrency provider.

תגיות לא נראים

אם מוסיפה הערה אך לא מופיעה בציור, בדוק:

  1. המפרט הימני של ההרשמה נמצא בתוך הדף. MediaBox
  2. page.getAnnotations().add(annotation) לאחר שהתקבלו כל התכונות.
  3. המסמך נשמר לאחר הוספת ההערה.

ראה גם

 עברית