Exemplo n.º 1
0
 public OPFMetadata()
 {
     DC = new DCMetadata();
     X  = new XMetadata();
 }
Exemplo n.º 2
0
        public void SerializeOPF()
        {
            OPF opf = new OPF();

            opf.ID = "tst";
            DCMetadata dc = new DCMetadata();

            dc.Title       = "BM";
            dc.Creator     = "Marty";
            dc.DateTime    = DateTime.Now;
            dc.Description = "test";
            dc.Publisher   = "marty";
            dc.Subject     = "bm";

            XMetadata x       = new XMetadata();
            XOutput   xoutput = new XOutput();

            xoutput.ContentType = "application/x-mobipocket-subscription-magazine";
            xoutput.Encoding    = "utf-8";
            x.Output            = xoutput;

            OPFMetadata opfMetadata = new OPFMetadata();

            opfMetadata.DC = dc;
            opfMetadata.X  = x;
            opf.Metadata   = opfMetadata;

            OPFManifest manifest = new OPFManifest();

            manifest.Items = new List <OPFItem>();
            OPFItem item1 = new OPFItem();

            item1.Href      = "test";
            item1.Id        = "fsakl";
            item1.MediaType = "application/xhtml+xml";
            manifest.Items.Add(item1);
            manifest.Items.Add(item1);

            opf.Items = manifest.Items;

            OPFReference opfref = new OPFReference();

            opfref.Href    = "test";
            opfref.RefType = "type";
            opfref.Title   = "table of contents";

            List <OPFReference> guide = new List <OPFReference>();

            guide.Add(opfref);
            guide.Add(opfref);

            //opf.RefItems = guide;

            OPFSpine spine = new OPFSpine();

            spine.Items = new List <OPFItemRef>();
            OPFItemRef itemRef = new OPFItemRef();

            itemRef.IdRef = "tstes";
            spine.Items.Add(itemRef);
            spine.Items.Add(itemRef);

            //spine.Add(itemRef);
            //spine.Add(itemRef);
            spine.Toc = "test";

            opf.Spine = spine;

            using (FileStream fileStream = new FileStream("./KindleBook/bm.opf", FileMode.Create))
            {
                XmlSerializer           serializer = new XmlSerializer(typeof(OPF));
                XmlSerializerNamespaces ns         = new XmlSerializerNamespaces();
                ns.Add("dc", "http://dc.mock");
                serializer.Serialize(fileStream, opf, ns);
            }
        }