Prev: print
Next: geoLocator
From: PaulH **AdobeCommunityExpert** on
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
I get the following error

The selected method setEncryption was not found

I'm using a itext 1.4.6.
From: PaulH **AdobeCommunityExpert** on
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
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
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?
First  |  Prev  |  Next  |  Last
Pages: 1 2 3
Prev: print
Next: geoLocator