PDF Certificates and Cyrillc unicode

valbudkin
Forums
Hello! I'm trying to use certificate with cyrillic symbols in it. Using dompdf as a method with quickest configuration. But after downloading certificate I get "????" symbols. You can see it at screenshot - https://www.evernote.com/shard/s2/sh/909d1421-265c-41c6-962b-b500472efc… I googled and found this issue – https://drupal.org/node/2085169 But Opigno uses PDF Version 7.x-1.3. Is it safe to update to 2.0? Is there another methods to solve the problem? Thanks!
Profile picture for user James Aparicio
James Aparicio

Hi valbudkin,

Hi valbudkin, Lets narrow it down, check if it is the certificate or the pdf. If you edit a content type that you have a node with content with these symbols. Structure-> Content Types -> a content type. Under Printer, email and PDF versions you set pdf version show link. Then go to the node and click on the pdf link. Does the pdf show strange symbols as well? Best regards
valbudkin

Yes, I've got the same

Yes, I've got the same problem in the PDF version.
Profile picture for user James Aparicio
James Aparicio

Hi valbudkin

Hi valbudkin Inside the file file print_pdf.pages.inc try adding the line $html = mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'); as shown below /////////// Before ////////////////////////////// function print_pdf_generate_path($path, $query = NULL, $cid = NULL, $pdf_filename = NULL) { global $base_url; $print = print_controller($path, $query, $cid, PRINT_PDF_FORMAT); if ($print === FALSE) { return; } // Img elements must be set to absolute $pattern = '!<(img\s[^>]*?)>!is'; $print['content'] = preg_replace_callback($pattern, '_print_rewrite_urls', $print['content']); $print['logo'] = preg_replace_callback($pattern, '_print_rewrite_urls', $print['logo']); $print['footer_message'] = preg_replace_callback($pattern, '_print_rewrite_urls', $print['footer_message']); // Send to printer option causes problems with PDF $print['sendtoprinter'] = ''; $node = $print['node']; $html = theme('print', array('print' => $print, 'type' => PRINT_PDF_FORMAT, 'node' => $node)); // Convert the a href elements, to make sure no relative links remain $pattern = '!<(a\s[^>]*?)>!is'; $html = preg_replace_callback($pattern, '_print_rewrite_urls', $html); // And make anchor links relative again, to permit in-PDF navigation $html = preg_replace("!${base_url}/" . PRINTPDF_PATH . '/.*?#!', '#', $html); return print_pdf_generate_html($print, $html, $pdf_filename); } ///////////////////////////////////////////////////////////////////////////////////////////// //////After //////////////////////////////////////// function print_pdf_generate_path($path, $query = NULL, $cid = NULL, $pdf_filename = NULL) { global $base_url; $print = print_controller($path, $query, $cid, PRINT_PDF_FORMAT); if ($print === FALSE) { return; } // Img elements must be set to absolute $pattern = '!<(img\s[^>]*?)>!is'; $print['content'] = preg_replace_callback($pattern, '_print_rewrite_urls', $print['content']); $print['logo'] = preg_replace_callback($pattern, '_print_rewrite_urls', $print['logo']); $print['footer_message'] = preg_replace_callback($pattern, '_print_rewrite_urls', $print['footer_message']); // Send to printer option causes problems with PDF $print['sendtoprinter'] = ''; $node = $print['node']; $html = theme('print', array('print' => $print, 'type' => PRINT_PDF_FORMAT, 'node' => $node)); // Convert the a href elements, to make sure no relative links remain $pattern = '!<(a\s[^>]*?)>!is'; $html = preg_replace_callback($pattern, '_print_rewrite_urls', $html); // And make anchor links relative again, to permit in-PDF navigation $html = preg_replace("!${base_url}/" . PRINTPDF_PATH . '/.*?#!', '#', $html); $html = mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'); return print_pdf_generate_html($print, $html, $pdf_filename); } /////////////////////////////////////////////// Best regards James Aparicio
albertpinto43

Hi,

Hi, I am trying to display a Russian text string in pdf but when the pdf is rendered, the Russian text is displayed as unicode (eg. ƴ displays as ƴ and п as п etc..) I have created the font metrics and embedded the font in my code. When generating the pdf, I can see the fonts being loaded from my output logs but the fonts are not displaying correctly. I'm not sure if I have done something wrong or the TTF I am using is incorrect. When I apply the Cyrillic font family in my xsl file to an English text string, I get Russian characters out ok so this makes me believe that the font is properly embedded and working. I've tried various methods to get the FontBaseURL but had to eventually put it into my fontcfg.xml using the tag as doing it programatically (commented out below) did not work. As you can see from the fontcfg file, I am trying numerous TTF's to try and get this working. Any help would be greatly appreciated. I've posted some code below.... String fontConfig = path + "fonts/fontcfg.xml"; FopFactory fopFactory = FopFactory.newInstance(); //fopFactory.setFontBaseURL("file:///" + path + "fonts/"); fopFactory.setUserConfig(fontConfig); Pass your [a link](https://www.exams4sure.com/Courses/ACT-practice-exam-dumps.html"ACT Exam Questions") with help of Exams4sure. FOUserAgent foAgent = fopFactory.newFOUserAgent(); //Setup a buffer to obtain the content length ByteArrayOutputStream out = new ByteArrayOutputStream(); //Setup FOP Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF,foAgent , out); ...... fontcfg.xml