Hello Aspose Team,
When lines are drawn using the PDFContentEditor, user was able to move the line when rendered in Acrobat Version 11.
Please help us in getting this issue resolved.
The code we use is as below,
InputStream is = new ByteArrayInputStream(baos.toByteArray());
PdfContentEditor editor = new PdfContentEditor();
editor.bindPdf(is);
Rectangle rect=new Rectangle();
int []dashArray={};
String []LEArray={}; editor.createLine(rect,"",x1,y1,x2,y2,pageNum,2,“s”,dashArray,LEArray,Color.BLACK);
editor.save(os);
Thanks,
Ashok
Hi Ashok,
Hello Aspose Team,
Thanks for your response.
We have to restrict both selction and movement.
Kindly help us on that regard.
Immediate response would be appreciated.
Thanks,
Ashok
Hi Ashok,
issue as PDFNEWJAVA-33831 in our issue tracking system. We will
further look into the details of this problem and will keep you updated on the
status of correction. Please be patient and spare us little time. We are sorry
for this inconvenience.
// input PDF file<o:p></o:p>
String inFile = "c:/pdftest/LineAdded.pdf";
// resultant PDF file
String outFile = "c:/pdftest/FileSecurity_kitOut.pdf";
// instantiate PdfFile Security object
com.aspose.pdf.kit.PdfFileSecurity fileSecurity = new com.aspose.pdf.kit.PdfFileSecurity(inFile, outFile);
// set restrictions over PDF file. Pdf Contents cannot be modified
fileSecurity.setPrivilege(com.aspose.pdf.kit.PdfPrivilege.ModifyContents
|com.aspose.pdf.kit.PdfPrivilege.ScreenReaders);
Hello Aspose Team,
I used the above lines of code.
But still we were able to move the lines.
Following are the lines of code we used,
if(null==pdfDocument){
pdfDocument = new Document();
}
System.out.println("Pdf document existing page count " + pdfDocument.getPages().size());
for(int i=0; i<totalPage;i++){
pdfDocument.getPages().add().setPageSize(PDFGenConstants.pageWidth, PDFGenConstants.pageHeight);
}
pdfDocument.save(tempPdfFileName);
com.aspose.pdf.kit.PdfFileSecurity fileSecurity = new com.aspose.pdf.kit.PdfFileSecurity(tempPdfFileName, tempPdfFileName);
// set restrictions over PDF file. Pdf Contents cannot be modified
try {
fileSecurity.setPrivilege(com.aspose.pdf.kit.PdfPrivilege.ModifyContents);
} catch (PdfKitException e) {
throw new ServiceException(PDFGenErrorConstants.RBUILDER_PDFGEN_FAILED, "Setting Security Previlage Failed " + e.getMessage(), e);
} catch (IOException e) {
throw new ServiceException(PDFGenErrorConstants.RBUILDER_PDFGEN_FAILED, "Settign Security Previlage Failed " + e.getMessage(), e);
}
For your reference am attaching the pdf generated.
Please open the pdf in X1 version.
Hi Ashok,
// load input PDF file<o:p></o:p>
FileInputStream in = new FileInputStream(new File("c:/pdftest/aspose (1).pdf"));
// instantiate PdfContentEditor instance
com.aspose.pdf.facades.PdfContentEditor editor = new com.aspose.pdf.facades.PdfContentEditor();
// bind the source PDF file
editor.bindPdf(in);
Rectangle rect=new Rectangle();
int []dashArray={};
String []LEArray={}; editor.createLine(rect,"",100,100,200,200,1,2,Color.BLACK,"s",dashArray,LEArray);
// instantiate ByteArray OutputStream
ByteArrayOutputStream baos = new ByteArrayOutputStream();
// save the file to Stream object
editor.save(baos);
// instantiate Object OutputStream so that contents of ByteArray can be loaded
ObjectOutputStream os = new ObjectOutputStream(baos);
os.writeObject(new java.util.Date());
os.close();
// save the contents into Byte array object
byte[] data = baos.toByteArray();
// load the contents of Byte array to ByteInput Stream
ByteArrayInputStream bis = new ByteArrayInputStream(data);
// instantiate PdfFile Security object
com.aspose.pdf.kit.PdfFileSecurity fileSecurity = new com.aspose.pdf.kit.PdfFileSecurity(bis, new FileOutputStream(new File("c:/pdftest/SecureFile.pdf")));
// set restrictions over PDF file. Pdf Contents cannot be modified
fileSecurity.setPrivilege(com.aspose.pdf.kit.PdfPrivilege.ModifyContents
|com.aspose.pdf.kit.PdfPrivilege.ScreenReaders);
Hi Ashok,
String inFile = “c:/pdftest/Alignment_DOM.pdf”;<o:p></o:p>
String outFile1 = "c:/pdftest/TestEncrypt1.pdf";
com.aspose.pdf.facades.PdfFileSecurity fileSecurity = new com.aspose.pdf.facades.PdfFileSecurity(inFile, outFile1);
// PdfPrivilege came to DocumentPrivilege, true -> KeySize.x128
fileSecurity.encryptFile(null, "mypassword", com.aspose.pdf.facades.DocumentPrivilege.getScreenReaders(), com.aspose.pdf.facades.KeySize.x128);
fileSecurity.close();
String outFile2 = "c:/pdftest/TestEncrypt2.pdf";
com.aspose.pdf.facades.PdfFileSecurity fileSecurity2 = new com.aspose.pdf.facades.PdfFileSecurity(inFile, outFile2);
fileSecurity2.encryptFile("", "owner", com.aspose.pdf.facades.DocumentPrivilege.getAllowAll(), com.aspose.pdf.facades.KeySize.x128); // was PdfPrivilege.AllowAll
fileSecurity2.close();
String outFile4 = "c:/pdftest/TestEncrypt4.pdf";
com.aspose.pdf.facades.PdfFileSecurity fileSecurity4 = new com.aspose.pdf.facades.PdfFileSecurity(inFile, outFile4);
fileSecurity4.encryptFile("user", "owner", com.aspose.pdf.facades.DocumentPrivilege.getCopy(), com.aspose.pdf.facades.KeySize.x40); // was PdfPrivilege.Copy
fileSecurity4.close();