Re: Copy a page to a new PDDocument
Am 26.04.2016 um 20:06 schrieb Tilman Hausherr: Am 26.04.2016 um 15:59 schrieb Simon Gaeremynck: Hi, So far this has happened with any document I’ve tried. Here’s the latest one: https://s3.amazonaws.com/ally-dev/files/e.pdf I’m running pdfbox 2.0.1. Thanks. I have opened https://issues.apache.org/jira/browse/PDFBOX-3328 . You can also comment there if you're registered (if the lockdown is over). IMHO the lockdown should be over, at least the banner in JIRA is gone If you're in a hurry, just copy the source code of PDFCloneUtility and create your own importPage as described in the issue. Tilman The full stack trace: Exception in thread "main" java.io.IOException: COSStream has been closed and cannot be read. Perhaps its enclosing PDDocument has been closed? at org.apache.pdfbox.cos.COSStream.checkClosed(COSStream.java:78) at org.apache.pdfbox.cos.COSStream.createRawInputStream(COSStream.java:126) at org.apache.pdfbox.pdfwriter.COSWriter.visitFromStream(COSWriter.java:1177) at org.apache.pdfbox.cos.COSStream.accept(COSStream.java:372) at org.apache.pdfbox.cos.COSObject.accept(COSObject.java:158) at org.apache.pdfbox.pdfwriter.COSWriter.doWriteObject(COSWriter.java:561) at org.apache.pdfbox.pdfwriter.COSWriter.doWriteObjects(COSWriter.java:490) at org.apache.pdfbox.pdfwriter.COSWriter.doWriteBody(COSWriter.java:474) at org.apache.pdfbox.pdfwriter.COSWriter.visitFromDocument(COSWriter.java:1073) at org.apache.pdfbox.cos.COSDocument.accept(COSDocument.java:419) at org.apache.pdfbox.pdfwriter.COSWriter.write(COSWriter.java:1331) at org.apache.pdfbox.pdfwriter.COSWriter.write(COSWriter.java:1229) at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1101) at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1073) Thanks! Simon On 25 Apr 2016, at 23:40, Tilman Hausherrwrote: Am 26.04.2016 um 08:08 schrieb Simon Gaeremynck: Hello, I’m trying to copy a page from a PDF and adding it to a new (empty) document but I’m running into an issue when I close the source PDF file before I save the destination file. Here’s a code snippet: // Load up some document from which to copy a page PDDocument documentA = PDDocument.load(new File("a.pdf")); // Create a new document and import the first page of the a document PDDocument newDocument = new PDDocument(); newDocument.importPage(documentA.getPage(0)); // Close the A document as we don't need it any longer documentA.close(); // Save the new document, this throws: // COSStream has been closed and cannot be read. Perhaps its enclosing PDDocument has been closed? // java.io.IOException: COSStream has been closed and cannot be read. Perhaps its enclosing PDDocument has been closed? newDocument.save(new File("new.pdf")); I get a similar exception when using the PDFMergerUtility class. I need to copy quite a few pages into a single output document and I’d like to avoid keeping all those source documents open both at the source and in the destination document. Any ideas? This shouldn't happen when using importPage, as that one should do a deep copy. Could you upload a PDF somewhere? (Attachments don't work) Please do also mention what version you are using Tilman Kind regards, Simon - To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org For additional commands, e-mail: users-h...@pdfbox.apache.org - To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org For additional commands, e-mail: users-h...@pdfbox.apache.org - To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org For additional commands, e-mail: users-h...@pdfbox.apache.org - To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org For additional commands, e-mail: users-h...@pdfbox.apache.org - To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org For additional commands, e-mail: users-h...@pdfbox.apache.org
Re: Copy a page to a new PDDocument
Duplicate of https://issues.apache.org/jira/browse/PDFBOX-3280 :-( Tilman Am 26.04.2016 um 20:06 schrieb Tilman Hausherr: Am 26.04.2016 um 15:59 schrieb Simon Gaeremynck: Hi, So far this has happened with any document I’ve tried. Here’s the latest one: https://s3.amazonaws.com/ally-dev/files/e.pdf I’m running pdfbox 2.0.1. Thanks. I have opened https://issues.apache.org/jira/browse/PDFBOX-3328 . You can also comment there if you're registered (if the lockdown is over). If you're in a hurry, just copy the source code of PDFCloneUtility and create your own importPage as described in the issue. Tilman The full stack trace: Exception in thread "main" java.io.IOException: COSStream has been closed and cannot be read. Perhaps its enclosing PDDocument has been closed? at org.apache.pdfbox.cos.COSStream.checkClosed(COSStream.java:78) at org.apache.pdfbox.cos.COSStream.createRawInputStream(COSStream.java:126) at org.apache.pdfbox.pdfwriter.COSWriter.visitFromStream(COSWriter.java:1177) at org.apache.pdfbox.cos.COSStream.accept(COSStream.java:372) at org.apache.pdfbox.cos.COSObject.accept(COSObject.java:158) at org.apache.pdfbox.pdfwriter.COSWriter.doWriteObject(COSWriter.java:561) at org.apache.pdfbox.pdfwriter.COSWriter.doWriteObjects(COSWriter.java:490) at org.apache.pdfbox.pdfwriter.COSWriter.doWriteBody(COSWriter.java:474) at org.apache.pdfbox.pdfwriter.COSWriter.visitFromDocument(COSWriter.java:1073) at org.apache.pdfbox.cos.COSDocument.accept(COSDocument.java:419) at org.apache.pdfbox.pdfwriter.COSWriter.write(COSWriter.java:1331) at org.apache.pdfbox.pdfwriter.COSWriter.write(COSWriter.java:1229) at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1101) at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1073) Thanks! Simon On 25 Apr 2016, at 23:40, Tilman Hausherrwrote: Am 26.04.2016 um 08:08 schrieb Simon Gaeremynck: Hello, I’m trying to copy a page from a PDF and adding it to a new (empty) document but I’m running into an issue when I close the source PDF file before I save the destination file. Here’s a code snippet: // Load up some document from which to copy a page PDDocument documentA = PDDocument.load(new File("a.pdf")); // Create a new document and import the first page of the a document PDDocument newDocument = new PDDocument(); newDocument.importPage(documentA.getPage(0)); // Close the A document as we don't need it any longer documentA.close(); // Save the new document, this throws: // COSStream has been closed and cannot be read. Perhaps its enclosing PDDocument has been closed? // java.io.IOException: COSStream has been closed and cannot be read. Perhaps its enclosing PDDocument has been closed? newDocument.save(new File("new.pdf")); I get a similar exception when using the PDFMergerUtility class. I need to copy quite a few pages into a single output document and I’d like to avoid keeping all those source documents open both at the source and in the destination document. Any ideas? This shouldn't happen when using importPage, as that one should do a deep copy. Could you upload a PDF somewhere? (Attachments don't work) Please do also mention what version you are using Tilman Kind regards, Simon - To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org For additional commands, e-mail: users-h...@pdfbox.apache.org - To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org For additional commands, e-mail: users-h...@pdfbox.apache.org - To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org For additional commands, e-mail: users-h...@pdfbox.apache.org - To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org For additional commands, e-mail: users-h...@pdfbox.apache.org - To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org For additional commands, e-mail: users-h...@pdfbox.apache.org
RE: Completely Remove a Field
New Solution: List pdFieldList = pdAcroForm.getFields(); removeField(pdFieldList, fieldName); // other . . . pdAcroForm.flatten(); public static boolean removeField(List pdFieldList, String fieldName) { boolean removed = false; Iterator it = pdFieldList.iterator(); while (it.hasNext() && !removed) { PDField pdField = it.next(); if (pdField instanceof PDNonTerminalField) { List pdChildFieldList = ((PDNonTerminalField) pdField).getChildren(); removed = removeField(pdChildFieldList, fieldName); } else if (fieldName.equals(pdField.getPartialName())) { pdFieldList.remove(pdField); removed = true; } } return removed; } -Original Message- From: Tilman Hausherr [mailto:thaush...@t-online.de] Sent: Tuesday, April 26, 2016 12:02 PM To: users@pdfbox.apache.org Subject: Re: Completely Remove a Field Am 25.04.2016 um 23:49 schrieb Kevin Ternes: > It seems like removing a PDField from a loaded PDDocument would be trivial. > The goal is to remove the field from the form and anything related to that > field from the displayed PDF. > > I have tried just removing the PDField from the List of > PDAcroForm.getFields() which does not seem to work. > > And I have tried digging into the PDAcroForm's dictionary: > PDField pdField = pdAcroForm.getField("boxAPPL"); > COSDictionary formDict = pdAcroForm.getCOSObject(); > COSArray fieldz = (COSArray) > formDict.getDictionaryObject(COSName.FIELDS); > fieldz.removeObject(pdField.getCOSObject()); > > which does not appear to work either. Have a look at PDAcroForm.getFields(). You'll have to work with that, and if you don't find your field, call PDNonTerminalField.getChildren() on non terminal fields. When you find it, remove your field and reassign the list. To find out whether you got your field, check the name or compare not the PDField object, but its getCOSObject() result. Your solution in the recent mail might still work with a specific PDF, but I doubt it will work for all PDFs. Tilman - To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org For additional commands, e-mail: users-h...@pdfbox.apache.org
Re: Copy a page to a new PDDocument
Am 26.04.2016 um 15:59 schrieb Simon Gaeremynck: Hi, So far this has happened with any document I’ve tried. Here’s the latest one: https://s3.amazonaws.com/ally-dev/files/e.pdf I’m running pdfbox 2.0.1. Thanks. I have opened https://issues.apache.org/jira/browse/PDFBOX-3328 . You can also comment there if you're registered (if the lockdown is over). If you're in a hurry, just copy the source code of PDFCloneUtility and create your own importPage as described in the issue. Tilman The full stack trace: Exception in thread "main" java.io.IOException: COSStream has been closed and cannot be read. Perhaps its enclosing PDDocument has been closed? at org.apache.pdfbox.cos.COSStream.checkClosed(COSStream.java:78) at org.apache.pdfbox.cos.COSStream.createRawInputStream(COSStream.java:126) at org.apache.pdfbox.pdfwriter.COSWriter.visitFromStream(COSWriter.java:1177) at org.apache.pdfbox.cos.COSStream.accept(COSStream.java:372) at org.apache.pdfbox.cos.COSObject.accept(COSObject.java:158) at org.apache.pdfbox.pdfwriter.COSWriter.doWriteObject(COSWriter.java:561) at org.apache.pdfbox.pdfwriter.COSWriter.doWriteObjects(COSWriter.java:490) at org.apache.pdfbox.pdfwriter.COSWriter.doWriteBody(COSWriter.java:474) at org.apache.pdfbox.pdfwriter.COSWriter.visitFromDocument(COSWriter.java:1073) at org.apache.pdfbox.cos.COSDocument.accept(COSDocument.java:419) at org.apache.pdfbox.pdfwriter.COSWriter.write(COSWriter.java:1331) at org.apache.pdfbox.pdfwriter.COSWriter.write(COSWriter.java:1229) at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1101) at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1073) Thanks! Simon On 25 Apr 2016, at 23:40, Tilman Hausherrwrote: Am 26.04.2016 um 08:08 schrieb Simon Gaeremynck: Hello, I’m trying to copy a page from a PDF and adding it to a new (empty) document but I’m running into an issue when I close the source PDF file before I save the destination file. Here’s a code snippet: // Load up some document from which to copy a page PDDocument documentA = PDDocument.load(new File("a.pdf")); // Create a new document and import the first page of the a document PDDocument newDocument = new PDDocument(); newDocument.importPage(documentA.getPage(0)); // Close the A document as we don't need it any longer documentA.close(); // Save the new document, this throws: // COSStream has been closed and cannot be read. Perhaps its enclosing PDDocument has been closed? // java.io.IOException: COSStream has been closed and cannot be read. Perhaps its enclosing PDDocument has been closed? newDocument.save(new File("new.pdf")); I get a similar exception when using the PDFMergerUtility class. I need to copy quite a few pages into a single output document and I’d like to avoid keeping all those source documents open both at the source and in the destination document. Any ideas? This shouldn't happen when using importPage, as that one should do a deep copy. Could you upload a PDF somewhere? (Attachments don't work) Please do also mention what version you are using Tilman Kind regards, Simon - To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org For additional commands, e-mail: users-h...@pdfbox.apache.org - To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org For additional commands, e-mail: users-h...@pdfbox.apache.org - To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org For additional commands, e-mail: users-h...@pdfbox.apache.org - To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org For additional commands, e-mail: users-h...@pdfbox.apache.org
Re: Completely Remove a Field
Am 25.04.2016 um 23:49 schrieb Kevin Ternes: It seems like removing a PDField from a loaded PDDocument would be trivial. The goal is to remove the field from the form and anything related to that field from the displayed PDF. I have tried just removing the PDField from the List of PDAcroForm.getFields() which does not seem to work. And I have tried digging into the PDAcroForm's dictionary: PDField pdField = pdAcroForm.getField("boxAPPL"); COSDictionary formDict = pdAcroForm.getCOSObject(); COSArray fieldz = (COSArray) formDict.getDictionaryObject(COSName.FIELDS); fieldz.removeObject(pdField.getCOSObject()); which does not appear to work either. Have a look at PDAcroForm.getFields(). You'll have to work with that, and if you don't find your field, call PDNonTerminalField.getChildren() on non terminal fields. When you find it, remove your field and reassign the list. To find out whether you got your field, check the name or compare not the PDField object, but its getCOSObject() result. Your solution in the recent mail might still work with a specific PDF, but I doubt it will work for all PDFs. Tilman - To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org For additional commands, e-mail: users-h...@pdfbox.apache.org
RE: Completely Remove a Field
The code below works as far as it goes. Until we call PDAcroForm.flatten(), the removed PDField is still accessible. So the correct code is: COSDictionary formDict = pdAcroForm.getCOSObject(); COSArray formFieldArray = (COSArray) formDict.getDictionaryObject(COSName.FIELDS); formFieldArray.removeObject(pdField.getCOSObject()); // other operations . . . pdAcroForm.flatten(); -Original Message- From: Kevin Ternes Sent: Monday, April 25, 2016 4:50 PM To: users@pdfbox.apache.org Subject: Completely Remove a Field It seems like removing a PDField from a loaded PDDocument would be trivial. The goal is to remove the field from the form and anything related to that field from the displayed PDF. I have tried just removing the PDField from the List of PDAcroForm.getFields() which does not seem to work. And I have tried digging into the PDAcroForm's dictionary: PDField pdField = pdAcroForm.getField("boxAPPL"); COSDictionary formDict = pdAcroForm.getCOSObject(); COSArray fieldz = (COSArray) formDict.getDictionaryObject(COSName.FIELDS); fieldz.removeObject(pdField.getCOSObject()); which does not appear to work either. Any is help appreciated. - To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org For additional commands, e-mail: users-h...@pdfbox.apache.org - To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org For additional commands, e-mail: users-h...@pdfbox.apache.org
Re: Copy a page to a new PDDocument
Hi, So far this has happened with any document I’ve tried. Here’s the latest one: https://s3.amazonaws.com/ally-dev/files/e.pdf I’m running pdfbox 2.0.1. The full stack trace: Exception in thread "main" java.io.IOException: COSStream has been closed and cannot be read. Perhaps its enclosing PDDocument has been closed? at org.apache.pdfbox.cos.COSStream.checkClosed(COSStream.java:78) at org.apache.pdfbox.cos.COSStream.createRawInputStream(COSStream.java:126) at org.apache.pdfbox.pdfwriter.COSWriter.visitFromStream(COSWriter.java:1177) at org.apache.pdfbox.cos.COSStream.accept(COSStream.java:372) at org.apache.pdfbox.cos.COSObject.accept(COSObject.java:158) at org.apache.pdfbox.pdfwriter.COSWriter.doWriteObject(COSWriter.java:561) at org.apache.pdfbox.pdfwriter.COSWriter.doWriteObjects(COSWriter.java:490) at org.apache.pdfbox.pdfwriter.COSWriter.doWriteBody(COSWriter.java:474) at org.apache.pdfbox.pdfwriter.COSWriter.visitFromDocument(COSWriter.java:1073) at org.apache.pdfbox.cos.COSDocument.accept(COSDocument.java:419) at org.apache.pdfbox.pdfwriter.COSWriter.write(COSWriter.java:1331) at org.apache.pdfbox.pdfwriter.COSWriter.write(COSWriter.java:1229) at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1101) at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1073) Thanks! Simon > On 25 Apr 2016, at 23:40, Tilman Hausherrwrote: > > Am 26.04.2016 um 08:08 schrieb Simon Gaeremynck: >> Hello, >> >> I’m trying to copy a page from a PDF and adding it to a new (empty) document >> but I’m running into an issue when I close the source PDF file before I save >> the destination file. >> >> Here’s a code snippet: >> // Load up some document from which to copy a page >> PDDocument documentA = PDDocument.load(new File("a.pdf")); >> >> // Create a new document and import the first page of the a document >> PDDocument newDocument = new PDDocument(); >> newDocument.importPage(documentA.getPage(0)); >> >> // Close the A document as we don't need it any longer >> documentA.close(); >> >> // Save the new document, this throws: >> // COSStream has been closed and cannot be read. Perhaps its enclosing >> PDDocument has been closed? >> // java.io.IOException: COSStream has been closed and cannot be read. >> Perhaps its enclosing PDDocument has been closed? >> newDocument.save(new File("new.pdf")); >> >> I get a similar exception when using the PDFMergerUtility class. >> >> I need to copy quite a few pages into a single output document and I’d like >> to avoid keeping all those source documents open both at the source and in >> the destination document. >> >> Any ideas? > > This shouldn't happen when using importPage, as that one should do a deep > copy. Could you upload a PDF somewhere? (Attachments don't work) Please do > also mention what version you are using > > Tilman > >> >> Kind regards, >> Simon >> - >> To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org >> For additional commands, e-mail: users-h...@pdfbox.apache.org >> > > > - > To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org > For additional commands, e-mail: users-h...@pdfbox.apache.org > - To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org For additional commands, e-mail: users-h...@pdfbox.apache.org
Re: How to add annotation that opens url in new tab/window ?
Hi, > Am 26.04.2016 um 11:12 schrieb Jana Sefcikova: > > Hi Maruan, > > thank you for your response. > > Where this code can be placed ? Somewhere in GUI or it can be done > programatically ? I havnÄt had the time to test the code but that should work I think: you can add Javascript to an annotation like this for a given annotation 'annot' PDActionJavaScript javascriptAction = new PDActionJavaScript("app.launchURL("http://yoururl;, true);"); PDAnnotationAdditionalActions actions = new PDAnnotationAdditionalActions(); actions.setU(javascriptAction); annot.setActions(actions); > What is app ? app is an Adobe Acrobat/Reader JavaScript object representing the application the PDF is running in (Acrobat/Reader). This is part of the Acrobat JavaScript SDK http://www.adobe.com/devnet/acrobat/javascript.html Let me know if you are experiencing any issues. BR Maruan > > Thank you > > ps: I am first time replying to this mailing list, and I am not sure > whether this answer will be correctly placed under original discussion, as > I don't know who should be recipient > > > On Sat, Apr 23, 2016 at 6:55 PM, Maruan Sahyoun > wrote: > >> Hi, >> >>> Am 23.04.2016 um 19:47 schrieb Tilman Hausherr : >>> >>> Hi, >>> >>> If you download this PDF >>> >> https://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf >>> open it, then go to the second page, and click on the link, what happens? >>> >>> (I suspect this is rather a problem of the browser or an Adobe Reader >> setting) >>> >>> Tilman >>> >>> Am 23.04.2016 um 13:27 schrieb Jana Sefcikova: Hi, I am using pdfbox to create links inside pdf as follows: PDAnnotationLink txtLink = new PDAnnotationLink(); // code for setting position PDActionURI action = new PDActionURI(); action.setURI("http://www.google.com;); txtLink.setAction(action); >> >> >> a regular link annotation doesn't have the capability. What you can do is >> adding a JavaScript with the following content >> >> app.launchURL("http://yoururl;, true); >> >> replacing with the actual one. >> >> Be aware that this JavaScript is application specific so might not work in >> Readers other than Adobe Reader / Acrobat. >> >> BR >> Maruan >> >> But when I open pdf in browser and click on the annotated text, it opens url in the current tab in the browser. Can I open links in new tab using pdfbox ? If yes, could you provide >> some example ? Thank you very much >>> >>> >>> - >>> To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org >>> For additional commands, e-mail: users-h...@pdfbox.apache.org >>> >> >> >> - >> To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org >> For additional commands, e-mail: users-h...@pdfbox.apache.org >> >> > On Sat, Apr 23, 2016 at 6:55 PM, Maruan Sahyoun > wrote: > >> Hi, >> >>> Am 23.04.2016 um 19:47 schrieb Tilman Hausherr : >>> >>> Hi, >>> >>> If you download this PDF >>> >> https://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf >>> open it, then go to the second page, and click on the link, what happens? >>> >>> (I suspect this is rather a problem of the browser or an Adobe Reader >> setting) >>> >>> Tilman >>> >>> Am 23.04.2016 um 13:27 schrieb Jana Sefcikova: Hi, I am using pdfbox to create links inside pdf as follows: PDAnnotationLink txtLink = new PDAnnotationLink(); // code for setting position PDActionURI action = new PDActionURI(); action.setURI("http://www.google.com;); txtLink.setAction(action); >> >> >> a regular link annotation doesn't have the capability. What you can do is >> adding a JavaScript with the following content >> >> app.launchURL("http://yoururl;, true); >> >> replacing with the actual one. >> >> Be aware that this JavaScript is application specific so might not work in >> Readers other than Adobe Reader / Acrobat. >> >> BR >> Maruan >> >> But when I open pdf in browser and click on the annotated text, it opens url in the current tab in the browser. Can I open links in new tab using pdfbox ? If yes, could you provide >> some example ? Thank you very much >>> >>> >>> - >>> To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org >>> For additional commands, e-mail: users-h...@pdfbox.apache.org >>> >> >> >> - >> To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org >> For additional commands, e-mail:
Re: How to add annotation that opens url in new tab/window ?
Hi Maruan, thank you for your response. Where this code can be placed ? Somewhere in GUI or it can be done programatically ? What is app ? Thank you ps: I am first time replying to this mailing list, and I am not sure whether this answer will be correctly placed under original discussion, as I don't know who should be recipient On Sat, Apr 23, 2016 at 6:55 PM, Maruan Sahyounwrote: > Hi, > > > Am 23.04.2016 um 19:47 schrieb Tilman Hausherr : > > > > Hi, > > > > If you download this PDF > > > https://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf > > open it, then go to the second page, and click on the link, what happens? > > > > (I suspect this is rather a problem of the browser or an Adobe Reader > setting) > > > > Tilman > > > > Am 23.04.2016 um 13:27 schrieb Jana Sefcikova: > >> Hi, I am using pdfbox to create links inside pdf as follows: > >> > >> PDAnnotationLink txtLink = new PDAnnotationLink(); > >> > >> // code for setting position > >> > >> PDActionURI action = new PDActionURI(); > >> > >> action.setURI("http://www.google.com;); > >> > >> txtLink.setAction(action); > > > a regular link annotation doesn't have the capability. What you can do is > adding a JavaScript with the following content > > app.launchURL("http://yoururl;, true); > > replacing with the actual one. > > Be aware that this JavaScript is application specific so might not work in > Readers other than Adobe Reader / Acrobat. > > BR > Maruan > > > >> > >> But when I open pdf in browser and click on the annotated text, it opens > >> url in the current tab in the browser. > >> > >> > >> Can I open links in new tab using pdfbox ? If yes, could you provide > some > >> example ? > >> > >> Thank you very much > >> > > > > > > - > > To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org > > For additional commands, e-mail: users-h...@pdfbox.apache.org > > > > > - > To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org > For additional commands, e-mail: users-h...@pdfbox.apache.org > > On Sat, Apr 23, 2016 at 6:55 PM, Maruan Sahyoun wrote: > Hi, > > > Am 23.04.2016 um 19:47 schrieb Tilman Hausherr : > > > > Hi, > > > > If you download this PDF > > > https://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf > > open it, then go to the second page, and click on the link, what happens? > > > > (I suspect this is rather a problem of the browser or an Adobe Reader > setting) > > > > Tilman > > > > Am 23.04.2016 um 13:27 schrieb Jana Sefcikova: > >> Hi, I am using pdfbox to create links inside pdf as follows: > >> > >> PDAnnotationLink txtLink = new PDAnnotationLink(); > >> > >> // code for setting position > >> > >> PDActionURI action = new PDActionURI(); > >> > >> action.setURI("http://www.google.com;); > >> > >> txtLink.setAction(action); > > > a regular link annotation doesn't have the capability. What you can do is > adding a JavaScript with the following content > > app.launchURL("http://yoururl;, true); > > replacing with the actual one. > > Be aware that this JavaScript is application specific so might not work in > Readers other than Adobe Reader / Acrobat. > > BR > Maruan > > > >> > >> But when I open pdf in browser and click on the annotated text, it opens > >> url in the current tab in the browser. > >> > >> > >> Can I open links in new tab using pdfbox ? If yes, could you provide > some > >> example ? > >> > >> Thank you very much > >> > > > > > > - > > To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org > > For additional commands, e-mail: users-h...@pdfbox.apache.org > > > > > - > To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org > For additional commands, e-mail: users-h...@pdfbox.apache.org > >
[ANNOUNCE] Apache PDFBox 2.0.1 released
The Apache PDFBox community is pleased to announce the release of Apache PDFBox version 2.0.1. The release is available for download at: http://pdfbox.apache.org/download.cgi See the full release notes below for details about this release. Release Notes -- Apache PDFBox -- Version 2.0.1 Introduction The Apache PDFBox library is an open source Java tool for working with PDF documents. This is an incremental bugfix release based on the earlier 2.0.0 release. It contains a couple of fixes and small improvements. For more details on these changes and all the other fixes and improvements included in this release, please refer to the following issues on the PDFBox issue tracker at https://issues.apache.org/jira/browse/PDFBOX. Bug [PDFBOX-3272] - Loaded fonts file descriptors open after closing document [PDFBOX-3273] - Fonts not rendered correctly [PDFBOX-3276] - Double encryption dictionary for files with XRef stream [PDFBOX-3279] - PDDocument.importPage creates two inputstreams [PDFBOX-3281] - HTML output wrongly specifies UTF-16 in header [PDFBOX-3286] - Think I found a bad constant (TTF) value and constant use in PDFBox source [PDFBOX-3292] - Error reading stream, expected='endstream' actual='' in non-truncated files [PDFBOX-3297] - Infinite loop [PDFBOX-3299] - TIFF-files with FillOrder=2 can't be converted to PDF [PDFBOX-3301] - NPE in PDAcroForm.flatten if a widget doesn't contain a /P entry [PDFBOX-3303] - setWidgets should set connection to parent [PDFBOX-3308] - Missing endOfName chars [PDFBOX-3312] - NPE in saveIncremental() / fix javadoc [PDFBOX-3317] - Merged PDF/A files no longer valid PDF/A [PDFBOX-3319] - Chinese character overlap other chinese character Improvement [PDFBOX-3275] - Show glyph bounds in DrawPrintTextLocations [PDFBOX-3289] - Wrong unit MM_PER_INCH in PDRectangle [PDFBOX-3295] - Improve parsing performance of object streams [PDFBOX-3305] - PDPageContentStream should allow drawing images at current position [PDFBOX-3307] - Enable AES128 encryption [PDFBOX-3323] - Cannot set destination meta data in PDFMergerUtility Release Contents This release consists of a single source archive packaged as a zip file. The archive can be unpacked with the jar tool from your JDK installation. See the README.txt file for instructions on how to build this release. The source archive is accompanied by SHA1 and MD5 checksums and a PGP signature that you can use to verify the authenticity of your download. The public key used for the PGP signature can be found at https://svn.apache.org/repos/asf/pdfbox/KEYS. About Apache PDFBox --- Apache PDFBox is an open source Java library for working with PDF documents. This project allows creation of new PDF documents, manipulation of existing documents and the ability to extract content from documents. Apache PDFBox also includes several command line utilities. Apache PDFBox is published under the Apache License, Version 2.0. For more information, visit http://pdfbox.apache.org/ About The Apache Software Foundation Established in 1999, The Apache Software Foundation provides organizational, legal, and financial support for more than 100 freely-available, collaboratively-developed Open Source projects. The pragmatic Apache License enables individual and commercial users to easily deploy Apache software; the Foundation's intellectual property framework limits the legal exposure of its 2,500+ contributors. For more information, visit http://www.apache.org/ - To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org For additional commands, e-mail: users-h...@pdfbox.apache.org
[ANNOUNCE] Apache PDFBox 1.8.12 released
The Apache PDFBox community is pleased to announce the release of Apache PDFBox version 1.8.12. The release is available for download at: http://pdfbox.apache.org/download.cgi See the full release notes below for details about this release. Release Notes -- Apache PDFBox -- Version 1.8.12 Introduction The Apache PDFBox library is an open source Java tool for working with PDF documents. This is an incremental bugfix release based on the earlier 1.8.11 release. It contains a couple of fixes and small improvements. For more details on all fixes included in this release, please refer to the following issues on the PDFBox issue tracker at https://issues.apache.org/jira/browse/PDFBOX. Bug [PDFBOX-1995] - AdobePDFSchema.getProducer() returns empty string [PDFBOX-2428] - An error occured when reading table hmtx [PDFBOX-3024] - Preflight validation call PDType0Font.clear at the wrong time [PDFBOX-3116] - COSNumber NumberFormatException for large number [PDFBOX-3201] - Skip zlib-header and checksum to avoid DataFormatException [PDFBOX-3204] - JVM crashes on PDFRenderer.renderImageWithDPI [PDFBOX-3217] - PdfaExtensionHelper.populatePDFAPropertyType [PDFBOX-3226] - No such Element Exception processing File [PDFBOX-3229] - Decryption fails when Metadata not encrypted but EncryptMetadata is true/default. [PDFBOX-3235] - ColorSpace validation fails for inlined image [PDFBOX-3237] - ASCII85Filter does not use or recognize the correct end-of-data terminator [PDFBOX-3254] - Corrupted XMP causes java.lang.StringIndexOutOfBoundsException [PDFBOX-3257] - XMPSchemaBasic setCreateDate and setModifyDate don't work if already set [PDFBOX-3258] - XMPBox XMPBasicSchema setters don't work if already set [PDFBOX-3259] - ClassCastException in PDTilingPattern.getContents [PDFBOX-3285] - All lines that use a given font stop rendering if 'ö' is inserted - ArrayIndexOutOfBoundsException in TTFSubFont.buildPostTable [PDFBOX-3297] - Infinite loop [PDFBOX-3299] - TIFF-files with FillOrder=2 can't be converted to PDF [PDFBOX-3308] - Missing endOfName chars [PDFBOX-3321] - ASCII stream data size is increased when written Improvement [PDFBOX-1840] - Automatically load isartor for preflight tests [PDFBOX-3196] - Update maven plugins and apache parent pom [PDFBOX-3231] - Update PDPropBuildDataDict [PDFBOX-3251] - Improve parsing and validation of ColorSpace for inline image [PDFBOX-3295] - Improve parsing performance of object streams Wish [PDFBOX-3241] - return original PDF Header Release Contents This release consists of a single source archive packaged as a zip file. The archive can be unpacked with the jar tool from your JDK installation. See the README.txt file for instructions on how to build this release. The source archive is accompanied by SHA1 and MD5 checksums and a PGP signature that you can use to verify the authenticity of your download. The public key used for the PGP signature can be found at https://svn.apache.org/repos/asf/pdfbox/KEYS. About Apache PDFBox --- Apache PDFBox is an open source Java library for working with PDF documents. This project allows creation of new PDF documents, manipulation of existing documents and the ability to extract content from documents. Apache PDFBox also includes several command line utilities. Apache PDFBox is published under the Apache License, Version 2.0. For more information, visit http://pdfbox.apache.org/ About The Apache Software Foundation Established in 1999, The Apache Software Foundation provides organizational, legal, and financial support for more than 100 freely-available, collaboratively-developed Open Source projects. The pragmatic Apache License enables individual and commercial users to easily deploy Apache software; the Foundation's intellectual property framework limits the legal exposure of its 2,500+ contributors. For more information, visit http://www.apache.org/ - To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org For additional commands, e-mail: users-h...@pdfbox.apache.org
Re: Copy a page to a new PDDocument
Am 26.04.2016 um 08:08 schrieb Simon Gaeremynck: Hello, I’m trying to copy a page from a PDF and adding it to a new (empty) document but I’m running into an issue when I close the source PDF file before I save the destination file. Here’s a code snippet: // Load up some document from which to copy a page PDDocument documentA = PDDocument.load(new File("a.pdf")); // Create a new document and import the first page of the a document PDDocument newDocument = new PDDocument(); newDocument.importPage(documentA.getPage(0)); // Close the A document as we don't need it any longer documentA.close(); // Save the new document, this throws: // COSStream has been closed and cannot be read. Perhaps its enclosing PDDocument has been closed? // java.io.IOException: COSStream has been closed and cannot be read. Perhaps its enclosing PDDocument has been closed? newDocument.save(new File("new.pdf")); I get a similar exception when using the PDFMergerUtility class. I need to copy quite a few pages into a single output document and I’d like to avoid keeping all those source documents open both at the source and in the destination document. Any ideas? This shouldn't happen when using importPage, as that one should do a deep copy. Could you upload a PDF somewhere? (Attachments don't work) Please do also mention what version you are using Tilman Kind regards, Simon - To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org For additional commands, e-mail: users-h...@pdfbox.apache.org - To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org For additional commands, e-mail: users-h...@pdfbox.apache.org
Copy a page to a new PDDocument
Hello, I’m trying to copy a page from a PDF and adding it to a new (empty) document but I’m running into an issue when I close the source PDF file before I save the destination file. Here’s a code snippet: // Load up some document from which to copy a page PDDocument documentA = PDDocument.load(new File("a.pdf")); // Create a new document and import the first page of the a document PDDocument newDocument = new PDDocument(); newDocument.importPage(documentA.getPage(0)); // Close the A document as we don't need it any longer documentA.close(); // Save the new document, this throws: // COSStream has been closed and cannot be read. Perhaps its enclosing PDDocument has been closed? // java.io.IOException: COSStream has been closed and cannot be read. Perhaps its enclosing PDDocument has been closed? newDocument.save(new File("new.pdf")); I get a similar exception when using the PDFMergerUtility class. I need to copy quite a few pages into a single output document and I’d like to avoid keeping all those source documents open both at the source and in the destination document. Any ideas? Kind regards, Simon - To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org For additional commands, e-mail: users-h...@pdfbox.apache.org