Read only PDF with FOP. Is it possible?
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 4
- Joined: Tue May 16, 2006 3:40 pm
Read only PDF with FOP. Is it possible?
Hi.
I use fop to create a pdf from xml with java.
But I would like to create a read only pdf, without the possibility to copy text by the user. Is it possible with fop? If not, what can I use?
thanks
I use fop to create a pdf from xml with java.
But I would like to create a read only pdf, without the possibility to copy text by the user. Is it possible with fop? If not, what can I use?
thanks
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Post by sorin_ristache »
Hello,
Yes it is possible. The Apache website documents the PDF encryption features of FOP when it is called from Java.
Regards,
Sorin
Yes it is possible. The Apache website documents the PDF encryption features of FOP when it is called from Java.
Regards,
Sorin
-
- Posts: 4
- Joined: Tue May 16, 2006 3:40 pm
Thank you very much
This is my code:
ByteArrayOutputStream BAout = new ByteArrayOutputStream();
org.apache.fop.apps.Driver driver = new org.apache.fop.apps.Driver();
driver.setRenderer(org.apache.fop.apps.Driver.RENDER_PDF);
driver.setOutputStream(BAout);
driver.render(input.getParser(), input.getInputSource());
File outputFile = new File(filenamePDF);
FileOutputStream outFileWriter = new FileOutputStream(filenamePDF);
byte[] content = BAout.toByteArray();
outFileWriter.write(content);
outFileWriter.flush();
outFileWriter.close();
How can I integrate with the code of the page you redirect me?
thanks
This is my code:
ByteArrayOutputStream BAout = new ByteArrayOutputStream();
org.apache.fop.apps.Driver driver = new org.apache.fop.apps.Driver();
driver.setRenderer(org.apache.fop.apps.Driver.RENDER_PDF);
driver.setOutputStream(BAout);
driver.render(input.getParser(), input.getInputSource());
File outputFile = new File(filenamePDF);
FileOutputStream outFileWriter = new FileOutputStream(filenamePDF);
byte[] content = BAout.toByteArray();
outFileWriter.write(content);
outFileWriter.flush();
outFileWriter.close();
How can I integrate with the code of the page you redirect me?
thanks
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Post by sorin_ristache »
Hello,
You have to obtain a reference to a FOUserAgent object and call getRendererOptions().put("encryption-params", new PDFEncryptionParams( ... )) on that reference.
Regards,
Sorin
You have to obtain a reference to a FOUserAgent object and call getRendererOptions().put("encryption-params", new PDFEncryptionParams( ... )) on that reference.
Regards,
Sorin
-
- Posts: 4
- Joined: Tue May 16, 2006 3:40 pm
I use this:
ByteArrayOutputStream BAout = new ByteArrayOutputStream();
org.apache.fop.apps.Driver driver = new org.apache.fop.apps.Driver();
java.util.HashMap rendererOptions = new java.util.HashMap();
rendererOptions.put("ownerPassword", "mypassword");
rendererOptions.put("allowCopyContent", "FALSE");
rendererOptions.put("allowEditContent", "FALSE");
rendererOptions.put("allowPrint", "FALSE");
driver.getRenderer().setOptions(rendererOptions);
driver.setRenderer(org.apache.fop.apps.Driver.RENDER_PDF);
driver.setOutputStream(BAout);
driver.render(input.getParser(), input.getInputSource());
File outputFile = new File(filenamePDF);
FileOutputStream outFileWriter = new FileOutputStream(filenamePDF);
byte[] content = BAout.toByteArray();
outFileWriter.write(content);
outFileWriter.flush();
outFileWriter.close();
but I get a Nullpointerexception
ByteArrayOutputStream BAout = new ByteArrayOutputStream();
org.apache.fop.apps.Driver driver = new org.apache.fop.apps.Driver();
java.util.HashMap rendererOptions = new java.util.HashMap();
rendererOptions.put("ownerPassword", "mypassword");
rendererOptions.put("allowCopyContent", "FALSE");
rendererOptions.put("allowEditContent", "FALSE");
rendererOptions.put("allowPrint", "FALSE");
driver.getRenderer().setOptions(rendererOptions);
driver.setRenderer(org.apache.fop.apps.Driver.RENDER_PDF);
driver.setOutputStream(BAout);
driver.render(input.getParser(), input.getInputSource());
File outputFile = new File(filenamePDF);
FileOutputStream outFileWriter = new FileOutputStream(filenamePDF);
byte[] content = BAout.toByteArray();
outFileWriter.write(content);
outFileWriter.flush();
outFileWriter.close();
but I get a Nullpointerexception
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Post by sorin_ristache »
Hello,
I think you can get more help about FOP problems that are not related with <oXygen/> on the FOP mailing list.
Regards,
Sorin
I think you can get more help about FOP problems that are not related with <oXygen/> on the FOP mailing list.
Regards,
Sorin
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service