//----------------------------------------------------------------------------------------------------x /// <summary>Creates a font properties data object for this formatter.</summary> /// <param name="fontProp"></param> internal override FontPropData fontPropData_CreateInstance(FontProp fontProp) { StringBuilder sb = new StringBuilder(50); sb.Append(fontProp.fontDef.sFontName); if (fontProp.bBold) { sb.Append(";B"); } if (fontProp.bItalic) { sb.Append(";I"); } String sKey = sb.ToString(); #if Framework2 FontProp fontProp_Reg; dict_FontProp.TryGetValue(sKey, out fontProp_Reg); #else FontProp fontProp_Reg = (FontProp)dict_FontProp[sKey]; #endif if (fontProp_Reg != null) // font registered //Debug.Assert(fontProp_Reg.fontPropData != null); { return(fontProp_Reg.fontPropData); } // Type1FontData afm = afm_Register(fontProp); PdfFontPropData pdfFontPropData = new PdfFontPropData(sKey, fontProp); dict_FontProp.Add(sKey, fontProp); return(pdfFontPropData); }
//------------------------------------------------------------------------------------------xx.02.2006 /// <summary>Registers the specified font properties for this page.</summary> /// <param name="fontProp">Font properties</param> /// <seealso cref="PdfPageData.ht_FontProp"/> /// <seealso cref="PdfFontPropData.pdfPageData_Registered"/> internal void RegisterFontProp(FontProp fontProp) { PdfFontPropData pdfFontPropData = (PdfFontPropData)fontProp.fontPropData; if (pdfFontPropData.pdfPageData_Registered != this) { ht_FontProp.Add(pdfFontPropData.sKey, fontProp); pdfFontPropData.pdfPageData_Registered = this; } }
//------------------------------------------------------------------------------------------01.02.2006 /// <summary>Writes the object to the buffer.</summary> internal override void Write() { PdfFontPropData pdfFontPropData = (PdfFontPropData)fontProp.fontPropData; Type1FontData type1FontData = (Type1FontData)pdfFontPropData.fontData; StartObj(); Dictionary_Start(); Dictionary_Key("Type"); Name("Font"); Dictionary_Key("Subtype"); Name("Type1"); Dictionary_Key("BaseFont"); Name(type1FontData.sFontName); if (type1FontData.sFamilyName != "ZapfDingbats" && type1FontData.sFamilyName != "Symbol") { Dictionary_Key("Encoding"); Name("WinAnsiEncoding"); } Dictionary_End(); EndObj(); }
//------------------------------------------------------------------------------------------07.02.2006 /// <summary>Writes the RepObj to the buffer.</summary> /// <param name="e">Environment data</param> public void Write(PdfIndirectObject_PageContents.Environment e) { PdfIndirectObject_PageContents p = e.pdfIndirectObject_PageContents; RepString repString = (RepString)e.repObj; Double rWidth = repString.fontProp.rWidth(repString.sText); Double rOfsX = rWidth * repString.rAlignH; Double rOfsY = repString.fontProp.rHeight() * (1 - repString.rAlignV); e.matrixD.Multiply(new MatrixD(1, 0, 0, 1, -rOfsX, rOfsY)); p.Command("BT"); p.Write_Font(repString.fontProp); if (e.bComplex) { p.Write_Matrix(e.matrixD); p.Command("Tm"); } else { p.Write_Point(e.matrixD.rDX, e.matrixD.rDY); p.Command("Td"); } p.String(repString.sText); p.Command("Tj"); p.Command("ET"); if (repString.fontProp.bUnderline) { Type1FontData type1FontData = (Type1FontData)repString.fontProp.fontPropData.fontData; PdfFontPropData pdfFontPropData = (PdfFontPropData)repString.fontProp.fontPropData; Double rSizeFactor = type1FontData.rSizeFactor(repString.fontProp); PenProp pp = new PenProp(e.report, rSizeFactor * type1FontData.fUnderlineThickness / 1000, repString.fontProp.color); p.Write_Pen(pp); Double rD = rSizeFactor * type1FontData.fUnderlinePosition / 1000; p.Write_Point(e.matrixD, 0, -rD); p.Command("m"); p.Write_Point(e.matrixD, rWidth, -rD); p.Command("l"); p.Command("S"); } }
//----------------------------------------------------------------------------------------------------x /// <summary>Prepares the PDF-object structure for a container.</summary> /// <param name="pdfPageData"></param> /// <param name="iObjId"></param> /// <param name="container"></param> private void PrepareObjIdsForContainer(PdfIndirectObject_Page pdfPageData, Container container) { foreach (RepObj repObj in container) { if (repObj is Container) { PrepareObjIdsForContainer(pdfPageData, (Container)repObj); } else if (repObj is RepArcBase) { pdfPageData.bProcSet_PDF = true; } else if (repObj is RepImage) { // RepImage repImage = (RepImage)repObj; // ImageFormat imageFormat = repImage.imageData.image.RawFormat; // if (Object.Equals(imageFormat, ImageFormat.Jpeg)) { // pdfPageData.bProcSet_ImageC = true; // } // else if (Object.Equals(imageFormat, ImageFormat.Tiff)) { // pdfPageData.bProcSet_ImageB = true; // } // else { // Debug.Fail("unknown image type: send image to [email protected]"); // } RepImage repImage = repObj as RepImage; repImage.imageData.stream.Position = 0; //Added By TechnoGuru - [email protected] - http://www.borie.org/ //To support tiff file //I reload Image from stream to be more scalable //(Dont't have like that lots of image object on memeory #if !WindowsCE using (Image image = Image.FromStream(repImage.imageData.stream)) { if (image.RawFormat.Equals(ImageFormat.Tiff) && image.PixelFormat.Equals(PixelFormat.Format1bppIndexed)) { pdfPageData.bProcSet_ImageI = true; // CHANGED } else if (image.RawFormat.Equals(ImageFormat.Tiff) || image.RawFormat.Equals(ImageFormat.Jpeg)) { pdfPageData.bProcSet_ImageC = true; } else { Debug.Fail("unknown image type: send image to [email protected]"); } } #endif } else if (repObj is RepLine) { pdfPageData.bProcSet_PDF = true; } else if (repObj is RepRect) { pdfPageData.bProcSet_PDF = true; } else if (repObj is RepString) { FontProp fontProp_String = ((RepString)repObj).fontProp; PdfFontPropData pdfFontPropData = (PdfFontPropData)fontProp_String.fontPropData; if (pdfFontPropData.pdfIndirectObject_Font == null) { pdfFontPropData.pdfIndirectObject_Font = new PdfIndirectObject_Font(this, fontProp_String); } pdfPageData.RegisterFontProp(fontProp_String); pdfPageData.bProcSet_Text = true; } else { throw new ReportException("unknown report object type [" + repObj.GetType().FullName + "]"); } } }
//------------------------------------------------------------------------------------------xx.02.2006 /// <summary>Writes the object to the buffer.</summary> internal override void Write() { StartObj(); Dictionary_Start(); Dictionary_Key("Type"); Name("Page"); Dictionary_Key("Parent"); IndirectReference(pdfFormatter.pdfIndirectObject_Pages); Dictionary_Key("Resources"); Dictionary_Start(); Dictionary_Key("ProcSet"); ArrayStart(); if (bProcSet_Text) { Name("Text"); } if (bProcSet_PDF) { Space(); Name("PDF"); } if (bProcSet_ImageB) { Space(); Name("ImageB"); } if (bProcSet_ImageC) { Space(); Name("ImageC"); } if (bProcSet_ImageI) { Space(); Name("ImageI"); } ArrayEnd(); Dictionary_Key("Font"); Dictionary_Start(); foreach (FontProp fontProp in ht_FontProp.Values) { PdfFontPropData pdfFontPropData = (PdfFontPropData)fontProp.fontPropData; Dictionary_Key("F" + pdfFontPropData.pdfIndirectObject_Font.iObjectNumber); IndirectReference(pdfFontPropData.pdfIndirectObject_Font); } Dictionary_End(); if (report.ht_ImageData.Count > 0) { Dictionary_Key("XObject"); Dictionary_Start(); foreach (ImageData imageData in report.ht_ImageData.Values) { PdfIndirectObject_ImageJpeg pdfIndirectObject_ImageJpeg = (PdfIndirectObject_ImageJpeg)imageData.oImageResourceX; Dictionary_Key("I" + pdfIndirectObject_ImageJpeg.iObjectNumber); IndirectReference(pdfIndirectObject_ImageJpeg); } Dictionary_End(); } Dictionary_End(); Dictionary_Key("MediaBox"); ArrayStart(); Number(0); Space(); Number(0); Space(); Number(page.rWidth); Space(); Number(page.rHeight); ArrayEnd(); Dictionary_Key("CropBox"); ArrayStart(); Number(0); Space(); Number(0); Space(); Number(page.rWidth); Space(); Number(page.rHeight); ArrayEnd(); Dictionary_Key("Rotate"); Number(0); Dictionary_Key("Contents"); IndirectReference(pdfIndirectObject_PageContents); Dictionary_End(); EndObj(); }