GlenKPeterson / PdfLayoutManager

Adds line-breaking, page-breaking, tables, and styles to PDFBox
45 stars 20 forks source link

Float.max vs Math.max, and Float.hashCode(floatA) vs floatA.hashCode() #1

Closed peterdietz closed 9 years ago

peterdietz commented 10 years ago

Hi Glen,

I was digging in to your project since I need to do more with PDFBox in terms of creating a PDF. So, I'm hoping your project can go further (integrated upstream maybe?).

Anyways, I got some compile errors while trying to use it. Float.max(floatA, floatB) method doesn't exist. I replaced this with Math.max(floatA, floatB)

Also, there is no method Float.hashCode(floatA), I instead changed float floatA to Float floatA, and then used floatA.hashCode()

I don't know if versions of Java matter here. I'm on JDK7

GlenKPeterson commented 10 years ago

Hi Peter,

I probably used JDK 8.0_05 to compile it. I specified the compiler source and target as 1.5, but that must mean the syntax (source) and bytecode (target). It must have still compiled against whatever version of the Java standard libraries were on my machine. That makes sense, now that I think about it. Thanks for bringing it to my attention!

If you submit a patch (or whatever that's called on GitHub), I can install an older JVM and try it out on the weekend. Actually, you described your changes well enough that I don't even need a patch!

Yes, this code may be integrated with PDFBox some day but the path to that is currently unclear.

Thanks for the feedback! I hope it works well for you. If you do find other issues, I hope you'll share them. I've been meaning to post the jar to MavenCentral. Maybe I'll try to do that this weekend too.

GlenKPeterson commented 10 years ago

OK, I just built it with jdk1.6.0_45, fixed all the errors, verified that the test PDF looks good, and pushed my changes. If you do a pull and a rebuild under Java 7 it should be a snap.

I also fixed up the JavaDoc and did the whole packaging, GPG signing, and opened a ticket to request that it be added to the Sonatype Central Maven repository. Hopefully, in a few days you will be able to get it already built from there just by specifying it as a dependency in your POM file.

Thanks for your interest and your feedback! Please continue to let me know how it works for you.

GlenKPeterson commented 10 years ago

If I were in the PDFBox group, I'd try to incorporate extras that were being actively used my many people who didn't work together. So you are already helping to move this project in that direction!

peterdietz commented 10 years ago

Great, thanks for being responsive, the latest pull fixed this up. In terms of route forward for people trying to get things done using PDFBox, my vote would be that a developer should be able to create a PDF using it without too much fuss. i.e. Want to add a string, Want to add a string that word-wraps, Want to add a table, want to add an image?

Publishing this as a jar on maven central would be a good idea, the project I work on is on Sonatype. And then if you had a quick-start / example-usage / cookbook on this project's readme/wiki, of how to include PDFBox and PdfLayoutManager, such that a developer could add a word-wrapped string, table, image, etc. That would have to get the ball rolling, as this becomes a route to solving needs, easily. There's so many Stack Overflow posts for PDFBox for how do I add word-wrapped-text, table, image, and the answers are typically gigantic code blocks. Eventually incorporating this, and turning it from copy/paste Q/A posts, to reusable code (in maven) would be great too.

Thanks again

GlenKPeterson commented 10 years ago

Glad that at least the build is working for you. Great suggestion! I just added this to the ReadMe:

The unit tests may be monolithic, but they provide a good usage example: https://github.com/GlenKPeterson/PdfLayoutManager/blob/master/src/test/java/TestPdfLayoutMgr.java

If you are building from source anyway, you might want to try running mvn javadoc:javadoc

I put some effort into the JavaDocs, though more effort would be better. I used to have the javadocs posted on a web site, but I since decided not to renew that whole site. Not sure where to put them now.

Which project on Sonatype are you considering PdfLayoutManager for?

peterdietz commented 10 years ago

I work on the DSpace (institutional archive) project. I'm adding a cover page to uploaded PDF's. https://github.com/DSpace/DSpace/pull/678

I was only able to add a basic level of content to that, using PDFBox, out of the box. If it were easier to add more content to that page, such as logo/image, then I might add that. The above solution isn't using PdfLayoutManager features, since I didn't want to copy in 20+ classes, but adding another dependency to maven would be fine.

One place to put your docs could be https://pages.github.com/, I think you can copy the output javadocs to there.

GlenKPeterson commented 10 years ago

Well, I think I just deployed PdfLayoutManager to the Sonatype repository because I can see it here: https://oss.sonatype.org/content/repositories/snapshots/com/planbase/pdf/PdfLayoutManager/0.2.1-SNAPSHOT/

This is the dependency to use:

    <dependency>
        <groupId>com.planbase.pdf</groupId>
        <artifactId>PdfLayoutManager</artifactId>
        <version>0.2.1-SNAPSHOT</version>
    </dependency>

Let me know how it goes.

DSpace looks like a cool project! PdfLayoutManager should work well for that. Everything you need to do should be demonstrated in the first page of the unit test I linked to earlier, but I'm happy to help if you have questions.