You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PDFICCStream.java 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * $Id$
  3. * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
  4. * For details on use and redistribution please refer to the
  5. * LICENSE file included with these sources.
  6. */
  7. package org.apache.fop.pdf;
  8. import java.awt.color.ICC_Profile;
  9. public class PDFICCStream extends PDFStream {
  10. private int origLength;
  11. private int len1, len3;
  12. private ICC_Profile cp;
  13. private PDFColorSpace pdfColorSpace;
  14. public void setColorSpace(ICC_Profile cp, PDFColorSpace alt) {
  15. this.cp = cp;
  16. pdfColorSpace = alt;
  17. }
  18. public PDFICCStream(int num) {
  19. super(num);
  20. cp = null;
  21. }
  22. // overload the base object method so we don't have to copy
  23. // byte arrays around so much
  24. protected int output(java.io.OutputStream stream)
  25. throws java.io.IOException {
  26. setData(cp.getData());
  27. int length = 0;
  28. String filterEntry = applyFilters();
  29. StringBuffer pb = new StringBuffer();
  30. pb.append(this.number).append(" ").append(this.generation).append(" obj\n<< ");
  31. pb.append("/N ").append(cp.getNumComponents()).append(" ");
  32. if (pdfColorSpace != null) {
  33. pb.append("/Alternate /").append(pdfColorSpace.getColorSpacePDFString()).append(" ");
  34. }
  35. pb.append("/Length ").append((_data.getSize() + 1)).append(" ").append(filterEntry);
  36. pb.append(" >>\n");
  37. byte[] p = pb.toString().getBytes();
  38. stream.write(p);
  39. length += p.length;
  40. length += outputStreamData(stream);
  41. p = "endobj\n".getBytes();
  42. stream.write(p);
  43. length += p.length;
  44. return length;
  45. }
  46. }