Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image AlignMent with added setAnchor #1102

Open
adityamauryaMog opened this issue Mar 15, 2024 · 2 comments
Open

Image AlignMent with added setAnchor #1102

adityamauryaMog opened this issue Mar 15, 2024 · 2 comments
Labels

Comments

@adityamauryaMog
Copy link

ClassPathResource classPathResource = new ClassPathResource(backgroundImage);
Image image = Image.getInstance(classPathResource.getURL());
image.setAbsolutePosition(0, 0);
image.scaleToFit(this.document.getPageSize().getWidth(),this.document.getPageSize().getHeight());
// Create a Chunk with the image
Chunk chunk = new Chunk(image, 0, 0, true);
chunk.setAnchor(new URL("http://www.example.com"));

    this.document.add(chunk);

when i direct add image to document it working fine , but when i added image with chunk to acheive anchoor effect then its Image towards left

@asturio
Copy link
Member

asturio commented Mar 16, 2024

So you have a Document with only one Chunk, and in the Chunk only one image.

Maybe working with a paragraph you can add the aligment to it.

Which version of OpenPDF are you using?

@asturio
Copy link
Member

asturio commented Mar 27, 2024

@adityamauryaMog have you find a solution for your problem? The normal is that Chunks are added from left to write, and from top to bottom. Probably that's why the Image in the Chunk is left-aligned.

@asturio asturio added question and removed bug labels Apr 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants