void DescendentFontWriter::WriteCIDSet(const UIntAndGlyphEncodingInfoVector& inEncodedGlyphs) { mObjectsContext->StartNewIndirectObject(mCIDSetObjectID); PDFStream* pdfStream = mObjectsContext->StartPDFStream(); IByteWriter* cidSetWritingContext = pdfStream->GetWriteStream(); Byte buffer; UIntAndGlyphEncodingInfoVector::const_iterator it = inEncodedGlyphs.begin(); unsigned int upperLimit = inEncodedGlyphs.back().first; for(unsigned int i=0; i < upperLimit; i+=8) { buffer = (it->first == i) ? 1:0; if(it->first == i) ++it; for(unsigned int j=1;j<8;++j) { buffer = buffer << 1; if(it != inEncodedGlyphs.end() && (it->first == i + j)) { buffer |= 1; ++it; if(it == inEncodedGlyphs.end()) break; } } cidSetWritingContext->Write(&buffer,1); } mObjectsContext->EndPDFStream(pdfStream); delete pdfStream; }
EStatusCode BufferedOutputStreamTest::Run() { IByteWriter* stream = new OutputBufferedStream(new OutputFileStream("C:\\PDFLibTests\\BufferedOutputStreamTest.txt"),2); Byte buffer[5] = {'a','b','c','d','e'}; stream->Write(buffer,5); delete stream; return PDFHummus::eSuccess; }
void CIDFontWriter::WriteToUnicodeMap(ObjectIDType inToUnicodeMap) { mObjectsContext->StartNewIndirectObject(inToUnicodeMap); PDFStream* pdfStream = mObjectsContext->StartPDFStream(); IByteWriter* cmapWriteContext = pdfStream->GetWriteStream(); PrimitiveObjectsWriter primitiveWriter(cmapWriteContext); unsigned long i = 1; UIntAndGlyphEncodingInfoVector::iterator it = mCharactersVector.begin() + 1; // skip 0 glyph unsigned long vectorSize = (unsigned long)mCharactersVector.size() - 1; // cause 0 is not there cmapWriteContext->Write((const Byte*)scCmapHeader,strlen(scCmapHeader)); primitiveWriter.WriteHexString(scFourByteRangeStart); primitiveWriter.WriteHexString(scFourByteRangeEnd,eTokenSeparatorEndLine); cmapWriteContext->Write((const Byte*)scEndCodeSpaceRange,strlen(scEndCodeSpaceRange)); if(vectorSize < 100) primitiveWriter.WriteInteger(vectorSize); else primitiveWriter.WriteInteger(100); primitiveWriter.WriteKeyword(scBeginBFChar); WriteGlyphEntry(cmapWriteContext,it->second.mEncodedCharacter,it->second.mUnicodeCharacters); ++it; for(; it != mCharactersVector.end(); ++it,++i) { if(i % 100 == 0) { primitiveWriter.WriteKeyword(scEndBFChar); if(vectorSize - i < 100) primitiveWriter.WriteInteger(vectorSize - i); else primitiveWriter.WriteInteger(100); primitiveWriter.WriteKeyword(scBeginBFChar); } WriteGlyphEntry(cmapWriteContext,it->second.mEncodedCharacter,it->second.mUnicodeCharacters); } primitiveWriter.WriteKeyword(scEndBFChar); cmapWriteContext->Write((const Byte*)scCmapFooter,strlen(scCmapFooter)); mObjectsContext->EndPDFStream(pdfStream); delete pdfStream; }