private OXmlDocSectionElement CreateDocSection(BsonDocument element) { if (_headerFooter) { throw new PBException("header-footer cant contain doc section"); } OXmlDocSectionElement docSection = new OXmlDocSectionElement(); BsonDocument element2 = element.zGet("PageSize").zAsBsonDocument(); if (element2 != null) { docSection.PageSize = new OXmlPageSize { Width = element2.zGet("Width").zAsNullableInt(), Height = element2.zGet("Height").zAsNullableInt() }; } element2 = element.zGet("PageMargin").zAsBsonDocument(); if (element2 != null) { docSection.PageMargin = new OXmlPageMargin { Top = element2.zGet("Top").zAsNullableInt(), Bottom = element2.zGet("Bottom").zAsNullableInt(), Left = element2.zGet("Left").zAsNullableInt(), Right = element2.zGet("Right").zAsNullableInt(), Header = element2.zGet("Header").zAsNullableInt(), Footer = element2.zGet("Footer").zAsNullableInt() }; } docSection.PageNumberStart = element.zGet("PageNumberStart").zAsNullableInt(); return(docSection); }
//private void AddPage() //{ // _paragraph = _body.AppendChild(new Paragraph()); // _run = _paragraph.AppendChild(new Run()); //} private void AddDocSection(OXmlDocSectionElement element) { //Trace.WriteLine("OXmlDoc.AddDocSection()"); CreateSectionProperties(); // PageSize, <w:pgSz w:w="11907" w:h="16839"/>, 11907 1/20 point = 21 cm, 16839 1/20 point = 29.7 cm, unit = 1/20 point, 11907 1/20 point = 595.35 point PageSize pageSize = CreatePageSize(element.PageSize); if (pageSize != null) { _sectionProperties.AppendChild(pageSize); } // <w:pgMar w:top="720" w:right="1418" w:bottom="720" w:left="1418" w:header="284" w:footer="284" w:gutter="0"/> PageMargin pageMargin = CreatePageMargin(element.PageMargin); if (pageMargin != null) { _sectionProperties.AppendChild(pageMargin); } // PageNumberType, <w:pgNumType w:start="0" /> if (element.PageNumberStart != null) { _sectionProperties.AppendChild(new PageNumberType { Start = element.PageNumberStart }); } }
public OXmlDocSectionElement _Deserialize(BsonReader bsonReader, IBsonSerializationOptions options) { OXmlDocSectionElement element = new OXmlDocSectionElement(); while (true) { BsonType bsonType = bsonReader.ReadBsonType(); if (bsonType == BsonType.EndOfDocument) break; string name = bsonReader.ReadName(); switch (name.ToLower()) { case "type": if (bsonType != BsonType.String) throw new PBException($"wrong type value {bsonType}"); string type = bsonReader.ReadString(); if (type.ToLower() != "docsection") throw new PBException($"invalid Type {type} when deserialize OXmlDocSectionElement"); break; case "pagesize": if (bsonType == BsonType.Null) break; if (bsonType != BsonType.Document) throw new PBException($"wrong PageSize value {bsonType}"); element.PageSize = ReadPageSize(bsonReader); break; case "pagemargin": if (bsonType == BsonType.Null) break; if (bsonType != BsonType.Document) throw new PBException($"wrong PageMargin value {bsonType}"); element.PageMargin = ReadPageMargin(bsonReader); break; case "pagenumberstart": if (bsonType == BsonType.Null) break; if (bsonType != BsonType.Int32) throw new PBException($"wrong PageNumberStart value {bsonType}"); element.PageNumberStart = bsonReader.ReadInt32(); break; default: throw new PBException($"unknow DocSection value \"{name}\""); } } return element; }
//private void AddPage() //{ // _paragraph = _body.AppendChild(new Paragraph()); // _run = _paragraph.AppendChild(new Run()); //} private void AddDocSection(OXmlDocSectionElement element) { CreateSectionProperties(); // PageSize, <w:pgSz w:w="11907" w:h="16839"/>, 11907 1/20 point = 21 cm, 16839 1/20 point = 29.7 cm, unit = 1/20 point, 11907 1/20 point = 595.35 point PageSize pageSize = CreatePageSize(element.PageSize); if (pageSize != null) _sectionProperties.AppendChild(pageSize); // <w:pgMar w:top="720" w:right="1418" w:bottom="720" w:left="1418" w:header="284" w:footer="284" w:gutter="0"/> PageMargin pageMargin = CreatePageMargin(element.PageMargin); if (pageMargin != null) _sectionProperties.AppendChild(pageMargin); // PageNumberType, <w:pgNumType w:start="0" /> if (element.PageNumberStart != null) _sectionProperties.AppendChild(new PageNumberType { Start = element.PageNumberStart }); }
private OXmlDocSectionElement CreateDocSection(BsonDocument element) { if (_headerFooter) throw new PBException("header-footer cant contain doc section"); OXmlDocSectionElement docSection = new OXmlDocSectionElement(); BsonDocument element2 = element.zGet("PageSize").zAsBsonDocument(); if (element2 != null) { docSection.PageSize = new OXmlPageSize { Width = element2.zGet("Width").zAsNullableInt(), Height = element2.zGet("Height").zAsNullableInt() }; } element2 = element.zGet("PageMargin").zAsBsonDocument(); if (element2 != null) { docSection.PageMargin = new OXmlPageMargin { Top = element2.zGet("Top").zAsNullableInt(), Bottom = element2.zGet("Bottom").zAsNullableInt(), Left = element2.zGet("Left").zAsNullableInt(), Right = element2.zGet("Right").zAsNullableInt(), Header = element2.zGet("Header").zAsNullableInt(), Footer = element2.zGet("Footer").zAsNullableInt() }; } docSection.PageNumberStart = element.zGet("PageNumberStart").zAsNullableInt(); return docSection; }