Examples of PdfReader


Examples of com.lowagie.text.pdf.PdfReader

    if ((parsedCommand != null) && (parsedCommand instanceof DocumentInfoParsedCommand)) {
      DocumentInfoParsedCommand inputCommand = (DocumentInfoParsedCommand) parsedCommand;
      setPercentageOfWorkDone(0);
      try {
        File tmpFile = FileUtility.generateTmpFile(inputCommand.getOutputFile());
        pdfReader = new PdfReader(new RandomAccessFileOrArray(inputCommand.getInputFile().getFile().getAbsolutePath()), inputCommand
            .getInputFile().getPasswordBytes());
        pdfReader.removeUnusedObjects();
        pdfReader.consolidateNamedDestinations();

        // version
View Full Code Here

Examples of com.lowagie.text.pdf.PdfReader

              encType = PdfWriter.STANDARD_ENCRYPTION_128;
            }

            prefixParser = new PrefixParser(inputCommand.getOutputFilesPrefix(), fileList[i].getFile().getName());
            File tmpFile = FileUtility.generateTmpFile(inputCommand.getOutputFile());
            pdfReader = new PdfReader(new RandomAccessFileOrArray(fileList[i].getFile().getAbsolutePath()), fileList[i]
                .getPasswordBytes());
            pdfReader.removeUnusedObjects();
            pdfReader.consolidateNamedDestinations();

            // version
View Full Code Here

Examples of com.lowagie.text.pdf.PdfReader

        }
        for(int i = 0; i<fileList.length; i++){
          try{
            prefixParser = new PrefixParser(inputCommand.getOutputFilesPrefix(), fileList[i].getFile().getName());
            File tmpFile = FileUtility.generateTmpFile(inputCommand.getOutputFile());
            pdfReader = new PdfReader(new RandomAccessFileOrArray(fileList[i].getFile().getAbsolutePath()),fileList[i].getPasswordBytes());
            pdfReader.removeUnusedObjects();
            pdfReader.consolidateNamedDestinations();
           
            //version
            LOG.debug("Creating a new document.");
View Full Code Here

Examples of com.lowagie.text.pdf.PdfReader

                        currentPageSelection = pageSelections[i].toLowerCase();
                    }

                    String[] selectionGroups = StringUtils.split(currentPageSelection, ",");

                    pdfReader = new PdfReader(new RandomAccessFileOrArray(fileList[i].getFile().getAbsolutePath()),
                            fileList[i].getPasswordBytes());
                    pdfReader.removeUnusedObjects();
                    pdfReader.consolidateNamedDestinations();
                    int pdfNumberOfPages = pdfReader.getNumberOfPages();
                    BookmarksProcessor bookmarkProcessor = new BookmarksProcessor(SimpleBookmark.getBookmark(pdfReader), pdfNumberOfPages);
View Full Code Here

Examples of com.lowagie.text.pdf.PdfReader

     * @param inputCommand
     * @return temporary file with pages rotation
     */
    private File applyRotations(File inputFile, ConcatParsedCommand inputCommand) throws Exception {

        rotationReader = new PdfReader(inputFile.getAbsolutePath());
        rotationReader.removeUnusedObjects();
        rotationReader.consolidateNamedDestinations();

        int pdfNumberOfPages = rotationReader.getNumberOfPages();
        PageRotation[] rotations = inputCommand.getRotations();
View Full Code Here

Examples of com.lowagie.text.pdf.PdfReader

      transitions = parseXmlInput(inputCommand.getInputXmlFile(), transitions);
      try{
        prefixParser = new PrefixParser(inputCommand.getOutputFilesPrefix(), inputCommand.getInputFile().getFile().getName());       
        File tmpFile = FileUtility.generateTmpFile(inputCommand.getOutputFile());
       
        pdfReader = new PdfReader(new RandomAccessFileOrArray(inputCommand.getInputFile().getFile().getAbsolutePath()),inputCommand.getInputFile().getPasswordBytes());
        pdfReader.removeUnusedObjects();
        pdfReader.consolidateNamedDestinations();
       
        //version
        LOG.debug("Creating a new document.");
View Full Code Here

Examples of com.lowagie.text.pdf.PdfReader

     */
    public static void createSignatur(PrivateKey privateKey,
            Certificate[] chain, String originalPdfName, String outputPdfName)
            throws Exception {

        PdfReader reader = new PdfReader(originalPdfName);
        FileOutputStream fout = new FileOutputStream(outputPdfName);

        //createSignature(PdfReader reader, OutputStream os, char pdfVersion)
        //pdfVersion - the new pdf version or '\0' to keep the same version as
        // the original document
View Full Code Here

Examples of com.lowagie.text.pdf.PdfReader

     * @param password password to open the file
     * @return the item to add to the table
     */
    PdfSelectionTableItem getPdfSelectionTableItem(File fileToAdd, String password, String pageSelection){
      PdfSelectionTableItem tableItem = null;
      PdfReader pdfReader = null;
        if (fileToAdd != null){
          tableItem = new PdfSelectionTableItem();
          tableItem.setInputFile(fileToAdd);
          tableItem.setPassword(password);
          tableItem.setPageSelection(pageSelection);
            try{
                //fix 04/11/08 for memory usage
               pdfReader = new PdfReader(new RandomAccessFileOrArray(fileToAdd.getAbsolutePath()), (password != null)?password.getBytes():null);                 
                 tableItem.setEncrypted(pdfReader.isEncrypted());
                 tableItem.setFullPermission(pdfReader.isOpenedWithFullPermissions());
                 if(tableItem.isEncrypted()){
                   tableItem.setPermissions(getPermissionsVerbose(pdfReader.getPermissions()));
                   int cMode = pdfReader.getCryptoMode();
                   switch (cMode){
                   case PdfWriter.STANDARD_ENCRYPTION_40:
                     tableItem.setEncryptionAlgorithm(EncryptionUtility.RC4_40);
                     break;
                   case PdfWriter.STANDARD_ENCRYPTION_128:
                     tableItem.setEncryptionAlgorithm(EncryptionUtility.RC4_128);
                     break;
                   case PdfWriter.ENCRYPTION_AES_128:
                     tableItem.setEncryptionAlgorithm(EncryptionUtility.AES_128);
                     break;
                   default:
                     break;                         
                   }
                 }
                 tableItem.setPagesNumber(Integer.toString(pdfReader.getNumberOfPages()));
                 tableItem.setFileSize(fileToAdd.length());
                 tableItem.setPdfVersion(pdfReader.getPdfVersion());
                 tableItem.setSyntaxErrors(pdfReader.isRebuilt());
                 initTableItemDocumentData(pdfReader, tableItem);
            }
            catch (Exception e){
              tableItem.setLoadedWithErrors(true);
              LOG.error(GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(),"Error loading ")+fileToAdd.getAbsolutePath()+" :", e);
            }
            finally{
              if(pdfReader != null){
                pdfReader.close();
          pdfReader = null;
              }
            }              
        }
        return tableItem;   
View Full Code Here

Examples of com.lowagie.text.pdf.PdfReader

                String inputMimeType = null;
                if (dataResource != null) {
                    inputMimeType = dataResource.getString("mimeTypeId");
                }
                byte [] inputByteArray = null;
                PdfReader reader = null;
                if (inputMimeType != null && inputMimeType.equals("application/pdf")) {
                    ByteBuffer byteBuffer = DataResourceWorker.getContentAsByteBuffer(delegator, thisDataResourceId, https, webSiteId, locale, rootDir);
                    inputByteArray = byteBuffer.array();
                    reader = new PdfReader(inputByteArray);
                } else if (inputMimeType != null && inputMimeType.equals("text/html")) {
                    ByteBuffer byteBuffer = DataResourceWorker.getContentAsByteBuffer(delegator, thisDataResourceId, https, webSiteId, locale, rootDir);
                    inputByteArray = byteBuffer.array();
                    String s = new String(inputByteArray);
                    Debug.logInfo("text/html string:" + s, module);
                    continue;
                } else if (inputMimeType != null && inputMimeType.equals("application/vnd.ofbiz.survey.response")) {
                    String surveyResponseId = dataResource.getString("relatedDetailId");
                    String surveyId = null;
                    String acroFormContentId = null;
                    GenericValue surveyResponse = null;
                    if (UtilValidate.isNotEmpty(surveyResponseId)) {
                        surveyResponse = delegator.findByPrimaryKey("SurveyResponse", UtilMisc.toMap("surveyResponseId", surveyResponseId));
                        if (surveyResponse != null) {
                            surveyId = surveyResponse.getString("surveyId");
                        }
                    }
                    if (UtilValidate.isNotEmpty(surveyId)) {
                        GenericValue survey = delegator.findByPrimaryKey("Survey", UtilMisc.toMap("surveyId", surveyId));
                        if (survey != null) {
                            acroFormContentId = survey.getString("acroFormContentId");
                            if (UtilValidate.isNotEmpty(acroFormContentId)) {
                                // TODO: is something supposed to be done here?
                            }
                        }
                    }
                    if (surveyResponse != null) {
                        if (UtilValidate.isEmpty(acroFormContentId)) {
                            // Create AcroForm PDF
                            Map<String, Object> survey2PdfResults = dispatcher.runSync("buildPdfFromSurveyResponse", UtilMisc.toMap("surveyResponseId", surveyId));
                            if (ServiceUtil.isError(survey2PdfResults)) {
                                return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ContentSurveyErrorBuildingPDF", locale), null, null, survey2PdfResults);
                            }

                            ByteBuffer outByteBuffer = (ByteBuffer) survey2PdfResults.get("outByteBuffer");
                            inputByteArray = outByteBuffer.array();
                            reader = new PdfReader(inputByteArray);
                        } else {
                            // Fill in acroForm
                            Map<String, Object> survey2AcroFieldResults = dispatcher.runSync("setAcroFieldsFromSurveyResponse", UtilMisc.toMap("surveyResponseId", surveyResponseId));
                            if (ServiceUtil.isError(survey2AcroFieldResults)) {
                                return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ContentSurveyErrorSettingAcroFields", locale), null, null, survey2AcroFieldResults);
                            }

                            ByteBuffer outByteBuffer = (ByteBuffer) survey2AcroFieldResults.get("outByteBuffer");
                            inputByteArray = outByteBuffer.array();
                            reader = new PdfReader(inputByteArray);
                        }
                    }
                } else {
                    ByteBuffer inByteBuffer = DataResourceWorker.getContentAsByteBuffer(delegator, thisDataResourceId, https, webSiteId, locale, rootDir);

                    Map<String, Object> convertInMap = UtilMisc.<String, Object>toMap("userLogin", userLogin, "inByteBuffer", inByteBuffer, "inputMimeType", inputMimeType, "outputMimeType", "application/pdf");
                    if (UtilValidate.isNotEmpty(oooHost)) convertInMap.put("oooHost", oooHost);
                    if (UtilValidate.isNotEmpty(oooPort)) convertInMap.put("oooPort", oooPort);

                    Map<String, Object> convertResult = dispatcher.runSync("convertDocumentByteBuffer", convertInMap);

                    if (ServiceUtil.isError(convertResult)) {
                        return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ContentConvertingDocumentByteBuffer", locale), null, null, convertResult);
                    }

                    ByteBuffer outByteBuffer = (ByteBuffer) convertResult.get("outByteBuffer");
                    inputByteArray = outByteBuffer.array();
                    reader = new PdfReader(inputByteArray);
                }
                if (reader != null) {
                    int n = reader.getNumberOfPages();
                    for (int i=0; i < n; i++) {
                        PdfImportedPage pg = writer.getImportedPage(reader, i + 1);
                        //cb.addTemplate(pg, left, height * pgCnt);
                        writer.addPage(pg);
                        pgCnt++;
View Full Code Here

Examples of com.lowagie.text.pdf.PdfReader

        String surveyId = null;
        try {
            String surveyName = (String) context.get("surveyName");
            ByteArrayOutputStream os = new ByteArrayOutputStream();
            ByteBuffer byteBuffer = getInputByteBuffer(context, delegator);
            PdfReader pdfReader = new PdfReader(byteBuffer.array());
            PdfStamper pdfStamper = new PdfStamper(pdfReader, os);
            AcroFields acroFields = pdfStamper.getAcroFields();
            Map<String, Object> acroFieldMap = UtilGenerics.checkMap(acroFields.getFields());

            String contentId = (String) context.get("contentId");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.