Am 06.06.2017 um 18:15 schrieb Bharat Bhatt:
Hi,

Is it possible to achieve tab feature in PDF using PDFBox?

No, that is Java GUI programming. You can use PDFBox to fill the JPanel objects of your JTabbedPane.

Here's some code fill a JPanel:

    private static JPanel getTestPanel()
    {
        final PDDocument doc;
        try
        {
           doc = PDDocument.load(...);
        }
        catch (IOException e)
        {
            e.printStackTrace();
            return null;
        }
        final PDFRenderer renderer = new PDFRenderer(doc);
        JPanel panel = new JPanel()
        {
            int i;

            @Override
            protected void paintComponent(Graphics g)
            {
                try
                {
                    g.setColor(Color.red);
                    g.fillRect(0, 0, getWidth(), getHeight());
                    PDPage page = doc.getPage(0);
                    PDRectangle cropBox = page.getCropBox();
                    boolean rot = false;
if (page.getRotation() == 90 || page.getRotation() == 270)
                    {
                        rot = true;
                    }

// https://stackoverflow.com/questions/1106339/resize-image-to-fit-in-bounding-box float imgWidth = rot ? cropBox.getHeight() : cropBox.getWidth(); float imgHeight = rot ? cropBox.getWidth() : cropBox.getHeight();
                    float xf = getWidth() / imgWidth;
                    float yf = getHeight() / imgHeight;
                    float scale = Math.min(xf, yf);
                    if (yf < xf)
                    {
g.translate((int) ((getWidth() - imgWidth * yf) / 2), 0);
                    }
                    else
                    {
g.translate(0, (int) ((getHeight() - imgHeight * xf) / 2));
                    }
renderer.renderPageToGraphics(pageNum-1, (Graphics2D) g, scale);
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
        };
        return panel;
    }

It is based on code posted to
https://issues.apache.org/jira/browse/PDFBOX-3359
by Ivan Ridao Freitas <https://issues.apache.org/jira/secure/ViewProfile.jspa?name=ivanrf>.

Tilman




Thanks,
Bharat

On Tue, Jun 6, 2017 at 9:37 PM, Tilman Hausherr <[email protected]>
wrote:

Am 06.06.2017 um 18:04 schrieb Bharat Bhatt:

Hi,

Its Tabs, like browser tabs.  So when I click on heading of tab then
content of tab should be displayed.

Is there any example for reference?

Oh, sorry. No, we don't have an example. That sounds like a java GUI
question.

https://docs.oracle.com/javase/tutorial/uiswing/components/tabbedpane.html

Tilman



Thanks,
Bharat

On Tue, Jun 6, 2017 at 9:09 PM, Tilman Hausherr <[email protected]>
wrote:

Am 06.06.2017 um 12:16 schrieb Bharat Bhatt:
Hi,
Assuming that with "tabs" you mean "tables" and not "tab stops":
I want to renders different tabs in PDF. If I click on any tab content of
that tab should be displayed.

If you are able to click on a content, then it is displayed, obviously.
Because if it weren't, then you wouldn't be able to see it to click on
it.

If you mean making some content visible by clicking on some checkbox,
this
is very advanced and probably needs javascript. The best would be to
create
a prototype of this with Adobe Professional and then replicate the effect
with PDFBox, i.e. by assigning the contents into the structures.

Tilman

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Reply via email to