private static void AddVideoToSlide(string presentationId, string slideId, string videotextTextBoxId) { SlidesService slidesService = GetSlideServiceClient(); var slide = GetSlides(presentationId).FirstOrDefault(s => s.ObjectId == slideId); // Create a new square text box, using a supplied object ID. List <Request> requests = new List <Request>(); Dimension pt350 = new Dimension() { Magnitude = 350.0, Unit = "PT" }; var afflineTransform = new AffineTransform() { ScaleX = (1.0), ScaleY = (1.0), TranslateX = (350.0), TranslateY = (100.0), Unit = ("PT") }; Size size = slide.PageElements.FirstOrDefault().Size; var pageElementProperties = new PageElementProperties() { PageObjectId = slideId, Size = size, Transform = afflineTransform }; // Insert text into the box, using the object ID given to it. requests.Add(new Request() { CreateVideo = new CreateVideoRequest() { ObjectId = videotextTextBoxId, Id = "z3iMVQlcuoE", Source = "YOUTUBE", ElementProperties = pageElementProperties } }); // Execute the requests. BatchUpdatePresentationRequest body = new BatchUpdatePresentationRequest() { Requests = requests }; BatchUpdatePresentationResponse response = slidesService.Presentations.BatchUpdate(body, presentationId).Execute(); CreateVideoResponse createShapeResponse = response.Replies.First().CreateVideo; Console.WriteLine("Created video with ID: " + createShapeResponse.ObjectId); }
private static void AddTextToSlide(string presentationId, string slideId, String textBoxId) { SlidesService slidesService = GetSlideServiceClient(); // Create a new square text box, using a supplied object ID. List <Request> requests = new List <Request>(); Dimension pt350 = new Dimension() { Magnitude = 350.0, Unit = "PT" }; var afflineTransform = new AffineTransform() { ScaleX = (1.0), ScaleY = (1.0), TranslateX = (350.0), TranslateY = (100.0), Unit = ("PT") }; Size size = new Size() { Height = (pt350), Width = (pt350) }; var pageElementProperties = new PageElementProperties() { PageObjectId = slideId, Size = size, Transform = afflineTransform }; requests.Add(new Request() { CreateShape = new CreateShapeRequest() { ObjectId = (textBoxId), ShapeType = ("TEXT_BOX"), ElementProperties = pageElementProperties } }); // Insert text into the box, using the object ID given to it. requests.Add(new Request() { InsertText = (new InsertTextRequest() { ObjectId = (textBoxId), InsertionIndex = (0), Text = ("New Box Text Inserted") }) }); // Execute the requests. BatchUpdatePresentationRequest body = new BatchUpdatePresentationRequest() { Requests = requests }; BatchUpdatePresentationResponse response = slidesService.Presentations.BatchUpdate(body, presentationId).Execute(); CreateShapeResponse createShapeResponse = response.Replies.First().CreateShape; Console.WriteLine("Created textbox with ID: " + createShapeResponse.ObjectId); }
private static void AddImageToSlide(string presentationId, string slideId, string textBoxId) { SlidesService slidesService = GetSlideServiceClient(); // Create a new square text box, using a supplied object ID. List <Request> requests = new List <Request>(); Dimension pt350 = new Dimension() { Magnitude = 350.0, Unit = "PT" }; var afflineTransform = new AffineTransform() { ScaleX = (1.0), ScaleY = (1.0), TranslateX = (350.0), TranslateY = (100.0), Unit = ("PT") }; Size size = new Size() { Height = (pt350), Width = (pt350) }; var pageElementProperties = new PageElementProperties() { PageObjectId = slideId, Size = size, Transform = afflineTransform }; //requests.Add(new Request() //{ // CreateShape = new CreateShapeRequest() // { // ObjectId = textBoxId, // ShapeType = "TEXT_BOX", // ElementProperties = pageElementProperties // } //}); // Insert text into the box, using the object ID given to it. requests.Add(new Request() { CreateImage = new CreateImageRequest() { ObjectId = textBoxId, Url = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ4gPTyRGSqYQoObgXWS9JRdsqBI7sQfJfgaAwQiZR43GxrR2hjWJE-Hg", ElementProperties = pageElementProperties } }); // Execute the requests. BatchUpdatePresentationRequest body = new BatchUpdatePresentationRequest() { Requests = requests }; BatchUpdatePresentationResponse response = slidesService.Presentations.BatchUpdate(body, presentationId).Execute(); CreateImageResponse createShapeResponse = response.Replies.First().CreateImage; Console.WriteLine("Created textbox with ID: " + createShapeResponse.ObjectId); }