Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-5696

COSStream lost, becomes a COSDictionary

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 3.0.0 PDFBox
    • 3.0.1 PDFBox, 4.0.0
    • None
    • None

    Description

      This is reduced from the example presented by Pados Attila on the mailing list

      public static void main(String[] args) throws IOException
      {
          InputStream resourceAsStream = NewClass.class.getResourceAsStream("/pdf/TemplateTank.pdf");
          try (PDDocument a1doc = Loader.loadPDF(new RandomAccessReadBuffer(resourceAsStream)))
          {
              PDAcroForm form = a1doc.getDocumentCatalog().getAcroForm();
              PDResources dr = form.getDefaultResources();
      
              form.getField("Site Name").setValue("Site Name");
              a1doc.save(new File("30-1.pdf"));
      
              PDFont font = PDType0Font.load(a1doc, PdfGenerator.class.getResourceAsStream("/fonts/CambriaMath.ttf"), false);
              dr.add(font);
              a1doc.save(new File("30-2.pdf"));
          }
      }
      

      The result file 30-1.pdf has "Site Name" in the rendering, the result file 30-2.pdf doesn't, because the appearance stream is now a dictionary.

      (The test was done on jdk21, I didn't test on another jdk)

      Attachments

        1. 30-1.pdf
          251 kB
          Tilman Hausherr
        2. 30-2.pdf
          1.02 MB
          Tilman Hausherr
        3. CambriaMath.ttf
          1.34 MB
          Tilman Hausherr
        4. TemplateTank.pdf
          252 kB
          Tilman Hausherr

        Issue Links

          Activity

            People

              lehmi Andreas Lehmkühler
              tilman Tilman Hausherr
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: