Ah! Got it! :-)

That bit of debug it spat out indicated a problem with what I was passing from 
Lucee into the overlay() call.

It turns out that a regular Lucee/CFML struct defined with numeric keys are 
actually strings! So it couldn't figure out what to do with the keys (structs 
are Maps in the Java world).

What I've ended up doing is creating a LinkedHashMap (which is compatible with 
the Map<Integer,String> type for overlay())

<cfset local.guide = createObject("java", "java.util.LinkedHashMap").init()>

And then using the put() method on the object with a cast Integer as the key 
and a string (the overlay path) as the value:
<cfset local.guide.put(javaCast("integer", local.i+1), arguments.overlay_path)>

And lo and behold, the overlay() call no longer errors and I get what I wanted.

I couldn't be more delighted!

Thank you Tilman, for the verbose version and the help! Who knew Lucee was so 
finicky! ;-)

--
Mike
________________________________
From: Michael Horne <m...@thecasecentre.org.INVALID>
Sent: 11 July 2025 08:51
To: users@pdfbox.apache.org <users@pdfbox.apache.org>
Subject: Re: Problem with using Overlay - specific pages

[You don't often get email from m...@thecasecentre.org.invalid. Learn why this 
is important at https://aka.ms/LearnAboutSenderIdentification ]

Interesting!
That version throws an error:
class java.lang.String cannot be cast to class java.lang.Integer 
(java.lang.String and java.lang.Integer are in module java.base of loader 
'bootstrap')

at Overlay.java, line 132.

I wonder if there's something fundamentally problematic about data types in the 
Lucee part and the non-verbose version just ignores it and throws its hands up 
and says "no"?

--
Mike
________________________________
From: Michael Horne <m...@thecasecentre.org.INVALID>
Sent: 11 July 2025 08:40
To: users@pdfbox.apache.org <users@pdfbox.apache.org>
Subject: Re: Problem with using Overlay - specific pages

[You don't often get email from m...@thecasecentre.org.invalid. Learn why this 
is important at https://aka.ms/LearnAboutSenderIdentification ]

Got it. Thanks Tilman!
Will let you know if I manage to figure out how to see the debug! 🙂
--
Mike
________________________________
From: Tilman Hausherr <thaush...@t-online.de>
Sent: 11 July 2025 08:35
To: users@pdfbox.apache.org <users@pdfbox.apache.org>
Subject: Re: Problem with using Overlay - specific pages

[You don't often get email from thaush...@t-online.de. Learn why this is 
important at https://aka.ms/LearnAboutSenderIdentification ]

Hi,

Use this version:
https://repository.apache.org/content/groups/snapshots/org/apache/pdfbox/pdfbox-app/3.0.6-SNAPSHOT/pdfbox-app-3.0.6-20250711.072333-59.jar

please tell when you've downloaded it so that revert these changes.

Tilman

On 7/11/2025 8:53 AM, Michael Horne wrote:
> Hi Tilman,
> That is the call I'm making, yes.
>
> Oooh. Interesting! I've just tried with the command line version documented 
> here:
> https://pdfbox.apache.org/3.0/commandline.html
>
> and THAT works nicely. I can create a new PDF with specific pages overlaid.
> So it IS capable of doing what I want, but only from the command line. But 
> it's the same JAR. Confusing!
>
> Which kinda leads me to think I'm doing something specifically wrong in the 
> Lucee/CFML version.
>
> Hmm. I'm unsure how to make a verbose snapshot.
>
> I think I'll try using Maven (https://docs.lucee.org/recipes/maven.html) 
> rather than the direct JAR and see if that produces a different result.
>
> Thanks for your help thus far. Will come back with some results if I can make 
> it do what I want!
>
> --
> Mike
> ________________________________
> From: Tilman Hausherr <thaush...@t-online.de>
> Sent: 10 July 2025 19:46
> To: users@pdfbox.apache.org <users@pdfbox.apache.org>
> Subject: Re: Problem with using Overlay - specific pages
>
> [You don't often get email from thaush...@t-online.de. Learn why this is 
> important at https://aka.ms/LearnAboutSenderIdentification ]
>
> Here's what I could do:
> I'd create a verbose snapshot version that will tell whether it was
> called at all and what pages were handled.
>
> I assume you're using this call:
> public PDDocument overlay(Map<Integer, String> specificPageOverlayMap)
>
> The output would look like this (that's from the unit test)
>
> specificPageOverlayMap:
> {1=pdfbox\src\test\resources\org\apache\pdfbox\multipdf\rot0.pdf,
> 2=pdfbox\src\test\resources\org\apache\pdfbox\multipdf\rot90.pdf,
> 3=pdfbox\src\test\resources\org\apache\pdfbox\multipdf\rot180.pdf,
> 4=pdfbox\src\test\resources\org\apache\pdfbox\multipdf\rot270.pdf}
> specificPageOverlayLayoutPageMap:
> {1=org.apache.pdfbox.multipdf.Overlay$LayoutPage@7f5c94e6,
> 2=org.apache.pdfbox.multipdf.Overlay$LayoutPage@761fc90d,
> 3=org.apache.pdfbox.multipdf.Overlay$LayoutPage@493f56b,
> 4=org.apache.pdfbox.multipdf.Overlay$LayoutPage@3620308c}
> processing page: 0
> processing page: 0, done
> processing page: 1
> processing page: 1, done
> processing page: 2
> processing page: 2, done
> processing page: 3
> processing page: 3, done
>
>
> Tilman
>
> On 7/10/2025 7:27 PM, Michael Horne wrote:
>> Sorry, yes that would help.
>>
>> I'm on 3.0.5 and I'm using the app JAR file.
>>
>> I can't really - my Java knowledge is appalling. I could maybe cobble it 
>> together but not sure it'd be very accurate!
>>
>> Mike
>>
>> Sent from Outlook for Android<https://aka.ms/AAb9ysg>
>> ________________________________
>> From: Tilman Hausherr <thaush...@t-online.de>
>> Sent: Thursday, July 10, 2025 6:09:26 PM
>> To: users@pdfbox.apache.org <users@pdfbox.apache.org>
>> Subject: Re: Problem with using Overlay - specific pages
>>
>> [You don't often get email from thaush...@t-online.de. Learn why this is 
>> important at https://aka.ms/LearnAboutSenderIdentification ]
>>
>> Hi,
>>
>> Please tell what PDFBox version you're using. Are you able to simulate
>> the calls without using Lucee and what happens then? Are you using a jar
>> file or are you using maven?
>>
>> Tilman
>>
>>
>> ---------------------------------------------------------------------
>> 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

Reply via email to