Prev: print
Next: geoLocator
From: PaulH **AdobeCommunityExpert** on 25 Jan 2007 12:07 iborsb wrote: > Is that even close? Currently, I get an AllowPrinting is undefined error. AllowPrinting is a user permission *field* in PdfWriter. if you have initialized a PdfWriter class then you can do PdfWriterObjectName.ALLOWPRINTING or simply javacast on it's value, 2052. newPDF=pdfStamper.setEncryption('','',javaCast("int",2052),0); if i can offer some advice, grab a copy of bruno's book if you plan on doing much w/Itext. very good value.
From: iborsb on 26 Jan 2007 04:20 I get the following error The selected method setEncryption was not found I'm using a itext 1.4.6.
From: PaulH **AdobeCommunityExpert** on 26 Jan 2007 06:43 iborsb wrote: > I get the following error > > The selected method setEncryption was not found post enough of your code to see what's going on.
From: iborsb on 26 Jan 2007 07:41 Here is the code. Its a copy of the concatenate pdf code from a previous post - as this removes all the security I need to add it back on. listOfPDFs="#listoffile#"; // list of PDFs to concatenate finalOutPutFile="PF#url.id#_spdf.pdf"; // new output file // setup needed objects // setup needed objects PdfEncryptor=createObject("java", "com.lowagie.textNew.pdf.PdfEncryptor"); pdfWriter=createObject("java", "com.lowagie.textNew.pdf.PdfWriter"); pdfCopy=createObject("java", "com.lowagie.textNew.pdf.PdfCopy"); pdfReader=createObject("java","com.lowagie.textNew.pdf.PdfReader"); pageSize=createObject("java", "com.lowagie.textNew.PageSize").init(); bookMark=createObject("java","com.lowagie.textNew.pdf.SimpleBookmark"); pdfDocument=createObject("java","com.lowagie.textNew.Document"); // setup new PDF newPDF=createObject("java","java.io.FileOutputStream").init(expandPath(finalOu tPutFile)); //pdfStamper=createObject("java","com.lowagie.textNew.pdf.PdfStamper"); //newPDF=pdfStamper.setEncryption('','',javaCast("int",2052),0); //PdfEncryptor.init(PdfWriter.AllowPrinting, false); // grab existing PDFs // pageOffset=0; PDFs=listToArray(listOfPDFs); //pdfs to copy master=arrayNew(1); //master list for (i=1; i LTE arrayLen(PDFs); i=i+1) { reader=""; // clobber reader pdfFile=expandPath(PDFs[i]); reader=pdfReader.init(pdfFile); reader.consolidateNamedDestinations(); pages=reader.getNumberOfPages(); // number of pages in this PDF bookmarks=bookMark.getBookmark(reader); //if (isDefined("bookmarks")) { //if (pageOffset NEQ 0) //bookMark.shiftPageNumbers(bookmarks, pageOffset, javacast("null","")); //arrayAppend(master,bookmarks); //} // if has bookmarks pageOffset=pageOffset+pages; if (i EQ 1) { pdfDocument.init(reader.getPageSizeWithRotation(1)); pdfCopy.init(pdfDocument, newPDF); pdfDocument.open(); } // first file in list? // now add pages to new PDF for (p=1; p LTE pages; p=p+1){ page=pdfCopy.getImportedPage(reader,javacast("int",p)); pdfCopy.addPage(page); }// loop pages in this PDF // special case: does this thing have any forms? acroForm=reader.getAcroForm(); if (isDefined("acroForm")) pdfCopy.copyAcroForm(reader); } //loop PDFs if (arraylen(master) GT 0) pdfCopy.setOutlines(master); //pdfWriter.setViewerPreferences(PdfWriter.HideToolbar); pdfDocument.close(); //done & done
From: PaulH **AdobeCommunityExpert** on 26 Jan 2007 13:36
if (i EQ 1) { pdfDocument.init(reader.getPageSizeWithRotation(1)); pdfCopy.init(pdfDocument, newPDF); // make sure we turn off printing BEFORE we open the new PDF pdfCopy.setEncryption(false,"","",bitNot(pdfCopy.ALLOWPRINTING)); pdfDocument.open(); } // first file in list? |