Setting the autofit text property - google-apps-script

I want to set the textbox autofix as shrink to shape,
I dont understand how to set the autofit for existing as SHRINK text on overflow
I have tried with
Slides.Presentations.Pages[0].get(presentationId, pageObjectId).pageElements[3].shape.shapeProperties.autofit

You are trying to set the properties of a shape by using a GET request.
If you check the documentation page of the request:
GET https://slides.googleapis.com/v1/presentations/{presentationId}/pages/{pageObjectId}
Gets the latest version of the specified page in the presentation.
Moreover, the fields you are using are also wrong. Pages is part of the request and you cannot pass any parameters to it and pageObjectId is in fact the id of the page, not the id of the object you are trying to modify.
In order to set the update the shape properties of an object, you will have to make the following request:
POST https://slides.googleapis.com/v1/presentations/{presentationId}:batchUpdate
And use the following body:
{
"requests": [
{
"updateShapeProperties": {
"objectId": "OBJECT_ID",
"shapeProperties": {
"autofit": {
"autofitType": "AUTOFIT_TYPE"
}
},
"fields": "autofit.autofitType"
}
}
]
}
However, it is important to note the following as it might be the reason you are receiving the Autofit types other than NONE are not supported error:
The field is automatically set to NONE if a request is made that might affect text fitting within its bounding text box. In this case the fontScale is applied to the fontSize and the lineSpacingReduction is applied to the lineSpacing. Both properties are also reset to default values.
This concern has already been raised on Google's Issue Tracker here and you can see that this indeed the intended behavior in this situation. What you can do instead is to file a feature request by using the form here and provide all the necessary details.
Reference
Slides API presentations.batchUpdate;
Slides API updateShapePropertiesRequest;
Slides API presentations.pages.get.

Related

Forcing a Classified Document to Another Layout within Hyperscience

I want to force a document to classify against a particular layout on Hyperscience - is this possible? I can use the uuid, layout_uuid, layout_version_uuid, along with other metadata. I also want to include the pages belonging to the document if it has been classified already.
I’ve already set up the custom code block to perform this function as below:
def force_classification(submission: Any) -> Any:
***insert code here***
return submission
cct_force_classification = CodeBlock(
reference_name='force_classification',
code=force_classification,
code_input={'submission': previous_block.output('submission')},
title='Force Classification',
description='Force Classification',
)
Reading the SDK docs, I didn't see a clear way to do this. I'm wondering if this is just not possible?
Yes, this is possible! However, there are some limitations. You are able to use a custom code block to specify the layout that a document must be classified against if it has already been classified, as long as the layout that you’re forcing classification against is a semi-structured layout.
new_documents = []
for document in submission.get('documents', []):
if document['layout_uuid'] == 'layout_uuid[1]':
new_document = {
'uuid': document['id'],
'layout_version_uuid': 'layout_version_uuid[2]',
'layout_uuid': 'layout_uuid[1]',
'pages': [{
'submission_page_id': page['id'],
'page_number': page['submission_page_number'],
'classification_type': page['classification_type'],
} for page in document.get('pages', [])],
'metadata': {},
}
new_documents.append(new_document)
return {'submission': submission, 'new_documents': new_documents}
Note that, here, layout_uuid[1] refers to an existing document, and 2 corresponds to the metadata of the other layout you want to force classification against.
Keep in mind that this is still superficial (client side) and will not reflect in the Hyperscience db until you sync this new document back.

How to check the (initial) render state (not the update state) of a component in shadow DOM

Following the question I would like to ask about the appropriate way to check the initial render status of a component (not the update status) in shadow DOM. Is there any similar to document.readyState or a promise?
I have also tried to do:
getItems() {
this.updateComplete
.then(() => {
this.nodesLists = this.shadowRoot.querySelectorAll(".name");
})
.then(...)
}
which also failed.
Tia
await this.updateComplete (or this.updateComplete.then(...)) is the correct way to wait until the element has no pending render work before e.g. querying the state of the element's rendering, so your code should generally work as long as the element is connected to the document before running getItems.
Example: https://jsbin.com/jiquhez/edit?html,console,output
Note however, that if you await updateComplete before the element is connected and the element has no properties set that would trigger a render, then updateComplete currently resolves before the first render. This may be considered an unintended bug, filed at lit-element/#594.
Note you may also want to look into using the firstUpdated lifecycle method, depending on your use case. This is a method you can implement on your class to perform one-time work following the first update/render cycle for the element (useful for e.g. selecting static nodes that won't change based on rendering).
Example: https://jsbin.com/limikas/edit?html,console,output

Aspose.words mailmerge. Text in table cell gets truncated if it overflows page

I am executing mailmerge with regions. For that purpose I am using the following callback :
void IFieldMergingCallback.FieldMerging(FieldMergingArgs e)
{
//html content of the comment
if (e.FieldName == "Content")
{
DocumentBuilder builder = new DocumentBuilder(e.Document);
builder.MoveToMergeField(e.DocumentFieldName);
builder.InsertHtml((string)e.FieldValue);
}
}
The latter handles field, that assumes html content. However, if the content, overflows page length, it does not continue on another page, and simply gets truncated. How should I elaborate the callback to avoid that (or what settings I have to apply to document before executing mailmerge)? Is it somehow related to the fact, that I am using trial version of Aspose.Words ?
Check the properties of table row. If "Allow row to page break" is checked, your table should automatically move to the next page. I also tested using the similar method as yours, it worked.
I work with Aspose as Developer Evangelist.

viewWillLayoutSubviews is being called recursively

I have view controller presented as a form sheet, in which there will be a table view with custom cell having a label on left and a textfield on right.
The form sheet size (height) will be dynamically increased based on the selection done from the options that will be given in the tableview.
So, for initial configuration, i use this
- (void)viewWillLayoutSubviews
{
[super viewWillLayoutSubviews];
CGRect newBoundsForSuperView=CGRectMake(0, 0, max_view_width,max_view_height);
if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(#"8.00")==YES)
{
self.view.superview.bounds=newBoundsForSuperView;
self.view.superview.center=self.view.window.center;
}
}
When I tap on the textfield, the viewWillLayoutSubviews is getting called infinite times and the application is getting freezed.
Can anyone point out what and/or where the problem is exactly ?
BTW, the issue is only in iOS 8.
I believe your problem is related to setting self.view.superview.bounds which is causing the superview to call viewWillLayoutSubviews in a recursive manor.
Look into setting the preferredContentSize attribute of the view controller for iOS7+.

mootools slideshow2

i am using slideshow2 by Aeron Glemann in a website.Does in generate the thumbnails or do i have to provide them?the images iam showing are coming from a cloud, and are passed to the slideshow in an array.the thumbs exist in the cloud. how can i pass them in the array if the show cannot create them?
i have used the replace parameter with regex but it shows as thumbnails the full image and nothing happens when i alter the css properties for the thumbnails. the images are displayed.
here is the line for the show creation:
var myShow = new Slideshow('show', eval(res.value), { controller: true, height: 350,overlap: false, resize: false, hu: '',replace:[/^\S+.(gif|jpg|jpeg|png)$/,'t$1'],thumbnails: true, width: 600});
the value object contains the images from the cloud in format shown below:
['xx.jpg','yy.png',....]
thank you very much for your time.
I'd say your regular expression is broken. To add a 't' to the end of the filename? Try:
replace:[/^(\S+)\.(gif|jpg|jpeg|png)$/,'$1t.$2']
Best to play with the regular expression using an online tester to get it right.