You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Yonas Jongkind (JIRA)" <ji...@apache.org> on 2009/11/23 19:55:41 UTC
[jira] Created: (PDFBOX-567) PDDocument always creates a real file.
Added a constructor option to allow for the use of a memory buffer rather
than a file.
PDDocument always creates a real file. Added a constructor option to allow for the use of a memory buffer rather than a file.
-----------------------------------------------------------------------------------------------------------------------------
Key: PDFBOX-567
URL: https://issues.apache.org/jira/browse/PDFBOX-567
Project: PDFBox
Issue Type: Improvement
Reporter: Yonas Jongkind
Added another constructor that allows for the use of a memory buffer instead. Better for my usage and less clutter in the temp directory by far.
$ diff -w 'C:/Users/yonasj/AppData/Local/Temp/PDDocument.java-revBASE.svn000.tmp.java' 'C:/dev/pdfbox/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java'
48a49
> import org.apache.pdfbox.io.RandomAccessBuffer;
120a122,134
> this(false);
> }
> /**
> * Constructor, creates a new PDF Document with no pages. You need to add
> * at least one page for the document to be valid.
> * @param memoryScratchFile When true the temp pdf is stored in memory, when false as a real file.
> * @throws IOException If there is an error creating this document.
> */
> public PDDocument(boolean memoryScratchFile) throws IOException
> {
> if (memoryScratchFile) {
> document = new COSDocument(new RandomAccessBuffer());
> } else {
121a136
> }
305c320
< PDStream dest = new PDStream( new COSStream( src.getStream(), document.getScratchFile() ) );
---
> PDStream dest = new PDStream( new COSStream( importedPage.getContents().getStream(), document.getScratchFile() ) );
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (PDFBOX-567) PDDocument always creates a real file.
Added a constructor option to allow for the use of a memory buffer rather
than a file.
Posted by "Yonas Jongkind (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/PDFBOX-567?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Yonas Jongkind updated PDFBOX-567:
----------------------------------
Attachment: PDDocument.java
> PDDocument always creates a real file. Added a constructor option to allow for the use of a memory buffer rather than a file.
> -----------------------------------------------------------------------------------------------------------------------------
>
> Key: PDFBOX-567
> URL: https://issues.apache.org/jira/browse/PDFBOX-567
> Project: PDFBox
> Issue Type: Improvement
> Reporter: Yonas Jongkind
> Attachments: PDDocument.java
>
>
> Added another constructor that allows for the use of a memory buffer instead. Better for my usage and less clutter in the temp directory by far.
> $ diff -w 'C:/Users/yonasj/AppData/Local/Temp/PDDocument.java-revBASE.svn000.tmp.java' 'C:/dev/pdfbox/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java'
> 48a49
> > import org.apache.pdfbox.io.RandomAccessBuffer;
> 120a122,134
> > this(false);
> > }
> > /**
> > * Constructor, creates a new PDF Document with no pages. You need to add
> > * at least one page for the document to be valid.
> > * @param memoryScratchFile When true the temp pdf is stored in memory, when false as a real file.
> > * @throws IOException If there is an error creating this document.
> > */
> > public PDDocument(boolean memoryScratchFile) throws IOException
> > {
> > if (memoryScratchFile) {
> > document = new COSDocument(new RandomAccessBuffer());
> > } else {
> 121a136
> > }
> 305c320
> < PDStream dest = new PDStream( new COSStream( src.getStream(), document.getScratchFile() ) );
> ---
> > PDStream dest = new PDStream( new COSStream( importedPage.getContents().getStream(), document.getScratchFile() ) );
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (PDFBOX-567) PDDocument always creates a real
file. Added a constructor option to allow for the use of a memory buffer
rather than a file.
Posted by "Jukka Zitting (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/PDFBOX-567?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12781957#action_12781957 ]
Jukka Zitting commented on PDFBOX-567:
--------------------------------------
Good idea!
I'm not too excited about the boolean flag argument to the constructor. Is there some other way we could design the API. How about something like this:
public PDDocument(COSDocument document) {
this.document = document;
// ...
}
public PDDocument(RandomAccess buffer) {
this(new COSDocument(buffer));
}
public PDDocument() {
this(new COSDocument());
}
It does make it a bit more complex for a client to create a memory-based PDDocument, i.e. "new PDDocument(new RandomAccessBuffer())" instead of "new PDDocument(true)". How about a static factory method, like "PDDocument.newDocumentInMemory()"?
> PDDocument always creates a real file. Added a constructor option to allow for the use of a memory buffer rather than a file.
> -----------------------------------------------------------------------------------------------------------------------------
>
> Key: PDFBOX-567
> URL: https://issues.apache.org/jira/browse/PDFBOX-567
> Project: PDFBox
> Issue Type: Improvement
> Reporter: Yonas Jongkind
> Attachments: PDDocument.java, PDDocument.java.diff
>
>
> Added another constructor that allows for the use of a memory buffer instead. Better for my usage and less clutter in the temp directory by far.
> $ diff -w 'C:/Users/yonasj/AppData/Local/Temp/PDDocument.java-revBASE.svn000.tmp.java' 'C:/dev/pdfbox/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java'
> 48a49
> > import org.apache.pdfbox.io.RandomAccessBuffer;
> 120a122,134
> > this(false);
> > }
> > /**
> > * Constructor, creates a new PDF Document with no pages. You need to add
> > * at least one page for the document to be valid.
> > * @param memoryScratchFile When true the temp pdf is stored in memory, when false as a real file.
> > * @throws IOException If there is an error creating this document.
> > */
> > public PDDocument(boolean memoryScratchFile) throws IOException
> > {
> > if (memoryScratchFile) {
> > document = new COSDocument(new RandomAccessBuffer());
> > } else {
> 121a136
> > }
> 305c320
> < PDStream dest = new PDStream( new COSStream( src.getStream(), document.getScratchFile() ) );
> ---
> > PDStream dest = new PDStream( new COSStream( importedPage.getContents().getStream(), document.getScratchFile() ) );
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (PDFBOX-567) PDDocument always creates a real
file. Added a constructor option to allow for the use of a memory buffer
rather than a file.
Posted by "Mel Martinez (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/PDFBOX-567?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12781979#action_12781979 ]
Mel Martinez commented on PDFBOX-567:
-------------------------------------
+1 to Jukka's suggestion of taking a RandomAccessBuffer through the constructor rather than using a flag.
> PDDocument always creates a real file. Added a constructor option to allow for the use of a memory buffer rather than a file.
> -----------------------------------------------------------------------------------------------------------------------------
>
> Key: PDFBOX-567
> URL: https://issues.apache.org/jira/browse/PDFBOX-567
> Project: PDFBox
> Issue Type: Improvement
> Reporter: Yonas Jongkind
> Attachments: PDDocument.java, PDDocument.java.diff
>
>
> Added another constructor that allows for the use of a memory buffer instead. Better for my usage and less clutter in the temp directory by far.
> $ diff -w 'C:/Users/yonasj/AppData/Local/Temp/PDDocument.java-revBASE.svn000.tmp.java' 'C:/dev/pdfbox/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java'
> 48a49
> > import org.apache.pdfbox.io.RandomAccessBuffer;
> 120a122,134
> > this(false);
> > }
> > /**
> > * Constructor, creates a new PDF Document with no pages. You need to add
> > * at least one page for the document to be valid.
> > * @param memoryScratchFile When true the temp pdf is stored in memory, when false as a real file.
> > * @throws IOException If there is an error creating this document.
> > */
> > public PDDocument(boolean memoryScratchFile) throws IOException
> > {
> > if (memoryScratchFile) {
> > document = new COSDocument(new RandomAccessBuffer());
> > } else {
> 121a136
> > }
> 305c320
> < PDStream dest = new PDStream( new COSStream( src.getStream(), document.getScratchFile() ) );
> ---
> > PDStream dest = new PDStream( new COSStream( importedPage.getContents().getStream(), document.getScratchFile() ) );
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (PDFBOX-567) PDDocument always creates a real file.
Added a constructor option to allow for the use of a memory buffer rather
than a file.
Posted by "Yonas Jongkind (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/PDFBOX-567?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Yonas Jongkind updated PDFBOX-567:
----------------------------------
Attachment: PDDocument.java.diff
> PDDocument always creates a real file. Added a constructor option to allow for the use of a memory buffer rather than a file.
> -----------------------------------------------------------------------------------------------------------------------------
>
> Key: PDFBOX-567
> URL: https://issues.apache.org/jira/browse/PDFBOX-567
> Project: PDFBox
> Issue Type: Improvement
> Reporter: Yonas Jongkind
> Attachments: PDDocument.java, PDDocument.java.diff
>
>
> Added another constructor that allows for the use of a memory buffer instead. Better for my usage and less clutter in the temp directory by far.
> $ diff -w 'C:/Users/yonasj/AppData/Local/Temp/PDDocument.java-revBASE.svn000.tmp.java' 'C:/dev/pdfbox/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java'
> 48a49
> > import org.apache.pdfbox.io.RandomAccessBuffer;
> 120a122,134
> > this(false);
> > }
> > /**
> > * Constructor, creates a new PDF Document with no pages. You need to add
> > * at least one page for the document to be valid.
> > * @param memoryScratchFile When true the temp pdf is stored in memory, when false as a real file.
> > * @throws IOException If there is an error creating this document.
> > */
> > public PDDocument(boolean memoryScratchFile) throws IOException
> > {
> > if (memoryScratchFile) {
> > document = new COSDocument(new RandomAccessBuffer());
> > } else {
> 121a136
> > }
> 305c320
> < PDStream dest = new PDStream( new COSStream( src.getStream(), document.getScratchFile() ) );
> ---
> > PDStream dest = new PDStream( new COSStream( importedPage.getContents().getStream(), document.getScratchFile() ) );
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.