সম্পাদনা এবং স্টাইলিং পাঠ্য

এই পৃষ্ঠাটি আপনাকে স্লাইড এপিআই ব্যবহার করে আপনার উপস্থাপনায় পাঠ্য সম্পাদনা এবং স্টাইল করার উপায় বলে।

পাঠ্য সম্পর্কে

আপনার উপস্থাপনায় পাঠ্য সর্বদা একটি আকৃতি বা একটি টেবিল ঘরের মধ্যে থাকে৷ API আপনাকে এই পাঠ্যটি বিভিন্ন উপায়ে সংশোধন করতে দেয়:

  • আপনি আপনার উপস্থাপনায় পাঠ্য সন্নিবেশ করতে, মুছতে বা প্রতিস্থাপন করতে পারেন।
  • বুলেটেড তালিকা তৈরি করতে আপনি অনুচ্ছেদ বিন্যাস যোগ করতে পারেন।
  • আপনি অক্ষর বিন্যাস পরিবর্তন করতে পারেন যেমন বোল্ড, তির্যক, রঙ, ফন্টের আকার বা হাইপারলিঙ্ক।

স্লাইড এপিআই-এ টেক্সট স্টাইলিং কীভাবে কাজ করে তার একটি সাধারণ ওভারভিউয়ের জন্য ধারণার পৃষ্ঠা টেক্সট স্ট্রাকচার এবং স্টাইলিং দেখুন। এছাড়াও নীচের বিভাগগুলি থেকে বেশ কয়েকটি ফর্ম্যাটিং ধারণাগুলিকে একত্রিত করে একটি সম্পূর্ণ উদাহরণ (পাইথন) দেখতে উপরের ভিডিওটি দেখুন।

টেক্সট ঢোকানো, মুছে ফেলা বা প্রতিস্থাপন করা

স্লাইড এপিআই ব্যবহার করে আপনি একটি উপস্থাপনায় পাঠ্য প্রতিস্থাপন করতে পারেন এমন দুটি উপায় রয়েছে: একটি বিশ্বব্যাপী অনুসন্ধান-এবং-প্রতিস্থাপন করে, অথবা স্পষ্টভাবে মুছে ফেলা এবং পাঠ যোগ করে। উভয় উপায়ই ব্যাচআপডেট পদ্ধতি ব্যবহার করে, কিন্তু বিভিন্ন ধরনের অনুরোধের সাথে।

বিশ্বব্যাপী অনুসন্ধান এবং প্রতিস্থাপন

আপনার উপস্থাপনা জুড়ে একটি বিশ্বব্যাপী অনুসন্ধান-এবং-প্রতিস্থাপন করতে ReplaceAllTextRequest ব্যবহার করুন।

মার্জিং ডেটা গাইডের টেক্সট মার্জিং বিভাগটি আপনি কীভাবে এই অনুরোধের ধরণটি ব্যবহার করতে পারেন তার একটি উদাহরণ প্রদান করে।

একটি আকারের মধ্যে টেক্সট প্রতিস্থাপন

স্লাইড API আপনাকে একটি আকারের পাঠ্য বিষয়বস্তু পরিবর্তন করতে দেয়। আপনি পাঠ্যের পৃথক পরিসরগুলি সরাতে পারেন এবং আপনি একটি নির্দিষ্ট স্থানে পাঠ্য সন্নিবেশ করতে পারেন।

এই ক্রিয়াকলাপগুলি সম্পাদন করতে InsertTextRequest এবং DeleteTextRequest ব্যবহার করুন।

পাঠ্যের একটি নির্দিষ্ট অঞ্চল প্রতিস্থাপনের জন্য একটি মুছে ফেলা এবং তারপর একটি সন্নিবেশ করা হয়, যা আপনি নিম্নলিখিত পদক্ষেপগুলি ব্যবহার করে সম্পাদন করতে পারেন:

  1. পাঠ্য ধারণ করে পৃষ্ঠা উপাদান সনাক্ত করুন।
  2. প্রতিস্থাপন করা পাঠ্যের শুরু এবং শেষ অবস্থান চিহ্নিত করুন।
  3. নিম্নলিখিত দুটি অনুরোধ সহ batchUpdate কল করুন:
    1. DeleteTextRequest , মুছে ফেলার জন্য পাঠ্যের পরিসর নির্দিষ্ট করে।
    2. InsertTextRequest , একই স্টার্ট পজিশনের পাশাপাশি যে টেক্সট স্ট্রিংটি ঢোকানো হবে তা উল্লেখ করে।

আপনি এইভাবে পাঠ্য প্রতিস্থাপন করার সময় পারমাণবিকতা নিশ্চিত করতে, একই ব্যাচআপডেট কলে উভয় অনুরোধ অন্তর্ভুক্ত করতে ভুলবেন না। এটি নিম্নলিখিত উদাহরণে দেখানো হয়েছে, যা একটি আকারের সমস্ত পাঠ্যকে নতুন পাঠ্যের সাথে প্রতিস্থাপন করে:

অ্যাপস স্ক্রিপ্ট

slides/api/Snippets.gs
/**
 * Remove existing text in the shape, then insert new text.
 * @param {string} presentationId
 * @param {string?} shapeId
 * @param {string} replacementText
 * @returns {*}
 */
function simpleTextReplace(presentationId, shapeId, replacementText) {
  const requests = [{
    deleteText: {
      objectId: shapeId,
      textRange: {
        type: 'ALL'
      }
    }
  }, {
    insertText: {
      objectId: shapeId,
      insertionIndex: 0,
      text: replacementText
    }
  }];

  // Execute the requests.
  try {
    const batchUpdateResponse = Slides.Presentations.batchUpdate({
      requests: requests
    }, presentationId);
    console.log('Replaced text in shape with ID: %s', shapeId);

    return batchUpdateResponse;
  } catch (err) {
    // TODO (Developer) - Handle exception
    console.log('Failed with error: %s', err.error);
  }
};

যাওয়া

slides/snippets/presentations.go
// Remove existing text in the shape, then insert the new text.
requests := []*slides.Request{{
	DeleteText: &slides.DeleteTextRequest{
		ObjectId: shapeId,
		TextRange: &slides.Range{
			Type: "All",
		},
	},
}, {
	InsertText: &slides.InsertTextRequest{
		ObjectId:       shapeId,
		InsertionIndex: 0,
		Text:           replacementText,
	},
}}

// Execute the requests.
body := &slides.BatchUpdatePresentationRequest{Requests: requests}
response, _ := slidesService.Presentations.BatchUpdate(presentationId, body).Do()
fmt.Printf("Replaced text in shape with ID: %s", shapeId)

জাভা

slides/snippets/src/main/java/SimpleTextReplace.java
import com.google.api.client.googleapis.json.GoogleJsonError;
import com.google.api.client.googleapis.json.GoogleJsonResponseException;
import com.google.api.client.http.HttpRequestInitializer;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.gson.GsonFactory;
import com.google.api.services.slides.v1.Slides;
import com.google.api.services.slides.v1.SlidesScopes;
import com.google.api.services.slides.v1.model.BatchUpdatePresentationRequest;
import com.google.api.services.slides.v1.model.BatchUpdatePresentationResponse;
import com.google.api.services.slides.v1.model.DeleteTextRequest;
import com.google.api.services.slides.v1.model.InsertTextRequest;
import com.google.api.services.slides.v1.model.Range;
import com.google.api.services.slides.v1.model.Request;
import com.google.auth.http.HttpCredentialsAdapter;
import com.google.auth.oauth2.GoogleCredentials;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/* Class to demonstrate the use of Slides Replace Text API */
public class SimpleTextReplace {
  /**
   * Remove existing text in the shape, then insert new text.
   *
   * @param presentationId  - id of the presentation.
   * @param shapeId         - id of the shape.
   * @param replacementText - New replacement text.
   * @return response
   * @throws IOException - if credentials file not found.
   */
  public static BatchUpdatePresentationResponse simpleTextReplace(
      String presentationId, String shapeId, String replacementText) throws IOException {
        /* Load pre-authorized user credentials from the environment.
           TODO(developer) - See https://developers.google.com/identity for
            guides on implementing OAuth2 for your application. */
    GoogleCredentials credentials = GoogleCredentials.getApplicationDefault()
        .createScoped(Collections.singleton(SlidesScopes.PRESENTATIONS));
    HttpRequestInitializer requestInitializer = new HttpCredentialsAdapter(
        credentials);

    // Create the slides API client
    Slides service = new Slides.Builder(new NetHttpTransport(),
        GsonFactory.getDefaultInstance(),
        requestInitializer)
        .setApplicationName("Slides samples")
        .build();

    // Remove existing text in the shape, then insert the new text.
    List<Request> requests = new ArrayList<>();
    requests.add(new Request()
        .setDeleteText(new DeleteTextRequest()
            .setObjectId(shapeId)
            .setTextRange(new Range()
                .setType("ALL"))));
    requests.add(new Request()
        .setInsertText(new InsertTextRequest()
            .setObjectId(shapeId)
            .setInsertionIndex(0)
            .setText(replacementText)));

    BatchUpdatePresentationResponse response = null;
    try {
      // Execute the requests.
      BatchUpdatePresentationRequest body =
          new BatchUpdatePresentationRequest().setRequests(requests);
      response = service.presentations().batchUpdate(presentationId, body).execute();
      System.out.println("Replaced text in shape with ID: " + shapeId);
    } catch (GoogleJsonResponseException e) {
      // TODO(developer) - handle error appropriately
      GoogleJsonError error = e.getDetails();
      if (error.getCode() == 400) {
        System.out.printf("Shape not found with id '%s'.\n", shapeId);
      } else if (error.getCode() == 404) {
        System.out.printf("Presentation not found with id '%s'.\n", presentationId);
      } else {
        throw e;
      }
    }
    return response;
  }
}

জাভাস্ক্রিপ্ট

slides/snippets/slides_simple_text_replace.js
function simpleTextReplace(presentationId, shapeId, replacementText, callback) {
  // Remove existing text in the shape, then insert new text.
  const requests = [{
    deleteText: {
      objectId: shapeId,
      textRange: {
        type: 'ALL',
      },
    },
  }, {
    insertText: {
      objectId: shapeId,
      insertionIndex: 0,
      text: replacementText,
    },
  }];
  // Execute the requests.
  try {
    gapi.client.slides.presentations.batchUpdate({
      presentationId: presentationId,
      requests: requests,
    }).then((batchUpdateResponse) => {
      console.log(`Replaced text in shape with ID: ${shapeId}`);
      if (callback) callback(batchUpdateResponse.result);
    });
  } catch (err) {
    document.getElementById('content').innerText = err.message;
    return;
  }
}

Node.js

slides/snippets/slides_simple_text_replace.js
/**
 * Replaces text in the provided shape ID.
 * @param {string} presentationId The presentation ID.
 * @param {string} shapeId The shape ID to delete existing text and insert new text into.
 * @param {string} replacementText The new replacement text.
 */
async function simpleTextReplace(presentationId, shapeId, replacementText) {
  const {GoogleAuth} = require('google-auth-library');
  const {google} = require('googleapis');

  const auth = new GoogleAuth({
    scopes: 'https://www.googleapis.com/auth/presentations',
  });

  const service = google.slides({version: 'v1', auth});
  // Remove existing text in the shape, then insert new text.
  const requests = [
    {
      deleteText: {
        objectId: shapeId,
        textRange: {
          type: 'ALL',
        },
      },
    },
    {
      insertText: {
        objectId: shapeId,
        insertionIndex: 0,
        text: replacementText,
      },
    },
  ];
  // Execute the requests.
  try {
    const batchUpdateResponse = await service.presentations.batchUpdate({
      presentationId,
      resource: {
        requests,
      },
    });
    console.log(`Replaced text in shape with ID: ${shapeId}`);
    return batchUpdateResponse.data;
  } catch (err) {
    // TODO (developer) - Handle exception
    throw err;
  }
}

পিএইচপি

slides/snippets/src/SlidesSimpleTextReplace.php
use Google\Client;
use Google\Service\Drive;
use Google\Service\Slides;
use Google\Service\Slides\Request;

function simpleTextReplace($presentationId, $shapeId, $replacementText)
{
    /* Load pre-authorized user credentials from the environment.
       TODO(developer) - See https://developers.google.com/identity for
        guides on implementing OAuth2 for your application. */
    $client = new Google\Client();
    $client->useApplicationDefaultCredentials();
    $client->addScope(Google\Service\Drive::DRIVE);
    $slidesService = new Google_Service_Slides($client);
    // Remove existing text in the shape, then insert new text.
    $requests = array();
    $requests[] = new Google_Service_Slides_Request(array(
        'deleteText' => array(
            'objectId' => $shapeId,
            'textRange' => array(
                'type' => 'ALL'
            )
        )
    ));
    $requests[] = new Google_Service_Slides_Request(array(
        'insertText' => array(
            'objectId' => $shapeId,
            'insertionIndex' => 0,
            'text' => $replacementText
        )
    ));

    // Execute the requests.
    $batchUpdateRequest = new Google_Service_Slides_BatchUpdatePresentationRequest(array(
        'requests' => $requests
    ));
    $response = $slidesService->presentations->batchUpdate($presentationId, $batchUpdateRequest);
    printf("Replaced text in shape with ID: %s", $shapeId);
    return $response;
}

পাইথন

slides/snippets/slides_simple_text_replace.py
import google.auth
from googleapiclient.discovery import build
from googleapiclient.errors import HttpError


def simple_text_replace(presentation_id, shape_id, replacement_text):
  """
  Run simple_text_replace the user has access to.
  Load pre-authorized user credentials from the environment.
  TODO(developer) - See https://developers.google.com/identity
  for guides on implementing OAuth2 for the application.
  """
  creds, _ = google.auth.default()
  # pylint: disable=maybe-no-member
  try:
    slides_service = build("slides", "v1", credentials=creds)
    # Remove existing text in the shape, then insert new text.
    requests = []
    requests.append(
        {"deleteText": {"objectId": shape_id, "textRange": {"type": "ALL"}}}
    )
    requests.append(
        {
            "insertText": {
                "objectId": shape_id,
                "insertionIndex": 0,
                "text": replacement_text,
            }
        }
    )

    # Execute the requests.
    body = {"requests": requests}
    response = (
        slides_service.presentations()
        .batchUpdate(presentationId=presentation_id, body=body)
        .execute()
    )
    print(f"Replaced text in shape with ID: {shape_id}")
    return response
  except HttpError as error:
    print(f"An error occurred: {error}")
    print("Text is not merged")
    return error


if __name__ == "__main__":
  # Put the presentation_id, shape_id and replacement_text
  simple_text_replace(
      "10QnVUx1X2qHsL17WUidGpPh_SQhXYx40CgIxaKk8jU4",
      "MyTextBox_6",
      "GWSpace_now",
  )

রুবি

slides/snippets/lib/file_snippets.rb
# Remove existing text in the shape, then insert new text.
requests = [] << {
  delete_text: {
    object_id_prop: shape_id,
    text_range:     {
      type: 'ALL'
    }
  }
} << {
  insert_text: {
    object_id_prop:  shape_id,
    insertion_index: 0,
    text:            replacement_text
  }
}

# Execute the requests.
req = Google::Apis::SlidesV1::BatchUpdatePresentationRequest.new(requests: requests)
response = slides_service.batch_update_presentation(
  presentation_id,
  req
)
puts "Replaced text in shape with ID: #{shape_id}"

অক্ষর বিন্যাস পরিবর্তন

অক্ষর বিন্যাস টাইপফেস, রঙ এবং হাইপারলিঙ্কিং সহ আপনার উপস্থাপনায় পাঠ্য অক্ষরের রেন্ডারিং নির্ধারণ করে।

ধারণার পৃষ্ঠা টেক্সট স্ট্রাকচার এবং স্টাইলিং বর্ণনা করে যে কীভাবে স্লাইড এপিআই টেক্সট স্টাইলিং তথ্য উপস্থাপন করে।

পাঠ্যের অক্ষর বিন্যাস পরিবর্তন করতে, UpdateTextStyleRequest এর সাথে batchUpdate ব্যবহার করুন। আপনাকে আকৃতি বা টেবিল কক্ষের ID প্রদান করতে হবে যাতে পাঠ্য রয়েছে, সেইসাথে নিম্নলিখিত তথ্যগুলি অন্তর্ভুক্ত করে এমন একটি পরিসর প্রদান করতে হবে:

  • স্পেসিফায়ার FIXED_RANGE , শুরু এবং শেষ সূচী সহ যা আপনি যে পাঠ্য পরিসরটি স্টাইল করতে চান তা নির্ধারণ করে।
  • স্পেসিফায়ার FROM_START_INDEX , একটি স্টার্ট ইনডেক্স সহ যা আপনি যে টেক্সট ব্যাপ্তির স্টাইল করতে চান তার শুরুকে সংজ্ঞায়িত করে।
  • সমস্ত টেক্সটকে টার্গেট আকারে স্টাইল করার জন্য কোন সূচী ছাড়াই নির্দিষ্টকারী ALL

নিম্নলিখিত উদাহরণটি একটি আকারে থাকা পাঠ্যের উপর বেশ কয়েকটি পাঠ্য স্টাইলিং ক্রিয়াকলাপ সম্পাদন করে:

  • 0-4 অক্ষরের ফন্টকে বোল্ড ইটালিকসে সেট করে।
  • অক্ষরের রঙ 5-9 থেকে blue 14-pt Times New Roman ফন্ট সেট করে।
  • www.example.com এ 10-14 অক্ষর হাইপারলিঙ্ক করে।

এটি করার একটি সহজ উপায় হল অনুরোধগুলির একটি তালিকা তৈরি করা এবং তারপর একটি ব্যাচআপডেট কল ব্যবহার করা:

অ্যাপস স্ক্রিপ্ট

slides/api/Snippets.gs
/**
 * Update the text style so that the first 5 characters are bolded
 * and italicized, the next 5 are displayed in blue 14 pt Times
 * New Roman font, and the next 5 are hyperlinked.
 * @param {string} presentationId
 * @param {string} shapeId
 * @returns {*}
 */
function textStyleUpdate(presentationId, shapeId) {
  const requests = [{
    updateTextStyle: {
      objectId: shapeId,
      textRange: {
        type: 'FIXED_RANGE',
        startIndex: 0,
        endIndex: 5
      },
      style: {
        bold: true,
        italic: true
      },
      fields: 'bold,italic'
    }
  }, {
    updateTextStyle: {
      objectId: shapeId,
      textRange: {
        type: 'FIXED_RANGE',
        startIndex: 5,
        endIndex: 10
      },
      style: {
        fontFamily: 'Times New Roman',
        fontSize: {
          magnitude: 14,
          unit: 'PT'
        },
        foregroundColor: {
          opaqueColor: {
            rgbColor: {
              blue: 1.0,
              green: 0.0,
              red: 0.0
            }
          }
        }
      },
      fields: 'foregroundColor,fontFamily,fontSize'
    }
  }, {
    updateTextStyle: {
      objectId: shapeId,
      textRange: {
        type: 'FIXED_RANGE',
        startIndex: 10,
        endIndex: 15
      },
      style: {
        link: {
          url: 'www.example.com'
        }
      },
      fields: 'link'
    }
  }];

  // Execute the requests.
  try {
    const batchUpdateResponse = Slides.Presentations.batchUpdate({
      requests: requests
    }, presentationId);
    console.log('Updated the text style for shape with ID: %s', shapeId);

    return batchUpdateResponse;
  } catch (err) {
    // TODO (Developer) - Handle exception
    console.log('Failed with error: %s', err.error);
  }
};

যাওয়া

slides/snippets/presentations.go
// Update the text style so that the first 5 characters are bolded
// and italicized, and the next 5 are displayed in blue 14 pt Times
// New Roman font, and the next five are hyperlinked.
requests := []*slides.Request{{
	UpdateTextStyle: &slides.UpdateTextStyleRequest{
		ObjectId: shapeId,
		TextRange: &slides.Range{
			Type:            "FIXED_RANGE",
			StartIndex:      ptrInt64(0),
			EndIndex:        ptrInt64(5),
			ForceSendFields: []string{"StartIndex"},
		},
		Style: &slides.TextStyle{
			Bold:   true,
			Italic: true,
		},
		Fields: "bold,italic",
	},
}, {
	UpdateTextStyle: &slides.UpdateTextStyleRequest{
		ObjectId: shapeId,
		TextRange: &slides.Range{
			Type:       "FIXED_RANGE",
			StartIndex: ptrInt64(5),
			EndIndex:   ptrInt64(10),
		},
		Style: &slides.TextStyle{
			FontFamily: "Times New Roman",
			FontSize: &slides.Dimension{
				Magnitude: 14.0,
				Unit:      "PT",
			},
			ForegroundColor: &slides.OptionalColor{
				OpaqueColor: &slides.OpaqueColor{
					RgbColor: &slides.RgbColor{
						Blue:  1.0,
						Green: 0.0,
						Red:   0.0,
					},
				},
			},
		},
		Fields: "foregroundColor,fontFamily,fontSize",
	},
}, {
	UpdateTextStyle: &slides.UpdateTextStyleRequest{
		ObjectId: shapeId,
		TextRange: &slides.Range{
			Type:       "FIXED_RANGE",
			StartIndex: ptrInt64(10),
			EndIndex:   ptrInt64(15),
		},
		Style: &slides.TextStyle{
			Link: &slides.Link{
				Url: "www.example.com",
			},
		},
		Fields: "link",
	},
}}

// Execute the requests.
body := &slides.BatchUpdatePresentationRequest{Requests: requests}
response, _ := slidesService.Presentations.BatchUpdate(presentationId, body).Do()
fmt.Printf("Updated text style for shape with ID: %s", shapeId)

জাভা

slides/snippets/src/main/java/TextStyleUpdate.java
import com.google.api.client.googleapis.json.GoogleJsonError;
import com.google.api.client.googleapis.json.GoogleJsonResponseException;
import com.google.api.client.http.HttpRequestInitializer;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.gson.GsonFactory;
import com.google.api.services.slides.v1.Slides;
import com.google.api.services.slides.v1.SlidesScopes;
import com.google.api.services.slides.v1.model.BatchUpdatePresentationRequest;
import com.google.api.services.slides.v1.model.BatchUpdatePresentationResponse;
import com.google.api.services.slides.v1.model.Dimension;
import com.google.api.services.slides.v1.model.Link;
import com.google.api.services.slides.v1.model.OpaqueColor;
import com.google.api.services.slides.v1.model.OptionalColor;
import com.google.api.services.slides.v1.model.Range;
import com.google.api.services.slides.v1.model.Request;
import com.google.api.services.slides.v1.model.RgbColor;
import com.google.api.services.slides.v1.model.TextStyle;
import com.google.api.services.slides.v1.model.UpdateTextStyleRequest;
import com.google.auth.http.HttpCredentialsAdapter;
import com.google.auth.oauth2.GoogleCredentials;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/* Class to demonstrate the use of Slide Text Structure and Styling API */
public class TextStyleUpdate {
  /**
   * Styles text in the shape.
   *
   * @param presentationId - id of the presentation.
   * @param shapeId        - id of the shape.
   * @return shape id
   * @throws IOException - if credentials file not found.
   */
  public static BatchUpdatePresentationResponse textStyleUpdate(String presentationId,
                                                                String shapeId)
      throws IOException {
        /* Load pre-authorized user credentials from the environment.
           TODO(developer) - See https://developers.google.com/identity for
            guides on implementing OAuth2 for your application. */
    GoogleCredentials credentials = GoogleCredentials.getApplicationDefault()
        .createScoped(Collections.singleton(SlidesScopes.PRESENTATIONS));
    HttpRequestInitializer requestInitializer = new HttpCredentialsAdapter(
        credentials);

    // Create the slides API client
    Slides service = new Slides.Builder(new NetHttpTransport(),
        GsonFactory.getDefaultInstance(),
        requestInitializer)
        .setApplicationName("Slides samples")
        .build();

    // Update the text style so that the first 5 characters are bolded
    // and italicized, and the next 5 are displayed in blue 14 pt Times
    // New Roman font, and the next five are hyperlinked.
    List<Request> requests = new ArrayList<>();
    requests.add(new Request()
        .setUpdateTextStyle(new UpdateTextStyleRequest()
            .setObjectId(shapeId)
            .setTextRange(new Range()
                .setType("FIXED_RANGE")
                .setStartIndex(0)
                .setEndIndex(5))
            .setStyle(new TextStyle()
                .setBold(true)
                .setItalic(true))
            .setFields("bold,italic")));
    requests.add(new Request()
        .setUpdateTextStyle(new UpdateTextStyleRequest()
            .setObjectId(shapeId)
            .setTextRange(new Range()
                .setType("FIXED_RANGE")
                .setStartIndex(5)
                .setEndIndex(10))
            .setStyle(new TextStyle()
                .setFontFamily("Times New Roman")
                .setFontSize(new Dimension()
                    .setMagnitude(14.0)
                    .setUnit("PT"))
                .setForegroundColor(new OptionalColor()
                    .setOpaqueColor(new OpaqueColor()
                        .setRgbColor(new RgbColor()
                            .setBlue(1.0F)
                            .setGreen(0.0F)
                            .setRed(0.0F)))))
            .setFields("foregroundColor,fontFamily,fontSize")));
    requests.add(new Request()
        .setUpdateTextStyle(new UpdateTextStyleRequest()
            .setObjectId(shapeId)
            .setTextRange(new Range()
                .setType("FIXED_RANGE")
                .setStartIndex(10)
                .setEndIndex(15))
            .setStyle(new TextStyle()
                .setLink(new Link()
                    .setUrl("www.example.com")))
            .setFields("link")));

    BatchUpdatePresentationResponse response = null;
    try {
      // Execute the requests.
      BatchUpdatePresentationRequest body =
          new BatchUpdatePresentationRequest().setRequests(requests);
      response = service.presentations().batchUpdate(presentationId, body).execute();
      System.out.println("Updated text style for shape with ID: " + shapeId);
    } catch (GoogleJsonResponseException e) {
      // TODO(developer) - handle error appropriately
      GoogleJsonError error = e.getDetails();
      if (error.getCode() == 400) {
        System.out.printf("Shape not found with id '%s'.\n", shapeId);
      } else if (error.getCode() == 404) {
        System.out.printf("Presentation not found with id '%s'.\n", presentationId);
      } else {
        throw e;
      }
    }
    return response;
  }
}

জাভাস্ক্রিপ্ট

slides/snippets/slides_text_style_update.js
function textStyleUpdate(presentationId, shapeId, callback) {
  // Update the text style so that the first 5 characters are bolded
  // and italicized, the next 5 are displayed in blue 14 pt Times
  // New Roman font, and the next 5 are hyperlinked.
  const requests = [{
    updateTextStyle: {
      objectId: shapeId,
      textRange: {
        type: 'FIXED_RANGE',
        startIndex: 0,
        endIndex: 5,
      },
      style: {
        bold: true,
        italic: true,
      },
      fields: 'bold,italic',
    },
  }, {
    updateTextStyle: {
      objectId: shapeId,
      textRange: {
        type: 'FIXED_RANGE',
        startIndex: 5,
        endIndex: 10,
      },
      style: {
        fontFamily: 'Times New Roman',
        fontSize: {
          magnitude: 14,
          unit: 'PT',
        },
        foregroundColor: {
          opaqueColor: {
            rgbColor: {
              blue: 1.0,
              green: 0.0,
              red: 0.0,
            },
          },
        },
      },
      fields: 'foregroundColor,fontFamily,fontSize',
    },
  }, {
    updateTextStyle: {
      objectId: shapeId,
      textRange: {
        type: 'FIXED_RANGE',
        startIndex: 10,
        endIndex: 15,
      },
      style: {
        link: {
          url: 'www.example.com',
        },
      },
      fields: 'link',
    },
  }];
  // Execute the requests.
  try {
    gapi.client.slides.presentations.batchUpdate({
      presentationId: presentationId,
      requests: requests,
    }).then((batchUpdateResponse) => {
      console.log(`Updated the text style for shape with ID: ${shapeId}`);
      if (callback) callback(batchUpdateResponse.result);
    });
  } catch (err) {
    document.getElementById('content').innerText = err.message;
    return;
  }
}

Node.js

slides/snippets/slides_text_style_update.js
/**
 * Updates text style for a specific presentation's shape ID.
 * @param {string} presentationId The presentation ID.
 * @param {string} shapeId The shape ID.
 */
async function textStyleUpdate(presentationId, shapeId) {
  // Update the text style so that the first 5 characters are bolded
  // and italicized, the next 5 are displayed in blue 14 pt Times
  // New Roman font, and the next 5 are hyperlinked.
  const {GoogleAuth} = require('google-auth-library');
  const {google} = require('googleapis');

  const auth = new GoogleAuth({
    scopes: 'https://www.googleapis.com/auth/presentations',
  });

  const service = google.slides({version: 'v1', auth});

  const requests = [
    {
      updateTextStyle: {
        objectId: shapeId,
        textRange: {
          type: 'FIXED_RANGE',
          startIndex: 0,
          endIndex: 5,
        },
        style: {
          bold: true,
          italic: true,
        },
        fields: 'bold,italic',
      },
    },
    {
      updateTextStyle: {
        objectId: shapeId,
        textRange: {
          type: 'FIXED_RANGE',
          startIndex: 5,
          endIndex: 10,
        },
        style: {
          fontFamily: 'Times New Roman',
          fontSize: {
            magnitude: 14,
            unit: 'PT',
          },
          foregroundColor: {
            opaqueColor: {
              rgbColor: {
                blue: 1.0,
                green: 0.0,
                red: 0.0,
              },
            },
          },
        },
        fields: 'foregroundColor,fontFamily,fontSize',
      },
    },
    {
      updateTextStyle: {
        objectId: shapeId,
        textRange: {
          type: 'FIXED_RANGE',
          startIndex: 10,
          endIndex: 15,
        },
        style: {
          link: {
            url: 'www.example.com',
          },
        },
        fields: 'link',
      },
    },
  ];

  // Execute the requests.
  try {
    const batchUpdateResponse = await service.presentations.batchUpdate({
      presentationId,
      resource: {
        requests,
      },
    });
    console.log(`Updated the text style for shape with ID: ${shapeId}`);
    return batchUpdateResponse.data;
  } catch (err) {
    // TODO (developer) - Handle exceptions
    throw err;
  }
}

পিএইচপি

slides/snippets/src/SlidesTextStyleUpdate.php
use Google\Client;
use Google\Service\Drive;
use Google\Service\Slides;
use Google\Service\Slides\Request;
use Google\Service\Slides\BatchUpdatePresentationRequest;


function textStyleUpdate($presentationId, $shapeId)
{
    /* Load pre-authorized user credentials from the environment.
       TODO(developer) - See https://developers.google.com/identity for
        guides on implementing OAuth2 for your application. */
    $client = new Google\Client();
    $client->useApplicationDefaultCredentials();
    $client->addScope(Google\Service\Drive::DRIVE);
    $slidesService = new Google_Service_Slides($client);
    $requests = array();
    $requests[] = new Google_Service_Slides_Request(array(
        'updateTextStyle' => array(
            'objectId' => $shapeId,
            'textRange' => array(
                'type' => 'FIXED_RANGE',
                'startIndex' => 0,
                'endIndex' => 5
            ),
            'style' => array(
                'bold' => true,
                'italic' => true
            ),
            'fields' => 'bold,italic'
        )
    ));
    $requests[] = new Google_Service_Slides_Request(array(
        'updateTextStyle' => array(
            'objectId' => $shapeId,
            'textRange' => array(
                'type' => 'FIXED_RANGE',
                'startIndex' => 5,
                'endIndex' => 10
            ),
            'style' => array(
                'fontFamily' => 'Times New Roman',
                'fontSize' => array(
                    'magnitude' => 14,
                    'unit' => 'PT'
                ),
                'foregroundColor' => array(
                    'opaqueColor' => array(
                        'rgbColor' => array(
                            'blue' => 1.0,
                            'green' => 0.0,
                            'red' => 0.0
                        )
                    )
                )
            ),
            'fields' => 'foregroundColor,fontFamily,fontSize'
        )
    ));
    $requests[] = new Google_Service_Slides_Request(array(
        'updateTextStyle' => array(
            'objectId' => $shapeId,
            'textRange' => array(
                'type' => 'FIXED_RANGE',
                'startIndex' => 10,
                'endIndex' => 15
            ),
            'style' => array(
                'link' => array(
                    'url' => 'www.example.com'
                )
            ),
            'fields' => 'link'
        )
    ));

    // Execute the requests.
    $batchUpdateRequest = new Google_Service_Slides_BatchUpdatePresentationRequest(array(
        'requests' => $requests
    ));
    $response = $slidesService->presentations->batchUpdate($presentationId, $batchUpdateRequest);
    printf("Updated the text style for shape with ID: %s", $shapeId);
    return $response;
}

পাইথন

slides/snippets/slides_text_style_update.py
import google.auth
from googleapiclient.discovery import build
from googleapiclient.errors import HttpError


def text_style_update(presentation_id, shape_id):
  """
  create_sheets_chart the user has access to.
  Load pre-authorized user credentials from the environment.
  TODO(developer) - See https://developers.google.com/identity
  for guides on implementing OAuth2 for the application.
  """
  creds, _ = google.auth.default()
  # pylint: disable=maybe-no-member
  try:
    service = build("slides", "v1", credentials=creds)
    # Update the text style so that the first 5 characters are bolded
    # and italicized, the next 5 are displayed in blue 14 pt Times
    # New Roman font, and the next 5 are hyperlinked.
    requests = [
        {
            "updateTextStyle": {
                "objectId": shape_id,
                "textRange": {
                    "type": "FIXED_RANGE",
                    "startIndex": 0,
                    "endIndex": 5,
                },
                "style": {"bold": True, "italic": True},
                "fields": "bold,italic",
            }
        },
        {
            "updateTextStyle": {
                "objectId": shape_id,
                "textRange": {
                    "type": "FIXED_RANGE",
                    "startIndex": 5,
                    "endIndex": 10,
                },
                "style": {
                    "fontFamily": "Times New Roman",
                    "fontSize": {"magnitude": 14, "unit": "PT"},
                    "foregroundColor": {
                        "opaqueColor": {
                            "rgbColor": {
                                "blue": 1.0,
                                "green": 0.0,
                                "red": 0.0,
                            }
                        }
                    },
                },
                "fields": "foregroundColor,fontFamily,fontSize",
            }
        },
        {
            "updateTextStyle": {
                "objectId": shape_id,
                "textRange": {
                    "type": "FIXED_RANGE",
                    "startIndex": 10,
                    "endIndex": 15,
                },
                "style": {"link": {"url": "www.example.com"}},
                "fields": "link",
            }
        },
    ]

    # Execute the requests.
    body = {"requests": requests}
    response = (
        service.presentations()
        .batchUpdate(presentationId=presentation_id, body=body)
        .execute()
    )
    print(f"Updated the text style for shape with ID:{shape_id}")

    return response
  except HttpError as error:
    print(f"An error occurred: {error}")
    return error


if __name__ == "__main__":
  # Put the presentation_id, shape_id of slides
  # to be submitted.
  text_style_update(
      "10QnVUx1X2qHsL17WUidGpPh_SQhXYx40CgIxaKk8jU4", "MyTextBox_9"
  )

রুবি

slides/snippets/lib/file_snippets.rb
# Update the text style so that the first 5 characters are bolded
# and italicized, the next 5 are displayed in blue 14 pt Times
# New Roman font, and the next 5 are hyperlinked.
requests = [] << {
  update_text_style: {
    object_id_prop: shape_id,
    text_range:     {
      type:        'FIXED_RANGE',
      start_index: 0,
      end_index:   5
    },
    style:          {
      bold:   true,
      italic: true
    },
    fields:         'bold,italic'
  }
} << {
  update_text_style: {
    object_id_prop: shape_id,
    text_range:     {
      type:        'FIXED_RANGE',
      start_index: 5,
      end_index:   10
    },
    style:          {
      font_family:      'Times New Roman',
      font_size:        {
        magnitude: 14,
        unit:      'PT'
      },
      foreground_color: {
        opaque_color: {
          rgb_color: {
            blue:  1.0,
            green: 0.0,
            red:   0.0
          }
        }
      }
    },
    fields:         'foreground_color,font_family,font_size'
  }
} << {
  update_text_style: {
    object_id_prop: shape_id,
    text_range:     {
      type:        'FIXED_RANGE',
      start_index: 10,
      end_index:   15
    },
    style:          {
      link: {
        url: 'www.example.com'
      }
    },
    fields:         'link'
  }
}

# Execute the requests.
req = Google::Apis::SlidesV1::BatchUpdatePresentationRequest.new(requests: requests)
response = slides_service.batch_update_presentation(presentation_id, req)
puts "Updated the text style for shape with ID: #{shape_id}"

অনুচ্ছেদ বিন্যাস পরিবর্তন

অনুচ্ছেদ বিন্যাস নির্ধারণ করে কিভাবে পাঠ্যের ব্লকগুলি আপনার উপস্থাপনায় রেন্ডার করা হয়, সারিবদ্ধকরণ, ইন্ডেন্টেশন এবং তালিকার অলঙ্করণ সহ।

ধারণার পাতা টেক্সট স্ট্রাকচার এবং স্টাইলিং বর্ণনা করে যে কিভাবে [[slides_api_short]] অনুচ্ছেদ স্টাইলিং তথ্য উপস্থাপন করে।

স্লাইড এপিআই অনুচ্ছেদ শৈলী আপডেট করা, সাধারণ অনুচ্ছেদগুলিকে বুলেটযুক্ত তালিকায় রূপান্তর করা এবং অনুচ্ছেদগুলি থেকে বুলেটগুলি সরানো সমর্থন করে৷

অনুচ্ছেদগুলিকে একটি তালিকায় রূপান্তর করা হচ্ছে

একটি সাধারণ অনুচ্ছেদ বিন্যাস অপারেশন একটি বুলেট তালিকায় অনুচ্ছেদ রূপান্তর করা হয়. নিম্নলিখিত উদাহরণটি একটি আকারের সমস্ত অনুচ্ছেদকে একটি বুলেটযুক্ত তালিকায় রূপান্তরিত করে এবং ব্যবহার করার জন্য একটি সুস্পষ্ট বুলেট গ্লিফ নির্দিষ্ট করে৷

অ্যাপস স্ক্রিপ্ট

slides/api/Snippets.gs
/**
 * Add arrow-diamond-disc bullets to all text in the shape.
 */
function createBulletedText(presentationId, shapeId) {
  const requests = [{
    createParagraphBullets: {
      objectId: shapeId,
      textRange: {
        type: 'ALL'
      },
      bulletPreset: 'BULLET_ARROW_DIAMOND_DISC'
    }
  }];

  // Execute the requests.
  try {
    const batchUpdateResponse = Slides.Presentations.batchUpdate({
      requests: requests
    }, presentationId);
    console.log('Added bullets to text in shape with ID: %s', shapeId);

    return batchUpdateResponse;
  } catch (err) {
    // TODO (Developer) - Handle exception
    console.log('Failed with error: %s', err.error);
  }
};

যাওয়া

slides/snippets/presentations.go
// Add arrow-diamond-disc bullets to all text in the shape.
requests := []*slides.Request{{
	CreateParagraphBullets: &slides.CreateParagraphBulletsRequest{
		ObjectId: shapeId,
		TextRange: &slides.Range{
			Type: "ALL",
		},
		BulletPreset: "BULLET_ARROW_DIAMOND_DISC",
	},
}}

// Execute the requests.
body := &slides.BatchUpdatePresentationRequest{Requests: requests}
response, _ := slidesService.Presentations.BatchUpdate(presentationId, body).Do()
fmt.Printf("Added a linked Sheets chart with ID %s", shapeId)

জাভা

slides/snippets/src/main/java/CreateBulletedText.java
import com.google.api.client.googleapis.json.GoogleJsonError;
import com.google.api.client.googleapis.json.GoogleJsonResponseException;
import com.google.api.client.http.HttpRequestInitializer;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.gson.GsonFactory;
import com.google.api.services.slides.v1.Slides;
import com.google.api.services.slides.v1.SlidesScopes;
import com.google.api.services.slides.v1.model.BatchUpdatePresentationRequest;
import com.google.api.services.slides.v1.model.BatchUpdatePresentationResponse;
import com.google.api.services.slides.v1.model.CreateParagraphBulletsRequest;
import com.google.api.services.slides.v1.model.Range;
import com.google.api.services.slides.v1.model.Request;
import com.google.auth.http.HttpCredentialsAdapter;
import com.google.auth.oauth2.GoogleCredentials;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/* Class to demonstrate the use of Slide Create Bulleted Text API */
public class CreateBulletedText {
  /**
   * Add arrow-diamond-disc bullets to all text in the shape.
   *
   * @param presentationId - id of the presentation.
   * @param shapeId        - id of the shape.
   * @return response
   * @throws IOException - if credentials file not found.
   */
  public static BatchUpdatePresentationResponse createBulletedText(String presentationId,
                                                                   String shapeId)
      throws IOException {
        /* Load pre-authorized user credentials from the environment.
           TODO(developer) - See https://developers.google.com/identity for
            guides on implementing OAuth2 for your application. */
    GoogleCredentials credentials = GoogleCredentials.getApplicationDefault()
        .createScoped(Collections.singleton(SlidesScopes.PRESENTATIONS));
    HttpRequestInitializer requestInitializer = new HttpCredentialsAdapter(
        credentials);

    // Create the slides API client
    Slides service = new Slides.Builder(new NetHttpTransport(),
        GsonFactory.getDefaultInstance(),
        requestInitializer)
        .setApplicationName("Slides samples")
        .build();

    // Add arrow-diamond-disc bullets to all text in the shape.
    List<Request> requests = new ArrayList<>();
    requests.add(new Request()
        .setCreateParagraphBullets(new CreateParagraphBulletsRequest()
            .setObjectId(shapeId)
            .setTextRange(new Range()
                .setType("ALL"))
            .setBulletPreset("BULLET_ARROW_DIAMOND_DISC")));

    BatchUpdatePresentationResponse response = null;
    try {
      // Execute the request.
      BatchUpdatePresentationRequest body =
          new BatchUpdatePresentationRequest().setRequests(requests);
      response = service.presentations().batchUpdate(presentationId, body).execute();
      System.out.println("Added bullets to text in shape with ID: " + shapeId);
    } catch (GoogleJsonResponseException e) {
      // TODO(developer) - handle error appropriately
      GoogleJsonError error = e.getDetails();
      if (error.getCode() == 400) {
        System.out.printf("Shape not found with id '%s'.\n", shapeId);
      } else if (error.getCode() == 404) {
        System.out.printf("Presentation not found with id '%s'.\n", presentationId);
      } else {
        throw e;
      }
    }
    return response;
  }
}

জাভাস্ক্রিপ্ট

slides/snippets/slides_create_bulleted_text.js
function createBulletedText(presentationId, shapeId, callback) {
  // Add arrow-diamond-disc bullets to all text in the shape.
  const requests = [{
    createParagraphBullets: {
      objectId: shapeId,
      textRange: {
        type: 'ALL',
      },
      bulletPreset: 'BULLET_ARROW_DIAMOND_DISC',
    },
  }];
  // Execute the requests.
  try {
    gapi.client.slides.presentations.batchUpdate({
      presentationId: presentationId,
      requests: requests,
    }).then((batchUpdateResponse) => {
      console.log(`Added bullets to text in shape with ID: ${shapeId}`);
      if (callback) callback(batchUpdateResponse.result);
    });
  } catch (err) {
    document.getElementById('content').innerText = err.message;
    return;
  }
}

Node.js

slides/snippets/slides_create_bulleted_text.js
/**
 * Creates bulleted text for a presentation.
 * @param {string} presentationId The presentation ID.
 * @param {string} shapeId The shape ID to add bulleted text to.
 */
async function createBulletedText(presentationId, shapeId) {
  const {GoogleAuth} = require('google-auth-library');
  const {google} = require('googleapis');

  const auth = new GoogleAuth({
    scopes: 'https://www.googleapis.com/auth/presentations',
  });

  const service = google.slides({version: 'v1', auth});

  // Add arrow-diamond-disc bullets to all text in the shape.
  const requests = [
    {
      createParagraphBullets: {
        objectId: shapeId,
        textRange: {
          type: 'ALL',
        },
        bulletPreset: 'BULLET_ARROW_DIAMOND_DISC',
      },
    },
  ];

  // Execute the requests.
  try {
    const batchUpdateResponse = await service.presentations.batchUpdate({
      presentationId,
      resource: {
        requests,
      },
    });
    console.log(`Added bullets to text in shape with ID: ${shapeId}`);
    return batchUpdateResponse.data;
  } catch (err) {
    // TODO (developer) - Handle exception
    throw err;
  }
}

পিএইচপি

slides/snippets/src/SlidesCreateBulletedText.php
use Google\Client;
use Google\Service\Drive;
use Google\Service\Slides;
use Google\Service\Slides\Request;


function createBulletedText($presentationId, $shapeId)
{
    /* Load pre-authorized user credentials from the environment.
       TODO(developer) - See https://developers.google.com/identity for
        guides on implementing OAuth2 for your application. */
    $client = new Google\Client();
    $client->useApplicationDefaultCredentials();
    $client->addScope(Google\Service\Drive::DRIVE);
    $slidesService = new Google_Service_Slides($client);
    // Add arrow-diamond-disc bullets to all text in the shape.
    $requests = array();
    $requests[] = new Google_Service_Slides_Request(array(
        'createParagraphBullets' => array(
            'objectId' => $shapeId,
            'textRange' => array(
                'type' => 'ALL'
            ),
            'bulletPreset' => 'BULLET_ARROW_DIAMOND_DISC'
        )
    ));

    // Execute the request.
    $batchUpdateRequest = new Google_Service_Slides_BatchUpdatePresentationRequest(array(
        'requests' => $requests
    ));
    $response = $slidesService->presentations->batchUpdate($presentationId, $batchUpdateRequest);
    printf("Added bullets to text in shape with ID: %s", $shapeId);
    return $response;
}

পাইথন

slides/snippets/slides_create_bulleted_text.py
import google.auth
from googleapiclient.discovery import build
from googleapiclient.errors import HttpError


def create_bulleted_text(presentation_id, shape_id):
  """
  Run create_bulleted_text the user has access to.
  Load pre-authorized user credentials from the environment.
  TODO(developer) - See https://developers.google.com/identity
  for guides on implementing OAuth2 for the application.
  """
  creds, _ = google.auth.default()
  # pylint: disable=maybe-no-member
  try:
    slides_service = build("slides", "v1", credentials=creds)
    # Add arrow-diamond-disc bullets to all text in the shape.
    requests = [
        {
            "createParagraphBullets": {
                "objectId": shape_id,
                "textRange": {"type": "ALL"},
                "bulletPreset": "BULLET_ARROW_DIAMOND_DISC",
            }
        }
    ]

    # Execute the requests.
    body = {"requests": requests}
    response = (
        slides_service.presentations()
        .batchUpdate(presentationId=presentation_id, body=body)
        .execute()
    )
    print(f"Added bullets to text in shape with ID: {shape_id}")

    return response
  except HttpError as error:
    print(f"An error occurred: {error}")
    return error


if __name__ == "__main__":
  # Put the presentation_id and shape_id
  # to be submitted.
  create_bulleted_text(
      "1VD1xmi1-9DonI4zmCKENTzlVxIL5SdGGTmbHmnBjQ1E", "MyTextBox_9"
  )

রুবি

slides/snippets/lib/file_snippets.rb
# Add arrow-diamond-disc bullets to all text in the shape.
requests = [] << {
  create_paragraph_bullets: {
    object_id_prop: shape_id,
    text_range:     {
      type: 'ALL'
    },
    bulletPreset:   'BULLET_ARROW_DIAMOND_DISC'
  }
}

# Execute the requests.
req = Google::Apis::SlidesV1::BatchUpdatePresentationRequest.new(requests: requests)
response = slides_service.batch_update_presentation(presentation_id, req)
puts "Added bullets to text in shape with ID: #{shape_id}"