Examples of PdfStream


Examples of org.pdfclown.objects.PdfStream

      {
        /*
          Approach 1: Modifying the existing data object.
        */
        // Get the existing data object from the corresponding indirect object!
        PdfStream toUnicodeStream = (PdfStream)toUnicodeReference.getDataObject();

        // Editing the data object...
        IBuffer streamBody = toUnicodeStream.getBody();
        streamBody.setLength(0); // Erases the stream content to prepare it for new content insertion.
        streamBody.append("... modified ..."); // Adds arbitrary contents (NOTE: this would NOT be done in a real ToUnicode stream! We are just testing the editing functionality...).
      }
      else
      {
        /*
          Approach 2: Creating a new data object.
        */
        // Create a new data object!
        PdfStream toUnicodeStream = new PdfStream();
        // Associate the new data object to the existing indirect object, replacing the old one!
        toUnicodeReference.setDataObject(toUnicodeStream);

        // Editing the data object...
        IBuffer streamBody = toUnicodeStream.getBody();
        streamBody.append("... created ..."); // Adds arbitrary contents (NOTE: this would NOT be done in a real ToUnicode stream! We are just testing the editing functionality...).
      }

      toUnicodeReference.getIndirectObject().update(); // Ensures that the indirect object is updated.
    }
View Full Code Here

Examples of org.pdfclown.objects.PdfStream

    Document context
    )
  {
    return new ImageXObject(
      context,
      new PdfStream(
        new PdfDictionary(
          new PdfName[]
          {
            PdfName.Width,
            PdfName.Height,
View Full Code Here

Examples of org.pdfclown.objects.PdfStream

    )
  {
    PdfDictionary descriptor = getDescriptor();
    if(descriptor.containsKey(PdfName.FontFile)) // Embedded noncompact Type 1 font.
    {
      PdfStream fontFileStream = (PdfStream)descriptor.resolve(PdfName.FontFile);
      PfbParser parser = new PfbParser(fontFileStream.getBody());
      return parser.parse();
    }
    else if(descriptor.containsKey(PdfName.FontFile3)) // Embedded compact Type 1 font.
    {
      PdfStream fontFileStream = (PdfStream)descriptor.resolve(PdfName.FontFile3);
      PdfName fontFileSubtype = (PdfName)fontFileStream.getHeader().get(PdfName.Subtype);
      if(fontFileSubtype.equals(PdfName.Type1C)) // CFF.
      {throw new NotImplementedException("Embedded CFF font file.");}
      else if(fontFileSubtype.equals(PdfName.OpenType)) // OpenFont/CFF.
      {throw new NotImplementedException("Embedded OpenFont/CFF font file.");}
      else
View Full Code Here

Examples of org.pdfclown.objects.PdfStream

  protected void load(
    )
  {
    if(getBaseDataObject().containsKey(PdfName.ToUnicode)) // To-Unicode explicit mapping.
    {
      PdfStream toUnicodeStream = (PdfStream)getBaseDataObject().resolve(PdfName.ToUnicode);
      CMapParser parser = new CMapParser(toUnicodeStream.getBody());
      codes = new BiMap<ByteArray,Integer>(parser.parse());
      symbolic = false;
    }

    onLoad();
View Full Code Here

Examples of org.pdfclown.objects.PdfStream

    Document context
    )
  {
    this(
      context,
      new PdfStream()
      );
  }
View Full Code Here

Examples of org.pdfclown.objects.PdfStream

        + "end\n"
        + "end\n"
        + "%%EndResource\n"
        + "%%EOF"
      );
    PdfStream cmapStream = new PdfStream(cmapBuffer);
    PdfDictionary cmapHead = cmapStream.getHeader();
    cmapHead.put(
      PdfName.Type,
      PdfName.CMap
      );
    cmapHead.put(
      PdfName.CMapName,
      new PdfName("Adobe-Identity-UCS")
      );
    cmapHead.put(
      PdfName.CIDSystemInfo,
      new PdfDictionary(
        new PdfName[]
        {
          PdfName.Registry,
          PdfName.Ordering,
          PdfName.Supplement
        },
        new PdfDirectObject[]
        {
          new PdfTextString("Adobe"),
          new PdfTextString("Identity"),
          new PdfInteger(0)
        }
        )
      ); // Generic predefined CMap (Identity-H/V (Adobe-Identity-0)) [PDF:1.6:5.6.4].
    font.put(
      PdfName.Encoding,
      getFile().register(cmapStream)
      );

    PdfStream gIdStream = new PdfStream(gIdBuffer);
    cidFont.put(
      PdfName.CIDToGIDMap,
      getFile().register(gIdStream)
      );

    cidFont.put(
      PdfName.W,
      new PdfArray(new PdfDirectObject[]{new PdfInteger(1),widthsObject})
      );

    toUnicodeBuffer.append(
      "endbfchar\n"
        + "endcmap\n"
        + "CMapName currentdict /CMap defineresource pop\n"
        + "end\n"
        + "end\n"
      );
    PdfStream toUnicodeStream = new PdfStream(toUnicodeBuffer);
    font.put(
      PdfName.ToUnicode,
      getFile().register(toUnicodeStream)
      );
  }
View Full Code Here

Examples of org.pdfclown.objects.PdfStream

        new PdfInteger(100)
        );
      // FontFile.
  //TODO:IMPL distinguish between truetype (FontDescriptor.FontFile2) and opentype (FontDescriptor.FontFile3 and FontStream.subtype=OpenType)!!!
      PdfReference fontFileReference = getFile().register(
        new PdfStream(
          new PdfDictionary(
            new PdfName[]{PdfName.Subtype},
            new PdfDirectObject[]{PdfName.OpenType}
            ),
          new Buffer(parser.fontData.toByteArray())
View Full Code Here

Examples of org.pdfclown.objects.PdfStream

    IInputStream stream
    )
  {
    super(
      context.getFile(),
      new PdfStream(
        new PdfDictionary(
          new PdfName[]{PdfName.Type},
          new PdfDirectObject[]{PdfName.EmbeddedFile}
          ),
        new Buffer(stream.toByteArray())
View Full Code Here

Examples of org.pdfclown.objects.PdfStream

    Serializes the contents into the content stream.
  */
  public void flush(
    )
  {
    PdfStream stream;
    PdfDataObject baseDataObject = getBaseDataObject();
    // Are contents just a single stream object?
    if(baseDataObject instanceof PdfStream) // Single stream.
    {stream = (PdfStream)baseDataObject;}
    else // Array of streams.
    {
      PdfArray streams = (PdfArray)baseDataObject;
      // No stream available?
      if(streams.size() == 0) // No stream.
      {
        // Add first stream!
        stream = new PdfStream();
        streams.add( // Inserts the new stream into the content stream.
          getFile().register(stream) // Inserts the new stream into the file.
          );
      }
      else // Streams exist.
      {
        // Eliminating exceeding streams...
        /*
          NOTE: Applications that consume or produce PDF files are not required to preserve
          the existing structure of the Contents array [PDF:1.6:3.6.2].
        */
        while(streams.size() > 1)
        {
          getFile().unregister( // Removes the exceeding stream from the file.
            (PdfReference)streams.remove(1) // Removes the exceeding stream from the content stream.
            );
        }

        PdfReference streamReference = (PdfReference)streams.get(0);
        File.update(streamReference); // Updates the existing stream into the file.
        stream = (PdfStream)streamReference.getDataObject();
      }
    }

    // Get the stream buffer!
    IBuffer buffer = stream.getBody();
    // Delete old contents from the stream buffer!
    buffer.setLength(0);
    // Serializing the new contents into the stream buffer...
    for(ContentObject item : items)
    {item.writeTo(buffer);}
View Full Code Here

Examples of org.pdfclown.objects.PdfStream

  // <private>
  private PrimitiveComposer createFilter(
    )
  {
    PdfReference reference = page.getFile().register(new PdfStream());

    return new PrimitiveComposer(
      new ContentScanner(
        new Contents(
          reference,
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.