{"id":1397,"date":"2021-07-04T01:04:04","date_gmt":"2021-07-03T17:04:04","guid":{"rendered":"https:\/\/www.yohz.com\/blogs\/?p=1397"},"modified":"2021-07-13T15:24:36","modified_gmt":"2021-07-13T07:24:36","slug":"extracting-and-viewing-pdf-files-in-a-simpleindex-database","status":"publish","type":"post","link":"https:\/\/www.yohz.com\/blogs\/2021\/07\/04\/extracting-and-viewing-pdf-files-in-a-simpleindex-database\/","title":{"rendered":"Extracting and viewing PDF files in a SimpleIndex database"},"content":{"rendered":"<p><a href=\"https:\/\/www.simpleindex.com\/\">SimpleIndex<\/a> is an application that stores PDF files in SQL Server databases.\u00a0 The PDFs are stored in the <strong>General<\/strong> table, in the <strong>Image<\/strong> column.\u00a0 That column is of the SQL Server <strong>image<\/strong> type, generally used to store binary data (or blobs).<\/p>\n<p>We recently had a user that could not export the PDF files from his <a href=\"https:\/\/www.simpleindex.com\/\">SimpleIndex<\/a> database.\u00a0 \u00a0 The user was very helpful to send us the original PDF file, and the PDF file content as stored in his database for comparison.\u00a0 Turns out that <a href=\"https:\/\/www.simpleindex.com\/\">SimpleIndex<\/a> first converts the binary data in your PDF files to a unicode text string, then stores this unicode text.<\/p>\n<p>This is certainly a strange way to go about storing a file in a column that has a data type that&#8217;s perfectly suited to storing binary files.\u00a0 In addition to making it difficult to extract the PDF file, it doubles the storage requirements.\u00a0 Whatever the reason, <a href=\"https:\/\/www.yohz.com\/siv8_details.htm\">SQL Image Viewer<\/a> could not identify and display the PDF files.<\/p>\n<p>So the first thing we did was to convert the exported &#8216;mangled&#8217; PDF files back to their original state.\u00a0 We added this feature to our <a href=\"https:\/\/www.yohz.com\/blogs\/2021\/06\/11\/using-utf8tool\/\">UTF8Tool<\/a> application.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1398\" src=\"https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/07\/utf8_01.png\" alt=\"\" width=\"556\" height=\"369\" srcset=\"https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/07\/utf8_01.png 556w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/07\/utf8_01-300x199.png 300w\" sizes=\"(max-width: 556px) 100vw, 556px\" \/><\/p>\n<p>Now the user could export the content from his database, then use this tool to convert those files into proper PDF files.<\/p>\n<p>However, the user wanted to be able to query and view the PDF files from within <a href=\"https:\/\/www.yohz.com\/siv8_details.htm\">SQL Image Viewer<\/a>.\u00a0 We ended up with the easiest option &#8211; we created a second column to store the proper PDF content, then create an application to convert the mangled PDF files from the first column and store them in this new column.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1399\" src=\"https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/07\/utf8_02.png\" alt=\"\" width=\"509\" height=\"483\" srcset=\"https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/07\/utf8_02.png 509w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/07\/utf8_02-300x285.png 300w\" sizes=\"(max-width: 509px) 100vw, 509px\" \/><\/p>\n<p>It&#8217;s a very basic unpolished conversion application, and you can <a href=\"https:\/\/www.yohz.com\/downloads\/misc\/Unicode2Ansi.zip\">download<\/a> and use this application freely.<\/p>\n<p><strong>IMPORTANT NOTE:\u00a0<\/strong> This application updates a column in your database, so please make a backup of your database first, in case things don&#8217;t turn out exactly the way you want it.<\/p>\n<p>Currently, this application supports only SQL Server databases.\u00a0 If you need a version that supports another database engine, or if you require some modifications, drop us a line at <a href=\"mailto:support@yohz.com\">support@yohz.com<\/a>.<\/p>\n<p>Now that the user could display the PDF directly in <a href=\"https:\/\/www.yohz.com\/siv8_details.htm\">SQL Image Viewer<\/a>, we had another issue.\u00a0 By default, <a href=\"https:\/\/www.yohz.com\/siv8_details.htm\">SQL Image Viewer<\/a> only displays the first page of each PDF file that it detects e.g.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1400\" src=\"https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/07\/utf8_03.png\" alt=\"\" width=\"1035\" height=\"479\" srcset=\"https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/07\/utf8_03.png 1035w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/07\/utf8_03-300x139.png 300w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/07\/utf8_03-1024x474.png 1024w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/07\/utf8_03-768x355.png 768w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/07\/utf8_03-624x289.png 624w\" sizes=\"(max-width: 1035px) 100vw, 1035px\" \/><\/p>\n<p>This made it difficult to review each PDF file in details.\u00a0 Fortunately, <a href=\"https:\/\/www.yohz.com\/siv8_details.htm\">SQL Image Viewer<\/a> (professional edition) supports <a href=\"https:\/\/www.yohz.com\/blogs\/2018\/10\/13\/sql-image-viewer-9-and-custom-layouts\/\">custom layouts<\/a>.\u00a0 With <a href=\"https:\/\/www.yohz.com\/blogs\/2018\/10\/13\/sql-image-viewer-9-and-custom-layouts\/\">custom layouts<\/a>, you can choose to display a specific number of pages from your PDF files, and also the size of the pages e.g.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1401\" src=\"https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/07\/utf8_04.png\" alt=\"\" width=\"1130\" height=\"481\" srcset=\"https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/07\/utf8_04.png 1130w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/07\/utf8_04-300x128.png 300w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/07\/utf8_04-1024x436.png 1024w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/07\/utf8_04-768x327.png 768w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2021\/07\/utf8_04-624x266.png 624w\" sizes=\"(max-width: 1130px) 100vw, 1130px\" \/><\/p>\n<p>Now the user could easily preview more of his PDF files prior to exporting them.<\/p>\n<p>In summary:<\/p>\n<ul>\n<li>if you need to convert binary data from unicode files to ansi files, give our free <a href=\"https:\/\/www.yohz.com\/blogs\/2021\/06\/11\/using-utf8tool\/\">UTF8Tool<\/a> a try<\/li>\n<li>if you want to convert a column containing binary data in unicode text format to ansi text format and store the converted data in a separate column, give this free <a href=\"https:\/\/www.yohz.com\/downloads\/misc\/Unicode2Ansi.zip\">application<\/a> a try (but please back up your database first)<\/li>\n<li>if you want to preview multiple pages of a PDF file, use the <a href=\"https:\/\/www.yohz.com\/blogs\/2018\/10\/13\/sql-image-viewer-9-and-custom-layouts\/\">custom layouts<\/a> feature in SQL Image Viewer (professional edition)<\/li>\n<li>if you have data that SQL Image Viewer\/Access OLE Export\/SQL Blob Export does not recognize, send us an email at <a href=\"mailto:support@yohz.com\">support@yohz.com<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<div class=\"fcbkbttn_buttons_block\" id=\"fcbkbttn_left\"><div class=\"fcbkbttn_like \"><fb:like href=\"https:\/\/www.yohz.com\/blogs\/2021\/07\/04\/extracting-and-viewing-pdf-files-in-a-simpleindex-database\/\" action=\"like\" colorscheme=\"light\" layout=\"button\"  size=\"small\"><\/fb:like><\/div><div class=\"fb-share-button  \" data-href=\"https:\/\/www.yohz.com\/blogs\/2021\/07\/04\/extracting-and-viewing-pdf-files-in-a-simpleindex-database\/\" data-type=\"button\" data-size=\"small\"><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>SimpleIndex is an application that stores PDF files in SQL Server databases.\u00a0 The PDFs are stored in the General table, in the Image column.\u00a0 That column is of the SQL Server image type, generally used to store binary data (or blobs). We recently had a user that could not export the PDF files from his [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[17,44,5,11],"tags":[18,48,12],"_links":{"self":[{"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/posts\/1397"}],"collection":[{"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/comments?post=1397"}],"version-history":[{"count":1,"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/posts\/1397\/revisions"}],"predecessor-version":[{"id":1402,"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/posts\/1397\/revisions\/1402"}],"wp:attachment":[{"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/media?parent=1397"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/categories?post=1397"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/tags?post=1397"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}