public static String getTitle(String src){ try { PdfDocument pdfDoc = new PdfDocument(new PdfReader(src)); PdfDocumentInfo info = pdfDoc.getDocumentInfo(); String title=info.getTitle(); pdfDoc.close(); return title; } catch (Exception e) { return null; } }
PdfDocumentInfo info=pdfDoc.getDocumentInfo(); if(book.getName()!=null&&!book.getName().equals("null")){ info.setTitle(book.getName());
PdfDocument outDocument = new PdfDocument(new PdfReader(outPdf, getOutReaderProperties()), new DocumentProperties().setEventCountingMetaInfo(metaInfo)); PdfDocument cmpDocument = new PdfDocument(new PdfReader(cmpPdf, getCmpReaderProperties()), new DocumentProperties().setEventCountingMetaInfo(metaInfo)); String[] cmpInfo = convertInfo(cmpDocument.getDocumentInfo()); String[] outInfo = convertInfo(outDocument.getDocumentInfo()); for (int i = 0; i < cmpInfo.length; ++i) { if (!cmpInfo[i].equals(outInfo[i])) {
/** * Entry point to encrypt a PDF document. * * @param reader the read PDF * @param os the output destination * @param newInfo an optional {@code String} map to add or change * the info dictionary. Entries with {@code null} * values delete the key in the original info dictionary */ public void encrypt(PdfReader reader, OutputStream os, Map<String, String> newInfo) { WriterProperties writerProperties = new WriterProperties(); writerProperties.encryptionProperties = properties; PdfWriter writer = new PdfWriter(os, writerProperties); StampingProperties stampingProperties = new StampingProperties(); stampingProperties.setEventCountingMetaInfo(metaInfo); PdfDocument document = new PdfDocument(reader, writer, stampingProperties); document.getDocumentInfo().setMoreInfo(newInfo); document.close(); }
public static void addBookMark(Book book,String src,String dest){ PdfDocument pdfDoc = null; try { pdfDoc = new PdfDocument(new PdfReader(src), new PdfWriter(dest)); PdfOutline root = pdfDoc.getOutlines(false); PdfDocumentInfo info=pdfDoc.getDocumentInfo(); info.setTitle(book.getName()); info.setAuthor(CoreService.baseUrl+"/book/"+book.getId()); List<Node> nodes = book.getOutline(); addOutline(nodes, root, pdfDoc); pdfDoc.close(); } catch (IOException e) { e.printStackTrace(); } }
public static void addBookMark(Book book,String src,String dest){ PdfDocument pdfDoc = null; try { pdfDoc = new PdfDocument(new PdfReader(src), new PdfWriter(dest)); PdfOutline root = pdfDoc.getOutlines(false); PdfDocumentInfo info=pdfDoc.getDocumentInfo(); info.setTitle(book.getName()); info.setAuthor(book.getAuthor()); List<Node> nodes = book.getOutline(); addOutline(nodes, root, pdfDoc); pdfDoc.close(); } catch (IOException e) { e.printStackTrace(); } }
xrefStream.put(PdfName.W, new PdfArray( Arrays.asList((PdfObject) new PdfNumber(1), new PdfNumber(offsetSize), new PdfNumber(2)))); xrefStream.put(PdfName.Info, document.getDocumentInfo().getPdfObject()); xrefStream.put(PdfName.Root, document.getCatalog().getPdfObject()); PdfArray index = new PdfArray();