<?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>Question Re: setTemplate - how to access xdp file by code in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/settemplate-how-to-access-xdp-file-by-code/qaa-p/9163007#M3251677</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Omri,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've had this issue in the past and the only workaround I found was what you posted. If you do find a solution, please update this thread. Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 07 Nov 2012 13:38:08 GMT</pubDate>
    <dc:creator>Stefan-EA</dc:creator>
    <dc:date>2012-11-07T13:38:08Z</dc:date>
    <item>
      <title>setTemplate - how to access xdp file by code</title>
      <link>https://community.sap.com/t5/technology-q-a/settemplate-how-to-access-xdp-file-by-code/qaq-p/9163006</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm using ADS in my WDJ project.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I create new adobe form the xdp is created under src -&amp;gt; configuration -&amp;gt; Components -&amp;gt; &amp;lt;Component Name&amp;gt; -&amp;gt; xdp files.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In order to create PDF on the fly I need to use the 'setTemplate' method of the interface 'IWDPDFDocumentCreationContext'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Although the method has several signatures:&lt;/P&gt;&lt;P&gt;void setTemplate(byte[] template)&lt;/P&gt;&lt;P&gt;void setTemplate(OutputStream templateStream)&lt;/P&gt;&lt;P&gt;void setTemplate(String URL)&lt;/P&gt;&lt;P&gt;I still need to access the xdp source file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I couldn't find API to access xdp file under 'src -&amp;gt; configuration -&amp;gt; Components -&amp;gt; &amp;lt;Component Name&amp;gt;'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A possible workaround is to copy the xdp to the component's mimes folders and access it by&lt;/P&gt;&lt;P&gt;templateUrl = WDURLGenerator.getAbsoluteWebResourceURL(wdComponentAPI.getDeployableObjectPart(), "CopyOf.xdp");&lt;/P&gt;&lt;P&gt;I want to avoid this solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, how can I access the xdp files without copy it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Version is 7.00 SP22.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Omri&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Nov 2012 11:47:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/settemplate-how-to-access-xdp-file-by-code/qaq-p/9163006</guid>
      <dc:creator>former_member182374</dc:creator>
      <dc:date>2012-11-07T11:47:44Z</dc:date>
    </item>
    <item>
      <title>Re: setTemplate - how to access xdp file by code</title>
      <link>https://community.sap.com/t5/technology-q-a/settemplate-how-to-access-xdp-file-by-code/qaa-p/9163007#M3251677</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Omri,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've had this issue in the past and the only workaround I found was what you posted. If you do find a solution, please update this thread. Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Nov 2012 13:38:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/settemplate-how-to-access-xdp-file-by-code/qaa-p/9163007#M3251677</guid>
      <dc:creator>Stefan-EA</dc:creator>
      <dc:date>2012-11-07T13:38:08Z</dc:date>
    </item>
    <item>
      <title>Re: setTemplate - how to access xdp file by code</title>
      <link>https://community.sap.com/t5/technology-q-a/settemplate-how-to-access-xdp-file-by-code/qaa-p/9163008#M3251678</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Solved it on my own (or to be more precise by using to following code):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://gist.github.com/403956" title="https://gist.github.com/403956"&gt;https://gist.github.com/403956&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P class="line" id="LC2"&gt;&lt;SPAN class="k"&gt;try&lt;/SPAN&gt;&lt;SPAN class="o"&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="line" id="LC3"&gt;&lt;SPAN class="n"&gt;IWDPDFDocumentHandler&lt;/SPAN&gt; &lt;SPAN class="n"&gt;pdfDocumentHandler&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="n"&gt;WDPDFDocumentFactory&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="na"&gt;getDocumentHandler&lt;/SPAN&gt;&lt;SPAN class="o"&gt;();&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="line" id="LC4"&gt;&lt;SPAN class="n"&gt;IWDPDFDocumentCreationContext&lt;/SPAN&gt; &lt;SPAN class="n"&gt;pdfNewDocContext&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="n"&gt;pdfDocumentHandler&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="na"&gt;getDocumentCreationContext&lt;/SPAN&gt;&lt;SPAN class="o"&gt;();&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="line" id="LC5"&gt;&lt;/P&gt;&lt;P class="line" id="LC6"&gt;&lt;SPAN class="n"&gt;String&lt;/SPAN&gt; &lt;SPAN class="n"&gt;templateUrl&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="n"&gt;WDURLGenerator&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="na"&gt;getPublicResourcePath&lt;/SPAN&gt;&lt;SPAN class="o"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;wdComponentAPI&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="na"&gt;getDeployableObjectPart&lt;/SPAN&gt;&lt;SPAN class="o"&gt;(),&lt;/SPAN&gt; &lt;SPAN class="s"&gt;"IF.xdp"&lt;/SPAN&gt;&lt;SPAN class="o"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="line" id="LC7"&gt;&lt;SPAN class="n"&gt;InputStream&lt;/SPAN&gt; &lt;SPAN class="n"&gt;template&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="k"&gt;new&lt;/SPAN&gt; &lt;SPAN class="n"&gt;FileInputStream&lt;/SPAN&gt;&lt;SPAN class="o"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;templateUrl&lt;/SPAN&gt;&lt;SPAN class="o"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="line" id="LC8"&gt;&lt;SPAN class="kt"&gt;byte&lt;/SPAN&gt;&lt;SPAN class="o"&gt;[]&lt;/SPAN&gt; &lt;SPAN class="n"&gt;byteFileArray&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="k"&gt;new&lt;/SPAN&gt; &lt;SPAN class="kt"&gt;byte&lt;/SPAN&gt;&lt;SPAN class="o"&gt;[&lt;/SPAN&gt;&lt;SPAN class="n"&gt;template&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="na"&gt;available&lt;/SPAN&gt;&lt;SPAN class="o"&gt;()];&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="line" id="LC9"&gt;&lt;SPAN class="n"&gt;template&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="na"&gt;read&lt;/SPAN&gt;&lt;SPAN class="o"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;byteFileArray&lt;/SPAN&gt;&lt;SPAN class="o"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="line" id="LC10"&gt;&lt;/P&gt;&lt;P class="line" id="LC11"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="n"&gt;pdfNewDocContext&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="na"&gt;setTemplate&lt;/SPAN&gt;&lt;SPAN class="o"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;byteFileArray&lt;/SPAN&gt;&lt;SPAN class="o"&gt;);&lt;/SPAN&gt; &lt;/P&gt;&lt;P class="line" id="LC12"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="n"&gt;pdfNewDocContext&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="na"&gt;setData&lt;/SPAN&gt;&lt;SPAN class="o"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;WDInteractiveFormHelper&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="na"&gt;getContextDataAsStream&lt;/SPAN&gt;&lt;SPAN class="o"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;wdContext&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="na"&gt;nodeDataSource&lt;/SPAN&gt;&lt;SPAN class="o"&gt;()));&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="line" id="LC13"&gt;&lt;/P&gt;&lt;P class="line" id="LC14"&gt;&lt;SPAN class="n"&gt;IWDPDFDocument&lt;/SPAN&gt; &lt;SPAN class="n"&gt;document&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="n"&gt;pdfNewDocContext&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="na"&gt;execute&lt;/SPAN&gt;&lt;SPAN class="o"&gt;();&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="line" id="LC15"&gt;&lt;/P&gt;&lt;P class="line" id="LC16"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="n"&gt;IWDResource&lt;/SPAN&gt; &lt;SPAN class="n"&gt;resource&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;/P&gt;&lt;P class="line" id="LC17"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="n"&gt;WDResourceFactory&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="na"&gt;createCachedResource&lt;/SPAN&gt;&lt;SPAN class="o"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;document&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="na"&gt;getPDF&lt;/SPAN&gt;&lt;SPAN class="o"&gt;(),&lt;/SPAN&gt; &lt;SPAN class="s"&gt;"test.pdf"&lt;/SPAN&gt;&lt;SPAN class="o"&gt;,&lt;/SPAN&gt; &lt;SPAN class="n"&gt;WDWebResourceType&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="na"&gt;PDF&lt;/SPAN&gt;&lt;SPAN class="o"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="line" id="LC18"&gt;&lt;SPAN class="n"&gt;wdContext&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="na"&gt;currentContextElement&lt;/SPAN&gt;&lt;SPAN class="o"&gt;().&lt;/SPAN&gt;&lt;SPAN class="na"&gt;setPdfResource&lt;/SPAN&gt;&lt;SPAN class="o"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;resource&lt;/SPAN&gt;&lt;SPAN class="o"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="line" id="LC19"&gt;&lt;SPAN class="o"&gt;}&lt;/SPAN&gt; &lt;SPAN class="k"&gt;catch&lt;/SPAN&gt; &lt;SPAN class="o"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;Exception&lt;/SPAN&gt; &lt;SPAN class="n"&gt;e&lt;/SPAN&gt;&lt;SPAN class="o"&gt;)&lt;/SPAN&gt; &lt;SPAN class="o"&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="line" id="LC20"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="k"&gt;this&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="na"&gt;msgMgr&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="na"&gt;reportException&lt;/SPAN&gt;&lt;SPAN class="o"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;e&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="na"&gt;getMessage&lt;/SPAN&gt;&lt;SPAN class="o"&gt;());&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="line" id="LC21"&gt;&lt;SPAN class="o"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Nov 2012 14:42:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/settemplate-how-to-access-xdp-file-by-code/qaa-p/9163008#M3251678</guid>
      <dc:creator>former_member182374</dc:creator>
      <dc:date>2012-11-13T14:42:36Z</dc:date>
    </item>
  </channel>
</rss>

