예제 #1
0
        public void WritePatternObject(TPdfStream DataStream, TXRefSection XRef)
        {
            byte[] PatternDef = GetPatternDef();
            XRef.SetObjectOffset(PatternObjId, DataStream);
            TIndirectRecord.SaveHeader(DataStream, PatternObjId);
            TDictionaryRecord.BeginDictionary(DataStream);
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.TypeName, TPdfTokens.GetString(TPdfToken.PatternName));
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.PatternTypeName, "1");
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.PaintTypeName, "1");
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.TilingTypeName, "2");
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.BBoxName, String.Format(CultureInfo.InvariantCulture, "[0 0 {0} {1}]", ImgWidth, ImgHeight));
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.XStepName, PdfConv.CoordsToString(ImgWidth));
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.YStepName, PdfConv.CoordsToString(ImgHeight));
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.MatrixName, PdfConv.ToString(PatternMatrix, true));
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.LengthName, PatternDef.Length);
            TDictionaryRecord.WriteLine(DataStream, TPdfTokens.GetString(TPdfToken.ResourcesName));

            TDictionaryRecord.BeginDictionary(DataStream);
            TPdfBaseRecord.WriteLine(DataStream, TPdfTokens.GetString(TPdfToken.XObjectName));
            TDictionaryRecord.BeginDictionary(DataStream);

            ImageDef.WriteImage(DataStream, XRef);
            TDictionaryRecord.EndDictionary(DataStream);
            TDictionaryRecord.EndDictionary(DataStream);
            TDictionaryRecord.EndDictionary(DataStream);

            TStreamRecord.BeginSave(DataStream);
            DataStream.Write(PatternDef);
            TStreamRecord.EndSave(DataStream);

            TIndirectRecord.SaveTrailer(DataStream);

            ImageDef.WriteImageObject(DataStream, XRef);
        }
예제 #2
0
        public void WritePatternObject(TPdfStream DataStream, TXRefSection XRef)
        {
            int MatrixSize;

            byte[] PatternDef = GetPattern(out MatrixSize);

            XRef.SetObjectOffset(PatternObjId, DataStream);
            TIndirectRecord.SaveHeader(DataStream, PatternObjId);
            TDictionaryRecord.BeginDictionary(DataStream);
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.TypeName, TPdfTokens.GetString(TPdfToken.PatternName));
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.PatternTypeName, "1");
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.PaintTypeName, "2");
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.TilingTypeName, "2");
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.BBoxName, String.Format(CultureInfo.InvariantCulture, "[0 0 {0} {0}]", MatrixSize));
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.XStepName, MatrixSize.ToString(CultureInfo.InvariantCulture));
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.YStepName, MatrixSize.ToString(CultureInfo.InvariantCulture));
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.LengthName, PatternDef.Length);
            TDictionaryRecord.WriteLine(DataStream, TPdfTokens.GetString(TPdfToken.ResourcesName));
            TDictionaryRecord.BeginDictionary(DataStream);
            TDictionaryRecord.EndDictionary(DataStream);

            TDictionaryRecord.EndDictionary(DataStream);

            TStreamRecord.BeginSave(DataStream);
            DataStream.Write(PatternDef);
            TStreamRecord.EndSave(DataStream);

            TIndirectRecord.SaveTrailer(DataStream);
        }
예제 #3
0
        private void SaveToUnicode(TPdfStream DataStream, TXRefSection XRef)
        {
            XRef.SetObjectOffset(ToUnicodeId, DataStream);
            TIndirectRecord.SaveHeader(DataStream, ToUnicodeId);

            XRef.SetObjectOffset(ToUnicodeLenId, DataStream);
            TStreamRecord.BeginSave(DataStream, ToUnicodeLenId, FCompress);
            long StartStream = DataStream.Position;
            bool Compressing = DataStream.Compress;

            try
            {
                DataStream.Compress = FCompress;
                WriteToUnicodeData(DataStream);
            }
            finally
            {
                DataStream.Compress = Compressing;
            }
            long EndStream = DataStream.Position;

            TStreamRecord.EndSave(DataStream);
            TIndirectRecord.SaveTrailer(DataStream);

            XRef.SetObjectOffset(ToUnicodeLenId, DataStream);

            TIndirectRecord.SaveHeader(DataStream, ToUnicodeLenId);
            TPdfBaseRecord.WriteLine(DataStream, (EndStream - StartStream).ToString(CultureInfo.InvariantCulture));
            TIndirectRecord.SaveTrailer(DataStream);
        }
예제 #4
0
        protected override void SaveExtraKeys(TPdfStream DataStream, TXRefSection XRef, bool Compress)
        {
            Debug.Assert(DataStream.Compress == false); //It shouldn't be turned on at this place.
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.LengthName, FunctionData(Compress).Length.ToString(CultureInfo.InvariantCulture));
            if (NeedsCompression(Compress))
            {
                TStreamRecord.SetFlateDecode(DataStream);
            }

            TDictionaryRecord.SaveKey(DataStream, TPdfToken.SizeName, PdfConv.ToString(Size, true));
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.BitsPerSampleName, 8);
        }
예제 #5
0
        private void CreateNewPage(TPdfStream DataStream, TXRefSection XRef, TPaperDimensions PageSize)
        {
            int PageId    = XRef.GetNewObject(DataStream);
            int ContentId = XRef.GetNewObject(DataStream);

            PageTree.AddPage(PageId, ContentId, PageSize);
            TIndirectRecord.SaveHeader(DataStream, ContentId);
            LengthId = XRef.GetNewObject(DataStream);
            TStreamRecord.BeginSave(DataStream, LengthId, Compress);
            DataStream.Compress = Compress;
            StartStream         = DataStream.Position;
        }
예제 #6
0
        internal void FinishPage(TPdfStream DataStream, TXRefSection XRef)
        {
            DataStream.FlushEndText();
            DataStream.Compress = false;
            EndStream           = DataStream.Position;
            TStreamRecord.EndSave(DataStream);
            TIndirectRecord.SaveTrailer(DataStream);

            XRef.SetObjectOffset(LengthId, DataStream);
            TIndirectRecord.SaveHeader(DataStream, LengthId);
            TPdfBaseRecord.WriteLine(DataStream, (EndStream - StartStream).ToString(CultureInfo.InvariantCulture));
            TIndirectRecord.SaveTrailer(DataStream);
        }
예제 #7
0
        public void WriteSMaskObject(TPdfStream DataStream, TXRefSection XRef)
        {
            //Actually write stream
            XRef.SetObjectOffset(SMaskObjId, DataStream);
            TIndirectRecord.SaveHeader(DataStream, SMaskObjId);
            TDictionaryRecord.BeginDictionary(DataStream);
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.LengthName, SMask.Length);
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.TypeName, TPdfTokens.GetString(TPdfToken.XObjectName));
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.SubtypeName, TPdfTokens.GetString(TPdfToken.FormName));
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.BBoxName, BBox);
            TDictionaryRecord.WriteLine(DataStream, TPdfTokens.GetString(TPdfToken.GroupName));
            TDictionaryRecord.BeginDictionary(DataStream);
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.SName, TPdfTokens.GetString(TPdfToken.TransparencyName));

            TDictionaryRecord.EndDictionary(DataStream);

            TDictionaryRecord.EndDictionary(DataStream);

            TStreamRecord.BeginSave(DataStream);
            TStreamRecord.Write(DataStream, SMask);
            TStreamRecord.EndSave(DataStream);
            TIndirectRecord.SaveTrailer(DataStream);
        }
예제 #8
0
        internal void WriteFont(TPdfStream DataStream, TXRefSection XRef, bool Compress)
        {
            if (AlreadySaved || ObjectId == -1)
            {
                return;
            }
            AlreadySaved = true;
            int EmbeddedLenId = XRef.GetNewObject(DataStream);             //Stream Length

            XRef.SetObjectOffset(ObjectId, DataStream);
            TIndirectRecord.SaveHeader(DataStream, ObjectId);

            byte[] FontData = TrueTypeData.SubsetFontData(SubsetCMap);

            TStreamRecord.BeginSave(DataStream, EmbeddedLenId, Compress, FontData.Length);
            long StartStream = DataStream.Position;
            bool Compressing = DataStream.Compress;

            try
            {
                DataStream.Compress = Compress;
                DataStream.Write(FontData);
            }
            finally
            {
                DataStream.Compress = Compressing;
            }
            long EndStream = DataStream.Position;

            TStreamRecord.EndSave(DataStream);
            TIndirectRecord.SaveTrailer(DataStream);

            XRef.SetObjectOffset(EmbeddedLenId, DataStream);
            TIndirectRecord.SaveHeader(DataStream, EmbeddedLenId);
            TPdfBaseRecord.WriteLine(DataStream, (EndStream - StartStream).ToString(CultureInfo.InvariantCulture));
            TIndirectRecord.SaveTrailer(DataStream);
        }
예제 #9
0
        private void WriteImageOrMaskObject(TPdfStream DataStream, TXRefSection XRef, bool IsSMask, int ObjId)
        {
            XRef.SetObjectOffset(ObjId, DataStream);
            TIndirectRecord.SaveHeader(DataStream, ObjId);
            TDictionaryRecord.BeginDictionary(DataStream);
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.TypeName, TPdfTokens.GetString(TPdfToken.XObjectName));
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.SubtypeName, TPdfTokens.GetString(TPdfToken.ImageName));
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.WidthName, FImageWidth);
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.HeightName, FImageHeight);

            if (!IsSMask)
            {
                TDictionaryRecord.SaveKey(DataStream, TPdfToken.BitsPerComponentName, FBitsPerComponent);
                if (FSMask != null)
                {
                    TDictionaryRecord.SaveKey(DataStream, MaskOrSMask, TIndirectRecord.GetCallObj(SMaskId));
                }
                if (FMask != null)
                {
                    TDictionaryRecord.SaveKey(DataStream, TPdfToken.MaskName, FMask);
                }
                TDictionaryRecord.SaveKey(DataStream, TPdfToken.LengthName, (int)FImage.Length);
                TDictionaryRecord.SaveKey(DataStream, TPdfToken.ColorSpaceName, FColorSpace);                  //This value is stored on the PropertyTagExifColorSpace property of the image for JPEG.
                if (FDecodeParmsName != null)
                {
                    TDictionaryRecord.SaveKey(DataStream, TPdfToken.DecodeParmsName, FDecodeParmsName);
                }
            }
            else
            {
                if (OneBitMask != null && FMask == null)
                {
                    SaveSMaskAsMask(DataStream);
                }
                else
                {
                    TDictionaryRecord.SaveKey(DataStream, TPdfToken.BitsPerComponentName, 8);
                    TDictionaryRecord.SaveKey(DataStream, TPdfToken.LengthName, (int)FSMask.Length);
                    TDictionaryRecord.SaveKey(DataStream, TPdfToken.ColorSpaceName, TPdfTokens.GetString(TPdfToken.DeviceGrayName));                      //This value is stored on the PropertyTagExifColorSpace property of the image for JPEG.
                    if (FDecodeParmsSMask != null)
                    {
                        TDictionaryRecord.SaveKey(DataStream, TPdfToken.DecodeParmsName, FDecodeParmsSMask);
                    }
                }
            }

            TDictionaryRecord.SaveKey(DataStream, TPdfToken.FilterName, FFilterName);


            TDictionaryRecord.EndDictionary(DataStream);

            TStreamRecord.BeginSave(DataStream);
            if (!IsSMask)
            {
                DataStream.Write(FImage);
            }
            else
            {
                if (OneBitMask != null)
                {
                    DataStream.Write(OneBitMask);
                }
                else
                {
                    DataStream.Write(FSMask);
                }
            }
            TStreamRecord.EndSave(DataStream);

            TIndirectRecord.SaveTrailer(DataStream);
        }
예제 #10
0
 protected override void SaveStream(TPdfStream DataStream, TXRefSection XRef, bool Compress)
 {
     TStreamRecord.BeginSave(DataStream);
     DataStream.Write(FunctionData(Compress));
     TStreamRecord.EndSave(DataStream);
 }
예제 #11
0
파일: PdfForms.cs 프로젝트: mwilian/demos
 private static void WriteStream(TPdfStream DataStream, string StreamContents)
 {
     TStreamRecord.BeginSave(DataStream);
     WriteLine(DataStream, StreamContents);
     TStreamRecord.EndSave(DataStream);
 }