2
votes

Updated : with the help of The Master solution .setDashStyle(SlidesApp.DashStyle.DOT);

Trying to insert dotted/dashed lines on the layout in Google Slide. But my solution gives me straight lines and the height of the lines are limited to the slide.

This method shows how to use the insert line. https://developers.google.com/apps-script/reference/slides/page#insertlinelinecategory,-startleft,-starttop,-endleft,-endtop

Enum LineCategory - No any dashed/dotted type of line : https://developers.google.com/apps-script/reference/slides/line-category

Above 2 articles not supporting the dotted/dashed line with full layout(outside the slide).

function dottedLines() {
         var slide = SlidesApp.getActivePresentation();
         var slideHt = slide.getPageHeight();
         var slideWd = slide.getPageWidth();
         var prevLeft = 0;
         var prevTop = 0;
        
         for (var i = 0; i < 3; i++) {
             //Vertical lines
             prevLeft = prevLeft + (slideWd / 3); 
             var startPoint = {
                 left: prevLeft,
                 top: 0
             };
             var endPoint = {
                 left: prevLeft,
                 top: slideHt
             };
             slide.getSlides()[0].insertLine(
                 SlidesApp.LineCategory.STRAIGHT,
                 startPoint.left,
                 startPoint.top,
                 endPoint.left,
                 endPoint.top
             ).setDashStyle(SlidesApp.DashStyle.DOT);
         }

------------more script --------
------------more script --------
------------more script --------
------------more script --------
     }

Please see attached image here for more requirement

1
Have you searched the documentation for dotted lines? See tag info page for more details. - TheMaster
Yes, I tried from the documentation. InsertLine method not allowing any other style except "SlidesApp.LineCategory.STRAIGHT" developers.google.com/apps-script/reference/slides/… - Roshan Jha
May I know the reason for your downvote? As a new contributor, I will learn and post the exact requirement. - Roshan Jha
Downvote is for not documenting your search and the problems you encumbered during your attempts. I removed it, but you still need to explain what you've tried in your question itself, so that we don't have to ask: "Have you tried this" for every possible solution only for you to reply "yes, but this happened..." - TheMaster

1 Answers

4
votes

LineCategory only refers to "curve" of the line- whether it is STRAIGHT or BENT.

To create dashed/dotted line, .setDashStyle() on the line created, which can be SOLID or DOT or DASH