<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Print Task not printing textsymbol in correct format in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-task-not-printing-textsymbol-in-correct/m-p/1101906#M74796</link>
    <description>&lt;P&gt;Hi &lt;SPAN&gt;SailiTang1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;It is the TextSymbol added on GarphicsLayer of the map&lt;/P&gt;&lt;P&gt;this.textGraphic = new Graphic({&lt;BR /&gt;id: "textGraphic",&lt;BR /&gt;geometry: geometry,&lt;BR /&gt;symbol: {&lt;BR /&gt;type: "text", // autocasts as new TextSymbol()&lt;BR /&gt;color: "black",&lt;BR /&gt;font: { // autocast as new Font()&lt;BR /&gt;size: 12,&lt;BR /&gt;family: "sans-serif"&lt;BR /&gt;},&lt;BR /&gt;text: "demo text"&lt;BR /&gt;}&lt;BR /&gt;});&lt;/P&gt;</description>
    <pubDate>Sat, 25 Sep 2021 10:31:21 GMT</pubDate>
    <dc:creator>YashvitNaik</dc:creator>
    <dc:date>2021-09-25T10:31:21Z</dc:date>
    <item>
      <title>Print Task not printing textsymbol in correct format</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-task-not-printing-textsymbol-in-correct/m-p/1101590#M74771</link>
      <description>&lt;P&gt;I'm using ArcGIS Javascript API 4.15 for a web application, I have a TextSymbol added on the map, when I try to print the map using PrintTask, it is not printing the text in the proper format.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="YashvitNaik_0-1632485743231.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/23783iBA7DF9ADF025B064/image-size/medium?v=v2&amp;amp;px=400" role="button" title="YashvitNaik_0-1632485743231.png" alt="YashvitNaik_0-1632485743231.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;the above image is of the map with textsymbol, and the print version is this.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="YashvitNaik_1-1632485832379.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/23784i6F049E9D0975E8DF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="YashvitNaik_1-1632485832379.png" alt="YashvitNaik_1-1632485832379.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;it prints all the text in a single line.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here's my code:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;var template = new this.esri.PrintTemplate()&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;template.exportOptions = {&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;width: screen.availWidth,&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;height: screen.availHeight,&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;dpi: 96 //dots per inch&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;};&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;template.format = "pdf"&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;template.layout ="A4Landscape"&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;var printParameters = new this.esri.PrintParameters();&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;printParameters.view = this.mapView;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;printParameters.template = template;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;var printTask = new this.esri.PrintTask({ url: this.printUrl });&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;printTask.execute(printParameters)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Sep 2021 12:27:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-task-not-printing-textsymbol-in-correct/m-p/1101590#M74771</guid>
      <dc:creator>YashvitNaik</dc:creator>
      <dc:date>2021-09-24T12:27:56Z</dc:date>
    </item>
    <item>
      <title>Re: Print Task not printing textsymbol in correct format</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-task-not-printing-textsymbol-in-correct/m-p/1101756#M74780</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;The Printing service doesn't work like screenshot. It needs to grab your data and create a PDF (or other formats) on the ArcGIS server and then returns to client side. Where is the text from? It is part of your map or from a layer service?&lt;/P&gt;</description>
      <pubDate>Fri, 24 Sep 2021 17:57:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-task-not-printing-textsymbol-in-correct/m-p/1101756#M74780</guid>
      <dc:creator>SailiTang1</dc:creator>
      <dc:date>2021-09-24T17:57:36Z</dc:date>
    </item>
    <item>
      <title>Re: Print Task not printing textsymbol in correct format</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-task-not-printing-textsymbol-in-correct/m-p/1101906#M74796</link>
      <description>&lt;P&gt;Hi &lt;SPAN&gt;SailiTang1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;It is the TextSymbol added on GarphicsLayer of the map&lt;/P&gt;&lt;P&gt;this.textGraphic = new Graphic({&lt;BR /&gt;id: "textGraphic",&lt;BR /&gt;geometry: geometry,&lt;BR /&gt;symbol: {&lt;BR /&gt;type: "text", // autocasts as new TextSymbol()&lt;BR /&gt;color: "black",&lt;BR /&gt;font: { // autocast as new Font()&lt;BR /&gt;size: 12,&lt;BR /&gt;family: "sans-serif"&lt;BR /&gt;},&lt;BR /&gt;text: "demo text"&lt;BR /&gt;}&lt;BR /&gt;});&lt;/P&gt;</description>
      <pubDate>Sat, 25 Sep 2021 10:31:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-task-not-printing-textsymbol-in-correct/m-p/1101906#M74796</guid>
      <dc:creator>YashvitNaik</dc:creator>
      <dc:date>2021-09-25T10:31:21Z</dc:date>
    </item>
    <item>
      <title>Re: Print Task not printing textsymbol in correct format</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-task-not-printing-textsymbol-in-correct/m-p/1102254#M74808</link>
      <description>&lt;P&gt;Thank you for reporting this issue&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/336136"&gt;@YashvitNaik&lt;/a&gt;. It looks like the &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol.html#lineWidth" target="_self"&gt;lineWidth&lt;/A&gt; property is not being properly honored. We are currently investigating, and I will respond this post when we have an update to share.&lt;/P&gt;&lt;P&gt;As a workaround, if you manually add newline escapes ("\n") to the text, it will print better. Example (ignore the missing symbols as the Esri Icon Font is not installed on the print service server):&lt;/P&gt;&lt;P&gt;&lt;A href="https://codepen.io/noash/pen/ExXGVKd?editors=1000" target="_blank"&gt;https://codepen.io/noash/pen/ExXGVKd?editors=1000&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Sep 2021 19:03:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-task-not-printing-textsymbol-in-correct/m-p/1102254#M74808</guid>
      <dc:creator>Noah-Sager</dc:creator>
      <dc:date>2021-09-27T19:03:26Z</dc:date>
    </item>
    <item>
      <title>Re: Print Task not printing textsymbol in correct format</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-task-not-printing-textsymbol-in-correct/m-p/1106843#M74943</link>
      <description>&lt;P&gt;Noah, thank you so much for looking into it. Will this bug be marked by the ESRI Development team as a fairly high priority? Soon I will be deploying an application I've migrated from 3.x to 4.x, and I discovered lineWidth is ignored at the last minute.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Taking your idea of adding line escapes, some of us need to do this dynamically. So I found a handy regular expression that works to wrap user input which is being entered through a textarea element. It looks like this patch will do the trick for now.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function addLineBreaks(textLabel) {

    //apply line breaks to wrap text with max width of 32 characters
    const wrappedText = textLabel.replace(
        /(?![^\n]{1,32}$)([^\n]{1,32})\s/g, '$1\n'
    );

    return wrappedText;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 20:09:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-task-not-printing-textsymbol-in-correct/m-p/1106843#M74943</guid>
      <dc:creator>Andy_Morgan</dc:creator>
      <dc:date>2021-10-12T20:09:05Z</dc:date>
    </item>
    <item>
      <title>Re: Print Task not printing textsymbol in correct format</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-task-not-printing-textsymbol-in-correct/m-p/1106851#M74944</link>
      <description>&lt;P&gt;Also, I noticed multi-line text needs a vertical alignment of "bottom" in order to have a predictable location in the output pdf.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;verticalAlignment: "bottom"&lt;/LI-CODE&gt;&lt;P&gt;Otherwise, the default "baseline" setting will throw all text upward (when rendering the pdf) rather than going downward as it increases in length.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 20:33:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-task-not-printing-textsymbol-in-correct/m-p/1106851#M74944</guid>
      <dc:creator>Andy_Morgan</dc:creator>
      <dc:date>2021-10-12T20:33:12Z</dc:date>
    </item>
    <item>
      <title>Re: Print Task not printing textsymbol in correct format</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-task-not-printing-textsymbol-in-correct/m-p/1107076#M74953</link>
      <description>&lt;P&gt;Thanks for posting your regex idea&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/366432"&gt;@Andy_Morgan&lt;/a&gt;, that's a really nice dynamic workaround. One word of caution though, and this gets to the heart of why this issue is tricky to fix, if you only count the number of characters, you won't get a consistent newline experience. This is because the characters can vary in width depending on the font family, the font size, the font weight, and what characters make-up the label (e.g. W is wider than I).&lt;BR /&gt;&lt;BR /&gt;For the multi-text vertical alignment, I'm not sure I follow. Do you have a simplified test-app that I can see the issue with?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Oct 2021 14:17:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-task-not-printing-textsymbol-in-correct/m-p/1107076#M74953</guid>
      <dc:creator>Noah-Sager</dc:creator>
      <dc:date>2021-10-13T14:17:20Z</dc:date>
    </item>
    <item>
      <title>Re: Print Task not printing textsymbol in correct format</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-task-not-printing-textsymbol-in-correct/m-p/1107113#M74955</link>
      <description>&lt;P&gt;Hi Noah,&lt;/P&gt;&lt;P&gt;True, I don't think the solution is perfect for the reasons you've stated, but here's my final solution below. I had to add a second function on top of the initial wrapped text in order to break really long continuous strings that exceeded the preferred character max.&amp;nbsp; For example, if you included a long hyperlink like "&lt;A href="https://community.esri.com/t5/arcgis-api-for-javascript-questions/print-task-not-printing-textsymbol-in-correct/m-p/1102254" target="_blank"&gt;https://community.esri.com/t5/arcgis-api-for-javascript-questions/print-task-not-printing-textsymbol-in-correct/m-p/1102254&lt;/A&gt;"&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function addLineBreaks(textLabel) {
    //apply line breaks to wrap text with max width of 50 characters
    const wrappedText = textLabel.replace(
        /(?![^\n]{1,50}$)([^\n]{1,50})\s/g, '$1\n'
    );
    return wrappedText.replace(/(.{80})/g, "$1\n");
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My text symbol is defined as follows:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;       var textSymbolGeneric = {
            type: "text",  // autocasts as new TextSymbol()
            color: "white",
            haloColor: selectedColor,
            haloSize: "1px",
            text: "",
            xoffset: 0,
            yoffset: 0,
            font: {
                size: 12,
                family: "sans-serif",
                weight: "bold"
            },
            lineWidth: 300,
            horizontalAlignment: "left",
            verticalAlignment: "bottom"
        };&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is how it looks for verticalAlignment: "bottom"&lt;/P&gt;&lt;P&gt;Note the orange circle edit point which indicates the starting point for where I clicked to add the text.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vert_align_bottom.jpg" style="width: 525px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/25090iAA39A9D81EE13325/image-size/large?v=v2&amp;amp;px=999" role="button" title="vert_align_bottom.jpg" alt="vert_align_bottom.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is how it looks if I accept the default verticalAlignment value of "baseline"&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vert_align_baseline.jpg" style="width: 508px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/25091i42C3434F158B902F/image-size/large?v=v2&amp;amp;px=999" role="button" title="vert_align_baseline.jpg" alt="vert_align_baseline.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;While the baseline setting is preferred, since it goes downward based on where you clicked and started your text, the problem is when our users go to export the map to pdf. They expect whatever is showing on the map, with all their redline markups and text, will be sent to another person and appear the same way. I am forced to make text start from the "bottom" only because it's reliable in the output pdf.&lt;/P&gt;&lt;P&gt;The result of printing the last image above, with "baseline" as the vertical alignment, will be the following.&lt;/P&gt;&lt;P&gt;I realize it's difficult to compare to the one above without the line and point features, but you can see the text shifted to way above the thick white (highway) line.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vert_align_baseline_print_pdf_result.jpg" style="width: 758px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/25092i6AB2583178CB19A7/image-size/large?v=v2&amp;amp;px=999" role="button" title="vert_align_baseline_print_pdf_result.jpg" alt="vert_align_baseline_print_pdf_result.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Side note: all the layers you're seeing turned on in this output pdf are &lt;EM&gt;&lt;STRONG&gt;not&lt;/STRONG&gt; &lt;/EM&gt;visible (unchecked in the layer list). This is a JS 4.20 application, way too large to share all the code broken up into many files. This is either another bug or something going on with my code. Either way it's not obvious to me yet, because the Web Map JSON string does not include those layers you see shown (blue and red lines, the yellow points, etc.). I would think the print task is including too much, but again maybe an oversight by me somewhere.&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the sake of staying on topic with the original post I will not go further with this issue.&lt;/P&gt;&lt;P&gt;I'm unfortunately out of time to offer anything else for now. It may be days before I can return to this discussion.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Oct 2021 15:35:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-task-not-printing-textsymbol-in-correct/m-p/1107113#M74955</guid>
      <dc:creator>Andy_Morgan</dc:creator>
      <dc:date>2021-10-13T15:35:12Z</dc:date>
    </item>
  </channel>
</rss>

