pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Johan G <joh...@comcast.net>
Subject How to get: isOptimized, hasCompressedStreamObjects, allowsCommenting ?
Date Thu, 29 Nov 2012 22:23:48 GMT

Hi All, 

How can I determine in Java if a PDF file matches these requirements? 

• The file is optimized for Fast Web Viewing. 
• The file does not contain compressed stream objects. 
• The Document restrictions allow Commenting. // Am using ap.canModifyAnnotations() ? 


I think these requirements checks are close to working nicely already: 
• The file contains bookmarks (if it is over 50 pages). // Am using the below, does it look
close? 
• The Security method is set to “No Security” (in other words, no encryption exists
in the file). // Am using doc.isEncrypted() 
• The Document restrictions allow Printing, and Page Extraction. // Am using ap.canPrint()
and ap.canExtractContent() 


Close for checking if it has bookmarks? 
..... 
public Boolean hasBookmarks(){ 

PDDocumentOutline root = doc.getDocumentCatalog().getDocumentOutline(); 
if(root == null){ 
setValidationMessage("Not Bookmarked"); 
return false; 
} 
PDOutlineItem item = root.getFirstChild(); 
if(item == null){ 
setValidationMessage("Not Bookmarked"); 
return false; 
} 
int i = 0; 
while (item != null) { 
PDOutlineItem child = item.getFirstChild(); 
while (child != null) { 
child = child.getNextSibling(); 
i++; 
} 
item = item.getNextSibling(); 
} 

if(i > 0){ 
return true; 
} 
else{ 
setValidationMessage("Not Bookmarked"); 
return false; 
} 
} 

Thanks for anything 
Johan, Seattle 

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message