Is it possible to edit a PDF file directly?












6















I have a PDF file that is produced as part of a help file compilation. There is always late breaking stuff which goes into a text file (e.g. "What's new in this version" type of stuff) and while Help and Manual allows you to include stuff from a text file it only works for the CHM output and not for the PDF.



I'm wondering if I can do it by generating a unique placeholder string instead and then using some tool (I may need to write one) to do a search and replace of that unique string with the contents of the late breaking info text file.



Is this feasible? Or will it break some sort of internal structure?










share|improve this question


















  • 1





    When you replace a text string by another one, you have to keep track of the changing text length. This influences at least two internal PDF key properties and structures: (1) the xref table which represents the internal ToC of the objects, noting down the byte-offset of object starting points; (2) the /Length key for the stream that includes the changed text. Otherwise the file will be regarded as corrupt. Also, to edit text, the full (not subsetted) font must be embedded into the PDF.

    – Kurt Pfeifle
    Jun 22 '11 at 6:05






  • 1





    Perhaps it's time to look at another product, like HelpNDoc or Precision Helper. There's also Delphi components for dealing with PDFs that might do what you need, like PowerPDF or one of the items from About.com's list

    – afrazier
    Jun 22 '11 at 12:20













  • LibreOffice Draw works quite well for most things nowadays.

    – Nemo
    Oct 12 '18 at 7:17











  • @nemo - please explain how LibreOffice Draw could be used to do this.

    – rossmcm
    Oct 13 '18 at 23:48











  • @rossmcm I have limited experience in using LibreOffice Draw. I only know that every time I open a PDF file in LibreOffice I manage to edit or remove the parts I need without effort.

    – Nemo
    Oct 14 '18 at 15:37
















6















I have a PDF file that is produced as part of a help file compilation. There is always late breaking stuff which goes into a text file (e.g. "What's new in this version" type of stuff) and while Help and Manual allows you to include stuff from a text file it only works for the CHM output and not for the PDF.



I'm wondering if I can do it by generating a unique placeholder string instead and then using some tool (I may need to write one) to do a search and replace of that unique string with the contents of the late breaking info text file.



Is this feasible? Or will it break some sort of internal structure?










share|improve this question


















  • 1





    When you replace a text string by another one, you have to keep track of the changing text length. This influences at least two internal PDF key properties and structures: (1) the xref table which represents the internal ToC of the objects, noting down the byte-offset of object starting points; (2) the /Length key for the stream that includes the changed text. Otherwise the file will be regarded as corrupt. Also, to edit text, the full (not subsetted) font must be embedded into the PDF.

    – Kurt Pfeifle
    Jun 22 '11 at 6:05






  • 1





    Perhaps it's time to look at another product, like HelpNDoc or Precision Helper. There's also Delphi components for dealing with PDFs that might do what you need, like PowerPDF or one of the items from About.com's list

    – afrazier
    Jun 22 '11 at 12:20













  • LibreOffice Draw works quite well for most things nowadays.

    – Nemo
    Oct 12 '18 at 7:17











  • @nemo - please explain how LibreOffice Draw could be used to do this.

    – rossmcm
    Oct 13 '18 at 23:48











  • @rossmcm I have limited experience in using LibreOffice Draw. I only know that every time I open a PDF file in LibreOffice I manage to edit or remove the parts I need without effort.

    – Nemo
    Oct 14 '18 at 15:37














6












6








6


2






I have a PDF file that is produced as part of a help file compilation. There is always late breaking stuff which goes into a text file (e.g. "What's new in this version" type of stuff) and while Help and Manual allows you to include stuff from a text file it only works for the CHM output and not for the PDF.



I'm wondering if I can do it by generating a unique placeholder string instead and then using some tool (I may need to write one) to do a search and replace of that unique string with the contents of the late breaking info text file.



Is this feasible? Or will it break some sort of internal structure?










share|improve this question














I have a PDF file that is produced as part of a help file compilation. There is always late breaking stuff which goes into a text file (e.g. "What's new in this version" type of stuff) and while Help and Manual allows you to include stuff from a text file it only works for the CHM output and not for the PDF.



I'm wondering if I can do it by generating a unique placeholder string instead and then using some tool (I may need to write one) to do a search and replace of that unique string with the contents of the late breaking info text file.



Is this feasible? Or will it break some sort of internal structure?







pdf editing find-and-replace






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jun 22 '11 at 0:00









rossmcmrossmcm

73931946




73931946








  • 1





    When you replace a text string by another one, you have to keep track of the changing text length. This influences at least two internal PDF key properties and structures: (1) the xref table which represents the internal ToC of the objects, noting down the byte-offset of object starting points; (2) the /Length key for the stream that includes the changed text. Otherwise the file will be regarded as corrupt. Also, to edit text, the full (not subsetted) font must be embedded into the PDF.

    – Kurt Pfeifle
    Jun 22 '11 at 6:05






  • 1





    Perhaps it's time to look at another product, like HelpNDoc or Precision Helper. There's also Delphi components for dealing with PDFs that might do what you need, like PowerPDF or one of the items from About.com's list

    – afrazier
    Jun 22 '11 at 12:20













  • LibreOffice Draw works quite well for most things nowadays.

    – Nemo
    Oct 12 '18 at 7:17











  • @nemo - please explain how LibreOffice Draw could be used to do this.

    – rossmcm
    Oct 13 '18 at 23:48











  • @rossmcm I have limited experience in using LibreOffice Draw. I only know that every time I open a PDF file in LibreOffice I manage to edit or remove the parts I need without effort.

    – Nemo
    Oct 14 '18 at 15:37














  • 1





    When you replace a text string by another one, you have to keep track of the changing text length. This influences at least two internal PDF key properties and structures: (1) the xref table which represents the internal ToC of the objects, noting down the byte-offset of object starting points; (2) the /Length key for the stream that includes the changed text. Otherwise the file will be regarded as corrupt. Also, to edit text, the full (not subsetted) font must be embedded into the PDF.

    – Kurt Pfeifle
    Jun 22 '11 at 6:05






  • 1





    Perhaps it's time to look at another product, like HelpNDoc or Precision Helper. There's also Delphi components for dealing with PDFs that might do what you need, like PowerPDF or one of the items from About.com's list

    – afrazier
    Jun 22 '11 at 12:20













  • LibreOffice Draw works quite well for most things nowadays.

    – Nemo
    Oct 12 '18 at 7:17











  • @nemo - please explain how LibreOffice Draw could be used to do this.

    – rossmcm
    Oct 13 '18 at 23:48











  • @rossmcm I have limited experience in using LibreOffice Draw. I only know that every time I open a PDF file in LibreOffice I manage to edit or remove the parts I need without effort.

    – Nemo
    Oct 14 '18 at 15:37








1




1





When you replace a text string by another one, you have to keep track of the changing text length. This influences at least two internal PDF key properties and structures: (1) the xref table which represents the internal ToC of the objects, noting down the byte-offset of object starting points; (2) the /Length key for the stream that includes the changed text. Otherwise the file will be regarded as corrupt. Also, to edit text, the full (not subsetted) font must be embedded into the PDF.

– Kurt Pfeifle
Jun 22 '11 at 6:05





When you replace a text string by another one, you have to keep track of the changing text length. This influences at least two internal PDF key properties and structures: (1) the xref table which represents the internal ToC of the objects, noting down the byte-offset of object starting points; (2) the /Length key for the stream that includes the changed text. Otherwise the file will be regarded as corrupt. Also, to edit text, the full (not subsetted) font must be embedded into the PDF.

– Kurt Pfeifle
Jun 22 '11 at 6:05




1




1





Perhaps it's time to look at another product, like HelpNDoc or Precision Helper. There's also Delphi components for dealing with PDFs that might do what you need, like PowerPDF or one of the items from About.com's list

– afrazier
Jun 22 '11 at 12:20







Perhaps it's time to look at another product, like HelpNDoc or Precision Helper. There's also Delphi components for dealing with PDFs that might do what you need, like PowerPDF or one of the items from About.com's list

– afrazier
Jun 22 '11 at 12:20















LibreOffice Draw works quite well for most things nowadays.

– Nemo
Oct 12 '18 at 7:17





LibreOffice Draw works quite well for most things nowadays.

– Nemo
Oct 12 '18 at 7:17













@nemo - please explain how LibreOffice Draw could be used to do this.

– rossmcm
Oct 13 '18 at 23:48





@nemo - please explain how LibreOffice Draw could be used to do this.

– rossmcm
Oct 13 '18 at 23:48













@rossmcm I have limited experience in using LibreOffice Draw. I only know that every time I open a PDF file in LibreOffice I manage to edit or remove the parts I need without effort.

– Nemo
Oct 14 '18 at 15:37





@rossmcm I have limited experience in using LibreOffice Draw. I only know that every time I open a PDF file in LibreOffice I manage to edit or remove the parts I need without effort.

– Nemo
Oct 14 '18 at 15:37










5 Answers
5






active

oldest

votes


















5














"It Depends."



You'll probably need a couple things: First of all, the text can't have been rasterized. If that's the case, then all bets are off. Second, the entire font must have been embedded. If the font was subsetted (which is most often the case) then you may not have the required glyphs. Finally, you'd probably want to limit the size of the textarea being modified to be as small as possible, just to prevent having to deal with large amounts of reflow. You'd want as much whitespace around the plcaeholder as possible.



Now, this probably won't be something that you'll be able to do with a simple text editor, but there might be some PDF maniulating tools that can do the substiution for you.






share|improve this answer
























  • Hmmmm.... Reflow is exactly what I don't want. There are 2 things I want to embed - one is the version (1.2.3.456) - that should be no big deal. The other is a text file - i.e. formatted with line breaks - I guess I would need to add some n's. Unfortunately poking around the PDF with a text editor I can't see any text blocks. I'm sure the file is not rasterized - I can select text with the mouse for example.

    – rossmcm
    Jun 22 '11 at 1:16











  • The content is almost certainly compressed, so you won't be able to find your text quite so readily.

    – afrazier
    Jun 22 '11 at 1:45













  • yes, I guess that's it. There are large lumps of binary in the file. I guess I'm stumped.

    – rossmcm
    Jun 22 '11 at 2:11



















4














You can use (Open Source) qpdf utility (available for Linux, Windows and MacOS X) to unpack the PDF into a more readable format. From there you can go and try some of the other advices from the other answers:



qpdf.exe ^
--qdf ^
input.pdf ^
output.pdf


The file oUtput.pdf will have uncompressed object streams, all objects re-numbered and re-sorted in an ascending order, and some helpful comments sprinkled into the file. The file can be edited in a text editor (if it doesn't mess with the remaining binary sections).






share|improve this answer































    3














    If you are willing to get your hands dirty; iText should work.



    There are examples which cover a wide range of topics and should get you pointed in the right direction.



    Note the example below; using the document.add method to add a Paragraph into an existing PDF document.



    protected void createPdf(String filename)
    throws IOException, DocumentException, SQLException {
    // Open the database connection
    DatabaseConnection connection = new HsqldbConnection("filmfestival");
    // step 1
    Document document = new Document();
    // step 2
    PdfWriter.getInstance(document, new FileOutputStream(filename));
    // step 3
    document.open();
    // step 4
    // Add text with a local destination
    Paragraph p = new Paragraph();
    Chunk top = new Chunk("Country List", FilmFonts.BOLD);
    top.setLocalDestination("top");
    p.add(top);
    document.add(p);
    // Add text with a link to an external URL
    Chunk imdb = new Chunk("Internet Movie Database", FilmFonts.ITALIC);
    imdb.setAction(new PdfAction(new URL("http://www.imdb.com/")));
    p = new Paragraph(
    "Click on a country, and you'll get a list of movies, containing links to the ");
    p.add(imdb);
    p.add(".");
    document.add(p);
    // Add text with a remote goto
    p = new Paragraph("This list can be found in a ");
    Chunk page1 = new Chunk("separate document");
    page1.setAction(new PdfAction("movie_links_1.pdf", 1));
    p.add(page1);
    p.add(".");
    document.add(p);
    document.add(Chunk.NEWLINE);
    // Get a list with countries from the database
    Statement stm = connection.createStatement();
    ResultSet rs = stm.executeQuery(
    "SELECT DISTINCT mc.country_id, c.country, count(*) AS c "
    + "FROM film_country c, film_movie_country mc WHERE c.id = mc.country_id "
    + "GROUP BY mc.country_id, country ORDER BY c DESC");
    // Loop over the countries
    while (rs.next()) {
    Paragraph country = new Paragraph(rs.getString("country"));
    country.add(": ");
    Chunk link = new Chunk(String.format("%d movies", rs.getInt("c")));
    link.setAction(
    PdfAction.gotoRemotePage("movie_links_1.pdf", rs.getString("country_id"), false, true));
    country.add(link);
    document.add(country);
    }
    document.add(Chunk.NEWLINE);
    // Add text with a local goto
    p = new Paragraph("Go to ");
    top = new Chunk("top");
    top.setAction(PdfAction.gotoLocalPage("top", false));
    p.add(top);
    p.add(".");
    document.add(p);
    // step 5
    document.close();
    // Close the database connection
    connection.close();
    }





    share|improve this answer



















    • 1





      I'm willing to get my hands dirty, but not quite that dirty... I'm using Delphi. It's a shame there is no port - it looks to be pretty comprehensive.

      – rossmcm
      Jun 22 '11 at 5:01













    • Get a freelancer. Works in Java, can call it as a process

      – tgkprog
      Jun 5 '17 at 8:05



















    2














    pdfedit might do the trick - to quote the blurb on their sourceforge site




    Free editor for PDF documents. Complete editing of PDF documents is possible with PDFedit. You can change raw pdf objects (for advanced users) or use many gui functions. Functionality can be easily extended using a scripting language (ECMAScript)




    As of June 2013, there are *nix and Windows versions.






    share|improve this answer


























    • Windows unfortunately

      – rossmcm
      Jun 22 '11 at 2:00











    • it allegedly works in cygwin or colinux/andlinux but i've never gotten it to work,

      – Journeyman Geek
      Jun 22 '11 at 2:34



















    0














    Foxit PDF Reader Enterprise Edition allows you to edit PDFs. There's also Master PDF, but the free version adds a watermark (which I'm sure you don't want).



    Alternately, you can keep your master copy as a Word (.docx) or OO Writer (.odt) document and use a printer emulator (such as CutePDF Writer) to "print" to PDF. Office 365 and OO Writer also offer "Export to PDF" functionality, which avoids the need for editing PDFs in the first place.






    share|improve this answer























      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "3"
      };
      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%2fsuperuser.com%2fquestions%2f300405%2fis-it-possible-to-edit-a-pdf-file-directly%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      5 Answers
      5






      active

      oldest

      votes








      5 Answers
      5






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      5














      "It Depends."



      You'll probably need a couple things: First of all, the text can't have been rasterized. If that's the case, then all bets are off. Second, the entire font must have been embedded. If the font was subsetted (which is most often the case) then you may not have the required glyphs. Finally, you'd probably want to limit the size of the textarea being modified to be as small as possible, just to prevent having to deal with large amounts of reflow. You'd want as much whitespace around the plcaeholder as possible.



      Now, this probably won't be something that you'll be able to do with a simple text editor, but there might be some PDF maniulating tools that can do the substiution for you.






      share|improve this answer
























      • Hmmmm.... Reflow is exactly what I don't want. There are 2 things I want to embed - one is the version (1.2.3.456) - that should be no big deal. The other is a text file - i.e. formatted with line breaks - I guess I would need to add some n's. Unfortunately poking around the PDF with a text editor I can't see any text blocks. I'm sure the file is not rasterized - I can select text with the mouse for example.

        – rossmcm
        Jun 22 '11 at 1:16











      • The content is almost certainly compressed, so you won't be able to find your text quite so readily.

        – afrazier
        Jun 22 '11 at 1:45













      • yes, I guess that's it. There are large lumps of binary in the file. I guess I'm stumped.

        – rossmcm
        Jun 22 '11 at 2:11
















      5














      "It Depends."



      You'll probably need a couple things: First of all, the text can't have been rasterized. If that's the case, then all bets are off. Second, the entire font must have been embedded. If the font was subsetted (which is most often the case) then you may not have the required glyphs. Finally, you'd probably want to limit the size of the textarea being modified to be as small as possible, just to prevent having to deal with large amounts of reflow. You'd want as much whitespace around the plcaeholder as possible.



      Now, this probably won't be something that you'll be able to do with a simple text editor, but there might be some PDF maniulating tools that can do the substiution for you.






      share|improve this answer
























      • Hmmmm.... Reflow is exactly what I don't want. There are 2 things I want to embed - one is the version (1.2.3.456) - that should be no big deal. The other is a text file - i.e. formatted with line breaks - I guess I would need to add some n's. Unfortunately poking around the PDF with a text editor I can't see any text blocks. I'm sure the file is not rasterized - I can select text with the mouse for example.

        – rossmcm
        Jun 22 '11 at 1:16











      • The content is almost certainly compressed, so you won't be able to find your text quite so readily.

        – afrazier
        Jun 22 '11 at 1:45













      • yes, I guess that's it. There are large lumps of binary in the file. I guess I'm stumped.

        – rossmcm
        Jun 22 '11 at 2:11














      5












      5








      5







      "It Depends."



      You'll probably need a couple things: First of all, the text can't have been rasterized. If that's the case, then all bets are off. Second, the entire font must have been embedded. If the font was subsetted (which is most often the case) then you may not have the required glyphs. Finally, you'd probably want to limit the size of the textarea being modified to be as small as possible, just to prevent having to deal with large amounts of reflow. You'd want as much whitespace around the plcaeholder as possible.



      Now, this probably won't be something that you'll be able to do with a simple text editor, but there might be some PDF maniulating tools that can do the substiution for you.






      share|improve this answer













      "It Depends."



      You'll probably need a couple things: First of all, the text can't have been rasterized. If that's the case, then all bets are off. Second, the entire font must have been embedded. If the font was subsetted (which is most often the case) then you may not have the required glyphs. Finally, you'd probably want to limit the size of the textarea being modified to be as small as possible, just to prevent having to deal with large amounts of reflow. You'd want as much whitespace around the plcaeholder as possible.



      Now, this probably won't be something that you'll be able to do with a simple text editor, but there might be some PDF maniulating tools that can do the substiution for you.







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Jun 22 '11 at 1:00









      afrazierafrazier

      20.6k24682




      20.6k24682













      • Hmmmm.... Reflow is exactly what I don't want. There are 2 things I want to embed - one is the version (1.2.3.456) - that should be no big deal. The other is a text file - i.e. formatted with line breaks - I guess I would need to add some n's. Unfortunately poking around the PDF with a text editor I can't see any text blocks. I'm sure the file is not rasterized - I can select text with the mouse for example.

        – rossmcm
        Jun 22 '11 at 1:16











      • The content is almost certainly compressed, so you won't be able to find your text quite so readily.

        – afrazier
        Jun 22 '11 at 1:45













      • yes, I guess that's it. There are large lumps of binary in the file. I guess I'm stumped.

        – rossmcm
        Jun 22 '11 at 2:11



















      • Hmmmm.... Reflow is exactly what I don't want. There are 2 things I want to embed - one is the version (1.2.3.456) - that should be no big deal. The other is a text file - i.e. formatted with line breaks - I guess I would need to add some n's. Unfortunately poking around the PDF with a text editor I can't see any text blocks. I'm sure the file is not rasterized - I can select text with the mouse for example.

        – rossmcm
        Jun 22 '11 at 1:16











      • The content is almost certainly compressed, so you won't be able to find your text quite so readily.

        – afrazier
        Jun 22 '11 at 1:45













      • yes, I guess that's it. There are large lumps of binary in the file. I guess I'm stumped.

        – rossmcm
        Jun 22 '11 at 2:11

















      Hmmmm.... Reflow is exactly what I don't want. There are 2 things I want to embed - one is the version (1.2.3.456) - that should be no big deal. The other is a text file - i.e. formatted with line breaks - I guess I would need to add some n's. Unfortunately poking around the PDF with a text editor I can't see any text blocks. I'm sure the file is not rasterized - I can select text with the mouse for example.

      – rossmcm
      Jun 22 '11 at 1:16





      Hmmmm.... Reflow is exactly what I don't want. There are 2 things I want to embed - one is the version (1.2.3.456) - that should be no big deal. The other is a text file - i.e. formatted with line breaks - I guess I would need to add some n's. Unfortunately poking around the PDF with a text editor I can't see any text blocks. I'm sure the file is not rasterized - I can select text with the mouse for example.

      – rossmcm
      Jun 22 '11 at 1:16













      The content is almost certainly compressed, so you won't be able to find your text quite so readily.

      – afrazier
      Jun 22 '11 at 1:45







      The content is almost certainly compressed, so you won't be able to find your text quite so readily.

      – afrazier
      Jun 22 '11 at 1:45















      yes, I guess that's it. There are large lumps of binary in the file. I guess I'm stumped.

      – rossmcm
      Jun 22 '11 at 2:11





      yes, I guess that's it. There are large lumps of binary in the file. I guess I'm stumped.

      – rossmcm
      Jun 22 '11 at 2:11













      4














      You can use (Open Source) qpdf utility (available for Linux, Windows and MacOS X) to unpack the PDF into a more readable format. From there you can go and try some of the other advices from the other answers:



      qpdf.exe ^
      --qdf ^
      input.pdf ^
      output.pdf


      The file oUtput.pdf will have uncompressed object streams, all objects re-numbered and re-sorted in an ascending order, and some helpful comments sprinkled into the file. The file can be edited in a text editor (if it doesn't mess with the remaining binary sections).






      share|improve this answer




























        4














        You can use (Open Source) qpdf utility (available for Linux, Windows and MacOS X) to unpack the PDF into a more readable format. From there you can go and try some of the other advices from the other answers:



        qpdf.exe ^
        --qdf ^
        input.pdf ^
        output.pdf


        The file oUtput.pdf will have uncompressed object streams, all objects re-numbered and re-sorted in an ascending order, and some helpful comments sprinkled into the file. The file can be edited in a text editor (if it doesn't mess with the remaining binary sections).






        share|improve this answer


























          4












          4








          4







          You can use (Open Source) qpdf utility (available for Linux, Windows and MacOS X) to unpack the PDF into a more readable format. From there you can go and try some of the other advices from the other answers:



          qpdf.exe ^
          --qdf ^
          input.pdf ^
          output.pdf


          The file oUtput.pdf will have uncompressed object streams, all objects re-numbered and re-sorted in an ascending order, and some helpful comments sprinkled into the file. The file can be edited in a text editor (if it doesn't mess with the remaining binary sections).






          share|improve this answer













          You can use (Open Source) qpdf utility (available for Linux, Windows and MacOS X) to unpack the PDF into a more readable format. From there you can go and try some of the other advices from the other answers:



          qpdf.exe ^
          --qdf ^
          input.pdf ^
          output.pdf


          The file oUtput.pdf will have uncompressed object streams, all objects re-numbered and re-sorted in an ascending order, and some helpful comments sprinkled into the file. The file can be edited in a text editor (if it doesn't mess with the remaining binary sections).







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jun 22 '11 at 6:00









          Kurt PfeifleKurt Pfeifle

          9,34713555




          9,34713555























              3














              If you are willing to get your hands dirty; iText should work.



              There are examples which cover a wide range of topics and should get you pointed in the right direction.



              Note the example below; using the document.add method to add a Paragraph into an existing PDF document.



              protected void createPdf(String filename)
              throws IOException, DocumentException, SQLException {
              // Open the database connection
              DatabaseConnection connection = new HsqldbConnection("filmfestival");
              // step 1
              Document document = new Document();
              // step 2
              PdfWriter.getInstance(document, new FileOutputStream(filename));
              // step 3
              document.open();
              // step 4
              // Add text with a local destination
              Paragraph p = new Paragraph();
              Chunk top = new Chunk("Country List", FilmFonts.BOLD);
              top.setLocalDestination("top");
              p.add(top);
              document.add(p);
              // Add text with a link to an external URL
              Chunk imdb = new Chunk("Internet Movie Database", FilmFonts.ITALIC);
              imdb.setAction(new PdfAction(new URL("http://www.imdb.com/")));
              p = new Paragraph(
              "Click on a country, and you'll get a list of movies, containing links to the ");
              p.add(imdb);
              p.add(".");
              document.add(p);
              // Add text with a remote goto
              p = new Paragraph("This list can be found in a ");
              Chunk page1 = new Chunk("separate document");
              page1.setAction(new PdfAction("movie_links_1.pdf", 1));
              p.add(page1);
              p.add(".");
              document.add(p);
              document.add(Chunk.NEWLINE);
              // Get a list with countries from the database
              Statement stm = connection.createStatement();
              ResultSet rs = stm.executeQuery(
              "SELECT DISTINCT mc.country_id, c.country, count(*) AS c "
              + "FROM film_country c, film_movie_country mc WHERE c.id = mc.country_id "
              + "GROUP BY mc.country_id, country ORDER BY c DESC");
              // Loop over the countries
              while (rs.next()) {
              Paragraph country = new Paragraph(rs.getString("country"));
              country.add(": ");
              Chunk link = new Chunk(String.format("%d movies", rs.getInt("c")));
              link.setAction(
              PdfAction.gotoRemotePage("movie_links_1.pdf", rs.getString("country_id"), false, true));
              country.add(link);
              document.add(country);
              }
              document.add(Chunk.NEWLINE);
              // Add text with a local goto
              p = new Paragraph("Go to ");
              top = new Chunk("top");
              top.setAction(PdfAction.gotoLocalPage("top", false));
              p.add(top);
              p.add(".");
              document.add(p);
              // step 5
              document.close();
              // Close the database connection
              connection.close();
              }





              share|improve this answer



















              • 1





                I'm willing to get my hands dirty, but not quite that dirty... I'm using Delphi. It's a shame there is no port - it looks to be pretty comprehensive.

                – rossmcm
                Jun 22 '11 at 5:01













              • Get a freelancer. Works in Java, can call it as a process

                – tgkprog
                Jun 5 '17 at 8:05
















              3














              If you are willing to get your hands dirty; iText should work.



              There are examples which cover a wide range of topics and should get you pointed in the right direction.



              Note the example below; using the document.add method to add a Paragraph into an existing PDF document.



              protected void createPdf(String filename)
              throws IOException, DocumentException, SQLException {
              // Open the database connection
              DatabaseConnection connection = new HsqldbConnection("filmfestival");
              // step 1
              Document document = new Document();
              // step 2
              PdfWriter.getInstance(document, new FileOutputStream(filename));
              // step 3
              document.open();
              // step 4
              // Add text with a local destination
              Paragraph p = new Paragraph();
              Chunk top = new Chunk("Country List", FilmFonts.BOLD);
              top.setLocalDestination("top");
              p.add(top);
              document.add(p);
              // Add text with a link to an external URL
              Chunk imdb = new Chunk("Internet Movie Database", FilmFonts.ITALIC);
              imdb.setAction(new PdfAction(new URL("http://www.imdb.com/")));
              p = new Paragraph(
              "Click on a country, and you'll get a list of movies, containing links to the ");
              p.add(imdb);
              p.add(".");
              document.add(p);
              // Add text with a remote goto
              p = new Paragraph("This list can be found in a ");
              Chunk page1 = new Chunk("separate document");
              page1.setAction(new PdfAction("movie_links_1.pdf", 1));
              p.add(page1);
              p.add(".");
              document.add(p);
              document.add(Chunk.NEWLINE);
              // Get a list with countries from the database
              Statement stm = connection.createStatement();
              ResultSet rs = stm.executeQuery(
              "SELECT DISTINCT mc.country_id, c.country, count(*) AS c "
              + "FROM film_country c, film_movie_country mc WHERE c.id = mc.country_id "
              + "GROUP BY mc.country_id, country ORDER BY c DESC");
              // Loop over the countries
              while (rs.next()) {
              Paragraph country = new Paragraph(rs.getString("country"));
              country.add(": ");
              Chunk link = new Chunk(String.format("%d movies", rs.getInt("c")));
              link.setAction(
              PdfAction.gotoRemotePage("movie_links_1.pdf", rs.getString("country_id"), false, true));
              country.add(link);
              document.add(country);
              }
              document.add(Chunk.NEWLINE);
              // Add text with a local goto
              p = new Paragraph("Go to ");
              top = new Chunk("top");
              top.setAction(PdfAction.gotoLocalPage("top", false));
              p.add(top);
              p.add(".");
              document.add(p);
              // step 5
              document.close();
              // Close the database connection
              connection.close();
              }





              share|improve this answer



















              • 1





                I'm willing to get my hands dirty, but not quite that dirty... I'm using Delphi. It's a shame there is no port - it looks to be pretty comprehensive.

                – rossmcm
                Jun 22 '11 at 5:01













              • Get a freelancer. Works in Java, can call it as a process

                – tgkprog
                Jun 5 '17 at 8:05














              3












              3








              3







              If you are willing to get your hands dirty; iText should work.



              There are examples which cover a wide range of topics and should get you pointed in the right direction.



              Note the example below; using the document.add method to add a Paragraph into an existing PDF document.



              protected void createPdf(String filename)
              throws IOException, DocumentException, SQLException {
              // Open the database connection
              DatabaseConnection connection = new HsqldbConnection("filmfestival");
              // step 1
              Document document = new Document();
              // step 2
              PdfWriter.getInstance(document, new FileOutputStream(filename));
              // step 3
              document.open();
              // step 4
              // Add text with a local destination
              Paragraph p = new Paragraph();
              Chunk top = new Chunk("Country List", FilmFonts.BOLD);
              top.setLocalDestination("top");
              p.add(top);
              document.add(p);
              // Add text with a link to an external URL
              Chunk imdb = new Chunk("Internet Movie Database", FilmFonts.ITALIC);
              imdb.setAction(new PdfAction(new URL("http://www.imdb.com/")));
              p = new Paragraph(
              "Click on a country, and you'll get a list of movies, containing links to the ");
              p.add(imdb);
              p.add(".");
              document.add(p);
              // Add text with a remote goto
              p = new Paragraph("This list can be found in a ");
              Chunk page1 = new Chunk("separate document");
              page1.setAction(new PdfAction("movie_links_1.pdf", 1));
              p.add(page1);
              p.add(".");
              document.add(p);
              document.add(Chunk.NEWLINE);
              // Get a list with countries from the database
              Statement stm = connection.createStatement();
              ResultSet rs = stm.executeQuery(
              "SELECT DISTINCT mc.country_id, c.country, count(*) AS c "
              + "FROM film_country c, film_movie_country mc WHERE c.id = mc.country_id "
              + "GROUP BY mc.country_id, country ORDER BY c DESC");
              // Loop over the countries
              while (rs.next()) {
              Paragraph country = new Paragraph(rs.getString("country"));
              country.add(": ");
              Chunk link = new Chunk(String.format("%d movies", rs.getInt("c")));
              link.setAction(
              PdfAction.gotoRemotePage("movie_links_1.pdf", rs.getString("country_id"), false, true));
              country.add(link);
              document.add(country);
              }
              document.add(Chunk.NEWLINE);
              // Add text with a local goto
              p = new Paragraph("Go to ");
              top = new Chunk("top");
              top.setAction(PdfAction.gotoLocalPage("top", false));
              p.add(top);
              p.add(".");
              document.add(p);
              // step 5
              document.close();
              // Close the database connection
              connection.close();
              }





              share|improve this answer













              If you are willing to get your hands dirty; iText should work.



              There are examples which cover a wide range of topics and should get you pointed in the right direction.



              Note the example below; using the document.add method to add a Paragraph into an existing PDF document.



              protected void createPdf(String filename)
              throws IOException, DocumentException, SQLException {
              // Open the database connection
              DatabaseConnection connection = new HsqldbConnection("filmfestival");
              // step 1
              Document document = new Document();
              // step 2
              PdfWriter.getInstance(document, new FileOutputStream(filename));
              // step 3
              document.open();
              // step 4
              // Add text with a local destination
              Paragraph p = new Paragraph();
              Chunk top = new Chunk("Country List", FilmFonts.BOLD);
              top.setLocalDestination("top");
              p.add(top);
              document.add(p);
              // Add text with a link to an external URL
              Chunk imdb = new Chunk("Internet Movie Database", FilmFonts.ITALIC);
              imdb.setAction(new PdfAction(new URL("http://www.imdb.com/")));
              p = new Paragraph(
              "Click on a country, and you'll get a list of movies, containing links to the ");
              p.add(imdb);
              p.add(".");
              document.add(p);
              // Add text with a remote goto
              p = new Paragraph("This list can be found in a ");
              Chunk page1 = new Chunk("separate document");
              page1.setAction(new PdfAction("movie_links_1.pdf", 1));
              p.add(page1);
              p.add(".");
              document.add(p);
              document.add(Chunk.NEWLINE);
              // Get a list with countries from the database
              Statement stm = connection.createStatement();
              ResultSet rs = stm.executeQuery(
              "SELECT DISTINCT mc.country_id, c.country, count(*) AS c "
              + "FROM film_country c, film_movie_country mc WHERE c.id = mc.country_id "
              + "GROUP BY mc.country_id, country ORDER BY c DESC");
              // Loop over the countries
              while (rs.next()) {
              Paragraph country = new Paragraph(rs.getString("country"));
              country.add(": ");
              Chunk link = new Chunk(String.format("%d movies", rs.getInt("c")));
              link.setAction(
              PdfAction.gotoRemotePage("movie_links_1.pdf", rs.getString("country_id"), false, true));
              country.add(link);
              document.add(country);
              }
              document.add(Chunk.NEWLINE);
              // Add text with a local goto
              p = new Paragraph("Go to ");
              top = new Chunk("top");
              top.setAction(PdfAction.gotoLocalPage("top", false));
              p.add(top);
              p.add(".");
              document.add(p);
              // step 5
              document.close();
              // Close the database connection
              connection.close();
              }






              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Jun 22 '11 at 4:31









              Aaron McIverAaron McIver

              1,360713




              1,360713








              • 1





                I'm willing to get my hands dirty, but not quite that dirty... I'm using Delphi. It's a shame there is no port - it looks to be pretty comprehensive.

                – rossmcm
                Jun 22 '11 at 5:01













              • Get a freelancer. Works in Java, can call it as a process

                – tgkprog
                Jun 5 '17 at 8:05














              • 1





                I'm willing to get my hands dirty, but not quite that dirty... I'm using Delphi. It's a shame there is no port - it looks to be pretty comprehensive.

                – rossmcm
                Jun 22 '11 at 5:01













              • Get a freelancer. Works in Java, can call it as a process

                – tgkprog
                Jun 5 '17 at 8:05








              1




              1





              I'm willing to get my hands dirty, but not quite that dirty... I'm using Delphi. It's a shame there is no port - it looks to be pretty comprehensive.

              – rossmcm
              Jun 22 '11 at 5:01







              I'm willing to get my hands dirty, but not quite that dirty... I'm using Delphi. It's a shame there is no port - it looks to be pretty comprehensive.

              – rossmcm
              Jun 22 '11 at 5:01















              Get a freelancer. Works in Java, can call it as a process

              – tgkprog
              Jun 5 '17 at 8:05





              Get a freelancer. Works in Java, can call it as a process

              – tgkprog
              Jun 5 '17 at 8:05











              2














              pdfedit might do the trick - to quote the blurb on their sourceforge site




              Free editor for PDF documents. Complete editing of PDF documents is possible with PDFedit. You can change raw pdf objects (for advanced users) or use many gui functions. Functionality can be easily extended using a scripting language (ECMAScript)




              As of June 2013, there are *nix and Windows versions.






              share|improve this answer


























              • Windows unfortunately

                – rossmcm
                Jun 22 '11 at 2:00











              • it allegedly works in cygwin or colinux/andlinux but i've never gotten it to work,

                – Journeyman Geek
                Jun 22 '11 at 2:34
















              2














              pdfedit might do the trick - to quote the blurb on their sourceforge site




              Free editor for PDF documents. Complete editing of PDF documents is possible with PDFedit. You can change raw pdf objects (for advanced users) or use many gui functions. Functionality can be easily extended using a scripting language (ECMAScript)




              As of June 2013, there are *nix and Windows versions.






              share|improve this answer


























              • Windows unfortunately

                – rossmcm
                Jun 22 '11 at 2:00











              • it allegedly works in cygwin or colinux/andlinux but i've never gotten it to work,

                – Journeyman Geek
                Jun 22 '11 at 2:34














              2












              2








              2







              pdfedit might do the trick - to quote the blurb on their sourceforge site




              Free editor for PDF documents. Complete editing of PDF documents is possible with PDFedit. You can change raw pdf objects (for advanced users) or use many gui functions. Functionality can be easily extended using a scripting language (ECMAScript)




              As of June 2013, there are *nix and Windows versions.






              share|improve this answer















              pdfedit might do the trick - to quote the blurb on their sourceforge site




              Free editor for PDF documents. Complete editing of PDF documents is possible with PDFedit. You can change raw pdf objects (for advanced users) or use many gui functions. Functionality can be easily extended using a scripting language (ECMAScript)




              As of June 2013, there are *nix and Windows versions.







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Jun 26 '13 at 8:23









              Dan Dascalescu

              2,39842847




              2,39842847










              answered Jun 22 '11 at 1:19









              Journeyman GeekJourneyman Geek

              113k44217371




              113k44217371













              • Windows unfortunately

                – rossmcm
                Jun 22 '11 at 2:00











              • it allegedly works in cygwin or colinux/andlinux but i've never gotten it to work,

                – Journeyman Geek
                Jun 22 '11 at 2:34



















              • Windows unfortunately

                – rossmcm
                Jun 22 '11 at 2:00











              • it allegedly works in cygwin or colinux/andlinux but i've never gotten it to work,

                – Journeyman Geek
                Jun 22 '11 at 2:34

















              Windows unfortunately

              – rossmcm
              Jun 22 '11 at 2:00





              Windows unfortunately

              – rossmcm
              Jun 22 '11 at 2:00













              it allegedly works in cygwin or colinux/andlinux but i've never gotten it to work,

              – Journeyman Geek
              Jun 22 '11 at 2:34





              it allegedly works in cygwin or colinux/andlinux but i've never gotten it to work,

              – Journeyman Geek
              Jun 22 '11 at 2:34











              0














              Foxit PDF Reader Enterprise Edition allows you to edit PDFs. There's also Master PDF, but the free version adds a watermark (which I'm sure you don't want).



              Alternately, you can keep your master copy as a Word (.docx) or OO Writer (.odt) document and use a printer emulator (such as CutePDF Writer) to "print" to PDF. Office 365 and OO Writer also offer "Export to PDF" functionality, which avoids the need for editing PDFs in the first place.






              share|improve this answer




























                0














                Foxit PDF Reader Enterprise Edition allows you to edit PDFs. There's also Master PDF, but the free version adds a watermark (which I'm sure you don't want).



                Alternately, you can keep your master copy as a Word (.docx) or OO Writer (.odt) document and use a printer emulator (such as CutePDF Writer) to "print" to PDF. Office 365 and OO Writer also offer "Export to PDF" functionality, which avoids the need for editing PDFs in the first place.






                share|improve this answer


























                  0












                  0








                  0







                  Foxit PDF Reader Enterprise Edition allows you to edit PDFs. There's also Master PDF, but the free version adds a watermark (which I'm sure you don't want).



                  Alternately, you can keep your master copy as a Word (.docx) or OO Writer (.odt) document and use a printer emulator (such as CutePDF Writer) to "print" to PDF. Office 365 and OO Writer also offer "Export to PDF" functionality, which avoids the need for editing PDFs in the first place.






                  share|improve this answer













                  Foxit PDF Reader Enterprise Edition allows you to edit PDFs. There's also Master PDF, but the free version adds a watermark (which I'm sure you don't want).



                  Alternately, you can keep your master copy as a Word (.docx) or OO Writer (.odt) document and use a printer emulator (such as CutePDF Writer) to "print" to PDF. Office 365 and OO Writer also offer "Export to PDF" functionality, which avoids the need for editing PDFs in the first place.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jan 25 at 8:29









                  Agi HammerthiefAgi Hammerthief

                  170113




                  170113






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Super User!


                      • 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%2fsuperuser.com%2fquestions%2f300405%2fis-it-possible-to-edit-a-pdf-file-directly%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







                      Popular posts from this blog

                      Plaza Victoria

                      In PowerPoint, is there a keyboard shortcut for bulleted / numbered list?

                      How to put 3 figures in Latex with 2 figures side by side and 1 below these side by side images but in...