Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Java
  4. Flatten or Merge PDF with PDFBox

Flatten or Merge PDF with PDFBox

Scheduled Pinned Locked Moved Java
helpcsharpc++htmlapache
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    GlobX
    wrote on last edited by
    #1

    Hi all, I'm having an issue with PDFBox (1.3.1) - I'm using a PDF with AcroForms to basically pull off a 'mail merge'. I am successfully populating the fields with data, but what I want to do now is 'render it down' or 'flatten' it. I don't want these fields to be editable in the final result. (not entirely sure I'm communicating my intention clearly here, let me know if clarification is needed) I've found this post that says to "remove all fields from [the] acroform". I've tried this in a number of ways:

    pdfAcroForm.getFields().clear();

    and...

    pdfAcroForm.setFields(new ArrayList());

    and...

    Iterator fields = pdfAcroForm.getFields().iterator();

    while (fields.hasNext())
    {
    PDField field = (PDField)fields.next();
    field.setAcroForm(null);
    }

    and variations thereof...

    while typing this I thought to try:

    pdfAcroForm.setFields(new COSArrayList());

    maybe that will fix it?

    Anyway, does anyone know how to do this? I have this niggling feeling that it's a language barrier (I'm a native C# speaker). I also have a niggling feeling that the aforementioned article is a big red herring that's taken me down the road to the dark side... Any help would be MUCH appreciated :)

    N 1 Reply Last reply
    0
    • G GlobX

      Hi all, I'm having an issue with PDFBox (1.3.1) - I'm using a PDF with AcroForms to basically pull off a 'mail merge'. I am successfully populating the fields with data, but what I want to do now is 'render it down' or 'flatten' it. I don't want these fields to be editable in the final result. (not entirely sure I'm communicating my intention clearly here, let me know if clarification is needed) I've found this post that says to "remove all fields from [the] acroform". I've tried this in a number of ways:

      pdfAcroForm.getFields().clear();

      and...

      pdfAcroForm.setFields(new ArrayList());

      and...

      Iterator fields = pdfAcroForm.getFields().iterator();

      while (fields.hasNext())
      {
      PDField field = (PDField)fields.next();
      field.setAcroForm(null);
      }

      and variations thereof...

      while typing this I thought to try:

      pdfAcroForm.setFields(new COSArrayList());

      maybe that will fix it?

      Anyway, does anyone know how to do this? I have this niggling feeling that it's a language barrier (I'm a native C# speaker). I also have a niggling feeling that the aforementioned article is a big red herring that's taken me down the road to the dark side... Any help would be MUCH appreciated :)

      N Offline
      N Offline
      Nagy Vilmos
      wrote on last edited by
      #2

      [Caveat - I am not familiar with API you are using] You should not need to remove the form fields. The pdf document allows itself to be locked, once locked the fields become ineditable.


      Panic, Chaos, Destruction. My work here is done. or "Drink. Get drunk. Fall over." - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups