<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.infopathdev.com:443/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>General</title><link>https://www.infopathdev.com:443/forums/41.aspx</link><description>If you're not sure where to ask your question, ask it here. If necessary, our moderators will make sure it gets classified in the correct board.</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Preview PDF in InfoPath Form?</title><link>https://www.infopathdev.com:443/forums/thread/58676.aspx</link><pubDate>Fri, 03 Sep 2010 21:17:46 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:58676</guid><dc:creator>davemor</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/58676.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=41&amp;PostID=58676</wfw:commentRss><description>&lt;p&gt;I have a secondary&amp;nbsp;Web Services data source in my form. One field contains PDF images. When I search for and return a record,&amp;nbsp;I wish to display (preview)&amp;nbsp;the PDF in the form. I tried adding the Adobe PDF Reader ActiveX but don&amp;#39;t know how to pass the PDF binary data from the web service&amp;nbsp;to it.&lt;/p&gt;
&lt;p&gt;I can get the record,&amp;nbsp;I can return all the other fields correctly. I can even write out the PDF binary to a file. What I can&amp;#39;t figure out is how to display the PDF as an image in the form. I want the users to be able to see the PDF image inline with the metadata for that PDF.&lt;/p&gt;
&lt;p&gt;Am I going down the wrong path? Is there an easier way?&lt;/p&gt;
&lt;p&gt;**********************************************************************************************************************************************************************&lt;/p&gt;
&lt;p&gt;Dim xpathFC As String = &amp;quot;/dfs:myFields/dfs:dataFields/tns:FetchManyResponse/docs/fileContent&amp;quot;&lt;br /&gt;Dim nav1 As XPathNavigator = Me.DataSources(&amp;quot;fetchMany&amp;quot;).CreateNavigator()&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39;Me.DataSources(&amp;quot;FetchManyResponse/docs/fileContent&amp;quot;).CreateNavigator()&lt;br /&gt;Dim FileContent1 As String = nav1.SelectSingleNode(xpathFC, NamespaceManager).Value&lt;/p&gt;
&lt;p&gt;Dim xpathPDF As String = &amp;quot;/my:myLocalFields/my:ImagePDF&amp;quot;&lt;br /&gt;Dim nav3 As XPathNavigator = Me.MainDataSource.CreateNavigator()&lt;br /&gt;Dim FileContent3 As String = nav3.SelectSingleNode(xpathPDF, NamespaceManager).Value&lt;/p&gt;
&lt;p&gt;&amp;#39; File Name&lt;br /&gt;Dim time As String = DateTime.Now.ToString(&amp;quot;ddMMyyyyhhmmss&amp;quot;)&lt;br /&gt;Dim fileName As String = &amp;quot;File&amp;quot; + time&lt;br /&gt;Dim data As Byte() = Convert.FromBase64String(FileContent1)&lt;br /&gt;&amp;#39; Write the file &lt;br /&gt;Dim outfile As System.IO.FileStream&lt;br /&gt;outfile = New System.IO.FileStream(&amp;quot;C:\temp\temp\&amp;quot; + fileName + &amp;quot;.pdf&amp;quot;, System.IO.FileMode.Create, System.IO.FileAccess.Write)&lt;br /&gt;outfile.Write(data, 0, data.Length - 1)&lt;br /&gt;outfile.Close()&lt;/p&gt;
&lt;p&gt;&amp;#39;Write to Form&lt;br /&gt;DeleteNil(nav3)&lt;br /&gt;&lt;strong&gt;&amp;#39;Cannot run - Gets &amp;quot;Value of type &amp;#39;1-dimensional array of Byte&amp;#39; cannot be converted to &amp;#39;String&amp;#39;. &amp;quot;&lt;/strong&gt;&lt;br /&gt;&amp;#39;nav3.SelectSingleNode(xpathPDF, NamespaceManager).SetValue(data) &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&amp;#39;Fails&amp;nbsp; - gets &amp;quot;Schema validation found non-data type errors.&amp;quot;&lt;/strong&gt;&lt;br /&gt;&amp;#39;nav3.SelectSingleNode(xpathPDF, NamespaceManager).SetValue(FileContent1) &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item></channel></rss>