You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Andreas Lehmkühler <an...@lehmi.de.INVALID> on 2023/08/18 05:42:13 UTC

[ANNOUNCE] Apache PDFBox 3.0.0 released

The Apache PDFBox community is pleased to announce the release of Apache 
PDFBox 3.0.0. It is available for download at:

https://pdfbox.apache.org/download.html

The Apache PDFBox library is an open source Java tool for working with 
PDF documents.

This is the new major release 3.0.0 of PDFBox. This release contains a 
lot of improvements, fixes and refactorings. The API is supposed to be 
stable.

A migration guide is available at

https://pdfbox.apache.org/3.0/migration.html.

It is still a work in progress and we are happy to include any valuable 
feedback from our community.

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.

The full release notes are available at:

https://www.apache.org/dist/pdfbox/3.0.0/RELEASE-NOTES.txt


The Apache PDFBox website can be found at:

https://pdfbox.apache.org/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


AW: [ANNOUNCE] Apache PDFBox 3.0.0 released

Posted by "Brangs, Erik" <E....@dnb.de>.
Hi,

thank you. I'm happy to hear that there is no bug.

I think the section about MemoyUsageSetting in the migration guide for 3.0 could profit from examples. It could show that you can either use the convenience methods, e.g.

try (PDDocument pdDocument = Loader.loadPDF(new RandomAccessReadBufferedFile("yourfile.pdf"), IOUtils.createMemoryOnlyStreamCache())) {
...
}

or you can configure the MemoryUsageSettings yourself as in 

MemoryUsageSetting limitMainMemory = MemoryUsageSetting.setupMainMemoryOnly(10 * 1024 * 1024L);
try (PDDocument pdDocument = Loader.loadPDF(new RandomAccessReadBufferedFile("yourfile.pdf"), limitMainMemory.streamCache)) {
...
}


> -----Ursprüngliche Nachricht-----
> Von: Andreas Lehmkühler [mailto:andreas@lehmi.de.INVALID]
> Gesendet: Samstag, 19. August 2023 11:24
> An: users@pdfbox.apache.org
> Betreff: Re: [ANNOUNCE] Apache PDFBox 3.0.0 released
> 
> Hi,
> 
> @Erik thanks for the report but I guess there is a misunderstanding, see
> inline
> 
> Am 18.08.23 um 11:32 schrieb Brangs, Erik:
> > Hi,
> >
> >> -----Ursprüngliche Nachricht-----
> >> Von: Andreas Lehmkühler [mailto:andreas@lehmi.de.INVALID]
> >> Gesendet: Freitag, 18. August 2023 07:42
> >> An: users@pdfbox.apache.org
> >> Betreff: [ANNOUNCE] Apache PDFBox 3.0.0 released
> >>
> >> The Apache PDFBox community is pleased to announce the release of Apache
> >> PDFBox 3.0.0. It is available for download at:
> >>
> >> https://pdfbox.apache.org/download.html
> >>
> >> [...]
> >>
> >> A migration guide is available at
> >>
> >> https://pdfbox.apache.org/3.0/migration.html.
> >>
> >> It is still a work in progress and we are happy to include any valuable
> >> feedback from our community.
> >
> > I was going to suggest to update the documentation to say that you can use the
> streamCache field of MemoryUsageSetting rather than using IOUtils. However, I've
> looked at the code of MemoryUsageSetting and I'm not actually sure if that's correct.
> >
> > I think there's a bug in MemoryUsageSetting: The comment for streamCache says
> that it creates "an instance of ScratchFile using the current settings". However, the line
> >
> > public final StreamCacheCreateFunction streamCache = () -> new ScratchFile(this);
> This is a functional interface. No instance of ScratchFile is created
> when creating an instance of MemoryUsageSetting. It is created once the
> functional interface is used.
> 
> > is executed at the start of the constructor of MemoryUsageSetting before the
> instance variables have been set. At least that's what the bytecode output from javap
> -c -p says:
> >
> >    private org.apache.pdfbox.io.MemoryUsageSetting(boolean, boolean, long, long);
> >      Code:
> >         0: aload_0
> >         1: invokespecial #1                  // Method java/lang/Object."<init>":()V
> >         4: aload_0
> >         5: aload_0
> >         6: invokedynamic #2,  0              // InvokeDynamic
> #0:create:(Lorg/apache/pdfbox/io/MemoryUsageSetting;)Lorg/apache/pdfbox/io/Rand
> omAccessStreamCache$StreamCacheCreateFunction;
> >        11: putfield      #3                  // Field
> streamCache:Lorg/apache/pdfbox/io/RandomAccessStreamCache$StreamCacheCreate
> Function;
> >        14: iload_2
> >
> I can't read the byte code but I've double checked the behaviour when
> debbugging one of our test cases
> 
> org.apache.pdfbox.multipdf.PDFMergerUtilityTest.testJpegCcitt()
> 
> Fortunately everthing is fine ;-)
> 
> Andreas
> 
> > I think the initialization of ScratchFile needs to happen at the end of the constructor
> if the settings are supposed to be used.
> 
> 
> 
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> > For additional commands, e-mail: users-help@pdfbox.apache.org
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org


Re: [ANNOUNCE] Apache PDFBox 3.0.0 released

Posted by Andreas Lehmkühler <an...@lehmi.de.INVALID>.
Hi,

@Erik thanks for the report but I guess there is a misunderstanding, see 
inline

Am 18.08.23 um 11:32 schrieb Brangs, Erik:
> Hi,
> 
>> -----Ursprüngliche Nachricht-----
>> Von: Andreas Lehmkühler [mailto:andreas@lehmi.de.INVALID]
>> Gesendet: Freitag, 18. August 2023 07:42
>> An: users@pdfbox.apache.org
>> Betreff: [ANNOUNCE] Apache PDFBox 3.0.0 released
>>
>> The Apache PDFBox community is pleased to announce the release of Apache
>> PDFBox 3.0.0. It is available for download at:
>>
>> https://pdfbox.apache.org/download.html
>>
>> [...]
>>
>> A migration guide is available at
>>
>> https://pdfbox.apache.org/3.0/migration.html.
>>
>> It is still a work in progress and we are happy to include any valuable
>> feedback from our community.
> 
> I was going to suggest to update the documentation to say that you can use the streamCache field of MemoryUsageSetting rather than using IOUtils. However, I've looked at the code of MemoryUsageSetting and I'm not actually sure if that's correct.
> 
> I think there's a bug in MemoryUsageSetting: The comment for streamCache says that it creates "an instance of ScratchFile using the current settings". However, the line
> 
> public final StreamCacheCreateFunction streamCache = () -> new ScratchFile(this);
This is a functional interface. No instance of ScratchFile is created 
when creating an instance of MemoryUsageSetting. It is created once the 
functional interface is used.

> is executed at the start of the constructor of MemoryUsageSetting before the instance variables have been set. At least that's what the bytecode output from javap -c -p says:
> 
>    private org.apache.pdfbox.io.MemoryUsageSetting(boolean, boolean, long, long);
>      Code:
>         0: aload_0
>         1: invokespecial #1                  // Method java/lang/Object."<init>":()V
>         4: aload_0
>         5: aload_0
>         6: invokedynamic #2,  0              // InvokeDynamic #0:create:(Lorg/apache/pdfbox/io/MemoryUsageSetting;)Lorg/apache/pdfbox/io/RandomAccessStreamCache$StreamCacheCreateFunction;
>        11: putfield      #3                  // Field streamCache:Lorg/apache/pdfbox/io/RandomAccessStreamCache$StreamCacheCreateFunction;
>        14: iload_2
> 
I can't read the byte code but I've double checked the behaviour when 
debbugging one of our test cases

org.apache.pdfbox.multipdf.PDFMergerUtilityTest.testJpegCcitt()

Fortunately everthing is fine ;-)

Andreas

> I think the initialization of ScratchFile needs to happen at the end of the constructor if the settings are supposed to be used.



> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


AW: [ANNOUNCE] Apache PDFBox 3.0.0 released

Posted by "Brangs, Erik" <E....@dnb.de>.
Hi,

> -----Ursprüngliche Nachricht-----
> Von: Andreas Lehmkühler [mailto:andreas@lehmi.de.INVALID]
> Gesendet: Freitag, 18. August 2023 07:42
> An: users@pdfbox.apache.org
> Betreff: [ANNOUNCE] Apache PDFBox 3.0.0 released
> 
> The Apache PDFBox community is pleased to announce the release of Apache
> PDFBox 3.0.0. It is available for download at:
> 
> https://pdfbox.apache.org/download.html
> 
> [...]
> 
> A migration guide is available at
> 
> https://pdfbox.apache.org/3.0/migration.html.
> 
> It is still a work in progress and we are happy to include any valuable
> feedback from our community.

I was going to suggest to update the documentation to say that you can use the streamCache field of MemoryUsageSetting rather than using IOUtils. However, I've looked at the code of MemoryUsageSetting and I'm not actually sure if that's correct.

I think there's a bug in MemoryUsageSetting: The comment for streamCache says that it creates "an instance of ScratchFile using the current settings". However, the line 

public final StreamCacheCreateFunction streamCache = () -> new ScratchFile(this);

is executed at the start of the constructor of MemoryUsageSetting before the instance variables have been set. At least that's what the bytecode output from javap -c -p says:

  private org.apache.pdfbox.io.MemoryUsageSetting(boolean, boolean, long, long);
    Code:
       0: aload_0
       1: invokespecial #1                  // Method java/lang/Object."<init>":()V
       4: aload_0
       5: aload_0
       6: invokedynamic #2,  0              // InvokeDynamic #0:create:(Lorg/apache/pdfbox/io/MemoryUsageSetting;)Lorg/apache/pdfbox/io/RandomAccessStreamCache$StreamCacheCreateFunction;
      11: putfield      #3                  // Field streamCache:Lorg/apache/pdfbox/io/RandomAccessStreamCache$StreamCacheCreateFunction;
      14: iload_2


I think the initialization of ScratchFile needs to happen at the end of the constructor if the settings are supposed to be used.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org