2

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

Naresh
  • 2,761
  • 10
  • 45
  • 78
Roshan Jha
  • 100
  • 2
  • 7
  • Have you searched the **documentation** for dotted lines? See [tag info page](https://stackoverflow.com/tags/google-apps-script/info) for more details. – TheMaster Aug 06 '20 at 11:24
  • Yes, I tried from the documentation. InsertLine method not allowing any other style except "SlidesApp.LineCategory.STRAIGHT" https://developers.google.com/apps-script/reference/slides/slide#insertLine(LineCategory,ConnectionSite,ConnectionSite) – Roshan Jha Aug 06 '20 at 11:26
  • May I know the reason for your downvote? As a new contributor, I will learn and post the exact requirement. – Roshan Jha Aug 06 '20 at 11:27
  • 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 Aug 06 '20 at 11:33
  • 1
    [.insertLine(lineCat,..).setDashedStyle](https://developers.google.com/apps-script/reference/slides/line#setDashStyle(DashStyle)) – TheMaster Aug 06 '20 at 12:15
  • @RoshanJha Please put down the solved part and write what you are looking for exactly, as i can see you are still waiting for lines on the layout. or i am wrong. – Naresh Aug 06 '20 at 13:35
  • As i have checked, the lines height are limited to slide area https://developers.google.com/apps-script/reference/slides/presentation#getpageheight "Gets the page height of the slides, layouts, and masters in the presentation in points. They all have the same page height." – Naresh Aug 06 '20 at 13:36

1 Answers1

4

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

TheMaster
  • 45,448
  • 6
  • 62
  • 85