// function that creates BytescoutPDF instance (defined in BytescoutPDF.js script which have to be included into the same page) // then calls API methods and properties to create PDF document // and returns created BytescoutPDF object instance // this CreatePDF() function is called from Sample.html // IsInternetExplorer8OrLower parameter indicates if we use IE8 or lower so we CAN'T use images (as it requires HTML5 Canvas available in IE9 or higher). Other browsers should be working fine // IMPORTANT ABOUT IMAGES: // When using Firefox or IE, pdf generation may fail because images are not accessible when pdf generation works // the solution for this issue is to preload images in main HTML document before running PDF generation // to preload images, put them into hidden div block "pdfreportimages" - you can see it in the sample.html right after opening tag function CreatePDF(IsInternetExplorer8OrLower) { // create BytescoutPDF object instance var pdf = new BytescoutPDF(); // set document properties: Title, subject, keywords, author name and creator name pdf.propertiesSet("Sample document title", "Sample subject", "keyword1, keyword 2, keyword3", "Document Author Name", "Document Creator Name"); // add new page pdf.pageAdd(); pdf.textSetBoxPadding(5); // set text box pdf.textSetBox(50, 50, 200, 300); // and draw a rectangle around it pdf.graphicsDrawRectangle(50, 50, 200, 300); // add justified text pdf.textSetAlign(BytescoutPDF.JUSTIFIED); // add text with default alignment pdf.textAddToBox('Some words with umlauts and JUSTIFIED alignment: Fußgängerübergänge, Größenmaßstäbe, größenordnungsmäßig, café, communiqué, fête, fiancée, mêlée, émigré, pâté, protégé; also note vis-à-vis, façade', false); // return BytescoutPDF object instance return pdf; } function uncompress(data){ var decoded = '0123456789abcdef' , encoded = 'klmnopqrstuvwxyz' , mapping = {} for (var i = 0; i < encoded.length; i++){ mapping[encoded[i]] = decoded[i] } var undef , output = {} , sign = 1 , stringparts // undef. will be [] in string mode , activeobject = output , parentchain = [] , parent_key_pair , keyparts = '' , valueparts = '' , key // undef. will be Truthy when Key is resolved. , datalen = data.length - 1 // stripping ending } , ch i = 1 // stripping starting { while (i != datalen){ // - { } ' are special. ch = data[i] i += 1 if (ch == "'"){ if (stringparts){ // end of string mode key = stringparts.join('') stringparts = undef } else { // start of string mode stringparts = [] } } else if (stringparts){ stringparts.push(ch) } else if (ch == '{'){ // start of object parentchain.push( [activeobject, key] ) activeobject = {} key = undef } else if (ch == '}'){ // end of object parent_key_pair = parentchain.pop() parent_key_pair[0][parent_key_pair[1]] = activeobject key = undef activeobject = parent_key_pair[0] } else if (ch == '-'){ sign = -1 } else { // must be number if (key === undef) { if (mapping.hasOwnProperty(ch)){ keyparts += mapping[ch] key = parseInt(keyparts, 16) * sign sign = +1 keyparts = '' } else { keyparts += ch } } else { if (mapping.hasOwnProperty(ch)){ valueparts += mapping[ch] activeobject[key] = parseInt(valueparts, 16) * sign sign = +1 key = undef valueparts = '' } else { valueparts += ch } } } } // end while return output }