Pdf to image conversion using PdfBox










0















When PDF(fillable) is converted to Jpeg using Pdfbox.The tick in checkbox is converted to a box character




WARN [org.apache.pdfbox.rendering.Type1Glyph2D] No glyph for code 52
(a20) in font ZapfDingbats




public static void main(String args) throws Exception



 try (final PDDocument document = PDDocument.load(new File("C:\Users\priyadarshini.s\Downloads\ADWE3244_Merge(1).pdf")))

ClassLoader classloader = Thread.currentThread().getContextClassLoader();
InputStream is = classloader.getResourceAsStream("zapfdingbats.ttf");

PDFRenderer pdfRenderer = new PDFRenderer(document);
PDFont font = PDType0Font.load(document,is); //PDTrueTypeFont.loadTTF(document, new File( "c:/arial.ttf" ));
//font.s sesetWidths(PDType1Font.HELVETICA.getWidths());


for (int page = 0; page < document.getNumberOfPages(); ++page)


BufferedImage bim = pdfRenderer.renderImageWithDPI(page, 300, ImageType.RGB);

String fileName = OUTPUT_DIR + "image-" + page + ".jpg";
ImageIOUtil.writeImage(bim, fileName, 300);



document.close();


catch (IOException e)
System.err.println("Exception while trying to create pdf document - " + e);




How do i set the font to the PDF to image code ?










share|improve this question




























    0















    When PDF(fillable) is converted to Jpeg using Pdfbox.The tick in checkbox is converted to a box character




    WARN [org.apache.pdfbox.rendering.Type1Glyph2D] No glyph for code 52
    (a20) in font ZapfDingbats




    public static void main(String args) throws Exception



     try (final PDDocument document = PDDocument.load(new File("C:\Users\priyadarshini.s\Downloads\ADWE3244_Merge(1).pdf")))

    ClassLoader classloader = Thread.currentThread().getContextClassLoader();
    InputStream is = classloader.getResourceAsStream("zapfdingbats.ttf");

    PDFRenderer pdfRenderer = new PDFRenderer(document);
    PDFont font = PDType0Font.load(document,is); //PDTrueTypeFont.loadTTF(document, new File( "c:/arial.ttf" ));
    //font.s sesetWidths(PDType1Font.HELVETICA.getWidths());


    for (int page = 0; page < document.getNumberOfPages(); ++page)


    BufferedImage bim = pdfRenderer.renderImageWithDPI(page, 300, ImageType.RGB);

    String fileName = OUTPUT_DIR + "image-" + page + ".jpg";
    ImageIOUtil.writeImage(bim, fileName, 300);



    document.close();


    catch (IOException e)
    System.err.println("Exception while trying to create pdf document - " + e);




    How do i set the font to the PDF to image code ?










    share|improve this question


























      0












      0








      0


      0






      When PDF(fillable) is converted to Jpeg using Pdfbox.The tick in checkbox is converted to a box character




      WARN [org.apache.pdfbox.rendering.Type1Glyph2D] No glyph for code 52
      (a20) in font ZapfDingbats




      public static void main(String args) throws Exception



       try (final PDDocument document = PDDocument.load(new File("C:\Users\priyadarshini.s\Downloads\ADWE3244_Merge(1).pdf")))

      ClassLoader classloader = Thread.currentThread().getContextClassLoader();
      InputStream is = classloader.getResourceAsStream("zapfdingbats.ttf");

      PDFRenderer pdfRenderer = new PDFRenderer(document);
      PDFont font = PDType0Font.load(document,is); //PDTrueTypeFont.loadTTF(document, new File( "c:/arial.ttf" ));
      //font.s sesetWidths(PDType1Font.HELVETICA.getWidths());


      for (int page = 0; page < document.getNumberOfPages(); ++page)


      BufferedImage bim = pdfRenderer.renderImageWithDPI(page, 300, ImageType.RGB);

      String fileName = OUTPUT_DIR + "image-" + page + ".jpg";
      ImageIOUtil.writeImage(bim, fileName, 300);



      document.close();


      catch (IOException e)
      System.err.println("Exception while trying to create pdf document - " + e);




      How do i set the font to the PDF to image code ?










      share|improve this question
















      When PDF(fillable) is converted to Jpeg using Pdfbox.The tick in checkbox is converted to a box character




      WARN [org.apache.pdfbox.rendering.Type1Glyph2D] No glyph for code 52
      (a20) in font ZapfDingbats




      public static void main(String args) throws Exception



       try (final PDDocument document = PDDocument.load(new File("C:\Users\priyadarshini.s\Downloads\ADWE3244_Merge(1).pdf")))

      ClassLoader classloader = Thread.currentThread().getContextClassLoader();
      InputStream is = classloader.getResourceAsStream("zapfdingbats.ttf");

      PDFRenderer pdfRenderer = new PDFRenderer(document);
      PDFont font = PDType0Font.load(document,is); //PDTrueTypeFont.loadTTF(document, new File( "c:/arial.ttf" ));
      //font.s sesetWidths(PDType1Font.HELVETICA.getWidths());


      for (int page = 0; page < document.getNumberOfPages(); ++page)


      BufferedImage bim = pdfRenderer.renderImageWithDPI(page, 300, ImageType.RGB);

      String fileName = OUTPUT_DIR + "image-" + page + ".jpg";
      ImageIOUtil.writeImage(bim, fileName, 300);



      document.close();


      catch (IOException e)
      System.err.println("Exception while trying to create pdf document - " + e);




      How do i set the font to the PDF to image code ?







      pdfbox pdf-conversion






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 14 '18 at 9:14







      PDS

















      asked Nov 14 '18 at 7:19









      PDSPDS

      239




      239






















          1 Answer
          1






          active

          oldest

          votes


















          1














          The problem may related with fonts. (Zapf Dingbats and/or MS Gothic may be missing)



          Can you try to install missing fonts in a directory "./fonts" or "/usr/share/fonts" for Linux,



          "/Windows/Fonts" for Windows






          share|improve this answer























          • WARN [org.apache.pdfbox.rendering.Type1Glyph2D] No glyph for code 52 (a20) in font ZapfDingbats 2018-11-13 20:01:01,280 WARN [org.apache.pdfbox.pdmodel.font.PDType1Font] Using fallback font LiberationSans for ZapfDingbats where do i install in aix server ?

            – PDS
            Nov 14 '18 at 8:13












          • How do i set the font to the PDF to image code ?

            – PDS
            Nov 14 '18 at 9:15











          • Link issues.apache.org/jira/browse/PDFBOX-1296, Link issues.apache.org/jira/browse/PDFBOX-490

            – yusuf hayırsever
            Nov 14 '18 at 9:22











          • You do not have to set the font in the code. You need to install it on your system. If you don't know how to install the font (most likely you just copy it there), ask your admin, or create a directory .fonts in your home directory and copy the font there.

            – Tilman Hausherr
            Nov 14 '18 at 9:37












          • But is there a way that we could do in code itself ?

            – PDS
            Nov 15 '18 at 5:29










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53294940%2fpdf-to-image-conversion-using-pdfbox%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          The problem may related with fonts. (Zapf Dingbats and/or MS Gothic may be missing)



          Can you try to install missing fonts in a directory "./fonts" or "/usr/share/fonts" for Linux,



          "/Windows/Fonts" for Windows






          share|improve this answer























          • WARN [org.apache.pdfbox.rendering.Type1Glyph2D] No glyph for code 52 (a20) in font ZapfDingbats 2018-11-13 20:01:01,280 WARN [org.apache.pdfbox.pdmodel.font.PDType1Font] Using fallback font LiberationSans for ZapfDingbats where do i install in aix server ?

            – PDS
            Nov 14 '18 at 8:13












          • How do i set the font to the PDF to image code ?

            – PDS
            Nov 14 '18 at 9:15











          • Link issues.apache.org/jira/browse/PDFBOX-1296, Link issues.apache.org/jira/browse/PDFBOX-490

            – yusuf hayırsever
            Nov 14 '18 at 9:22











          • You do not have to set the font in the code. You need to install it on your system. If you don't know how to install the font (most likely you just copy it there), ask your admin, or create a directory .fonts in your home directory and copy the font there.

            – Tilman Hausherr
            Nov 14 '18 at 9:37












          • But is there a way that we could do in code itself ?

            – PDS
            Nov 15 '18 at 5:29















          1














          The problem may related with fonts. (Zapf Dingbats and/or MS Gothic may be missing)



          Can you try to install missing fonts in a directory "./fonts" or "/usr/share/fonts" for Linux,



          "/Windows/Fonts" for Windows






          share|improve this answer























          • WARN [org.apache.pdfbox.rendering.Type1Glyph2D] No glyph for code 52 (a20) in font ZapfDingbats 2018-11-13 20:01:01,280 WARN [org.apache.pdfbox.pdmodel.font.PDType1Font] Using fallback font LiberationSans for ZapfDingbats where do i install in aix server ?

            – PDS
            Nov 14 '18 at 8:13












          • How do i set the font to the PDF to image code ?

            – PDS
            Nov 14 '18 at 9:15











          • Link issues.apache.org/jira/browse/PDFBOX-1296, Link issues.apache.org/jira/browse/PDFBOX-490

            – yusuf hayırsever
            Nov 14 '18 at 9:22











          • You do not have to set the font in the code. You need to install it on your system. If you don't know how to install the font (most likely you just copy it there), ask your admin, or create a directory .fonts in your home directory and copy the font there.

            – Tilman Hausherr
            Nov 14 '18 at 9:37












          • But is there a way that we could do in code itself ?

            – PDS
            Nov 15 '18 at 5:29













          1












          1








          1







          The problem may related with fonts. (Zapf Dingbats and/or MS Gothic may be missing)



          Can you try to install missing fonts in a directory "./fonts" or "/usr/share/fonts" for Linux,



          "/Windows/Fonts" for Windows






          share|improve this answer













          The problem may related with fonts. (Zapf Dingbats and/or MS Gothic may be missing)



          Can you try to install missing fonts in a directory "./fonts" or "/usr/share/fonts" for Linux,



          "/Windows/Fonts" for Windows







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 14 '18 at 7:26









          yusuf hayırseveryusuf hayırsever

          1877




          1877












          • WARN [org.apache.pdfbox.rendering.Type1Glyph2D] No glyph for code 52 (a20) in font ZapfDingbats 2018-11-13 20:01:01,280 WARN [org.apache.pdfbox.pdmodel.font.PDType1Font] Using fallback font LiberationSans for ZapfDingbats where do i install in aix server ?

            – PDS
            Nov 14 '18 at 8:13












          • How do i set the font to the PDF to image code ?

            – PDS
            Nov 14 '18 at 9:15











          • Link issues.apache.org/jira/browse/PDFBOX-1296, Link issues.apache.org/jira/browse/PDFBOX-490

            – yusuf hayırsever
            Nov 14 '18 at 9:22











          • You do not have to set the font in the code. You need to install it on your system. If you don't know how to install the font (most likely you just copy it there), ask your admin, or create a directory .fonts in your home directory and copy the font there.

            – Tilman Hausherr
            Nov 14 '18 at 9:37












          • But is there a way that we could do in code itself ?

            – PDS
            Nov 15 '18 at 5:29

















          • WARN [org.apache.pdfbox.rendering.Type1Glyph2D] No glyph for code 52 (a20) in font ZapfDingbats 2018-11-13 20:01:01,280 WARN [org.apache.pdfbox.pdmodel.font.PDType1Font] Using fallback font LiberationSans for ZapfDingbats where do i install in aix server ?

            – PDS
            Nov 14 '18 at 8:13












          • How do i set the font to the PDF to image code ?

            – PDS
            Nov 14 '18 at 9:15











          • Link issues.apache.org/jira/browse/PDFBOX-1296, Link issues.apache.org/jira/browse/PDFBOX-490

            – yusuf hayırsever
            Nov 14 '18 at 9:22











          • You do not have to set the font in the code. You need to install it on your system. If you don't know how to install the font (most likely you just copy it there), ask your admin, or create a directory .fonts in your home directory and copy the font there.

            – Tilman Hausherr
            Nov 14 '18 at 9:37












          • But is there a way that we could do in code itself ?

            – PDS
            Nov 15 '18 at 5:29
















          WARN [org.apache.pdfbox.rendering.Type1Glyph2D] No glyph for code 52 (a20) in font ZapfDingbats 2018-11-13 20:01:01,280 WARN [org.apache.pdfbox.pdmodel.font.PDType1Font] Using fallback font LiberationSans for ZapfDingbats where do i install in aix server ?

          – PDS
          Nov 14 '18 at 8:13






          WARN [org.apache.pdfbox.rendering.Type1Glyph2D] No glyph for code 52 (a20) in font ZapfDingbats 2018-11-13 20:01:01,280 WARN [org.apache.pdfbox.pdmodel.font.PDType1Font] Using fallback font LiberationSans for ZapfDingbats where do i install in aix server ?

          – PDS
          Nov 14 '18 at 8:13














          How do i set the font to the PDF to image code ?

          – PDS
          Nov 14 '18 at 9:15





          How do i set the font to the PDF to image code ?

          – PDS
          Nov 14 '18 at 9:15













          Link issues.apache.org/jira/browse/PDFBOX-1296, Link issues.apache.org/jira/browse/PDFBOX-490

          – yusuf hayırsever
          Nov 14 '18 at 9:22





          Link issues.apache.org/jira/browse/PDFBOX-1296, Link issues.apache.org/jira/browse/PDFBOX-490

          – yusuf hayırsever
          Nov 14 '18 at 9:22













          You do not have to set the font in the code. You need to install it on your system. If you don't know how to install the font (most likely you just copy it there), ask your admin, or create a directory .fonts in your home directory and copy the font there.

          – Tilman Hausherr
          Nov 14 '18 at 9:37






          You do not have to set the font in the code. You need to install it on your system. If you don't know how to install the font (most likely you just copy it there), ask your admin, or create a directory .fonts in your home directory and copy the font there.

          – Tilman Hausherr
          Nov 14 '18 at 9:37














          But is there a way that we could do in code itself ?

          – PDS
          Nov 15 '18 at 5:29





          But is there a way that we could do in code itself ?

          – PDS
          Nov 15 '18 at 5:29



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53294940%2fpdf-to-image-conversion-using-pdfbox%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          Barbados

          How to read a connectionString WITH PROVIDER in .NET Core?

          Node.js Script on GitHub Pages or Amazon S3