I am generating a pdf using itext. So when the content of a page exceeds it creates a new page automatically. I am trying to know if it created a new page. If yes I want to add some image on top of the page.
List paylist =new List(List.ORDERED, List.ALPHABETICAL);
paylist.setIndentationLeft(10);
paylist.add(new ListItem("Some text", yourfont));
document.add(paylist);
The content of the list will be dynamic. So I am unable to find whether its a new page it is in the same page. Suggestion please..
Subclass PdfPageEventHelper and bind an instance of it to your PdfWriter:
writer.setPageEvent(new YourCustomPageEventHelper());
Within that class there's a method called onStartPage that will be called for every page in your document. Use this to add an image to every page, then you don't have to worry about keeping tracking of things. See this page for a bunch of samples.
Check the page number before and after you add content to the document. If the value is different, then a new page has been created.
The page number is returned by the PdfWriter.getPageNumber() method.
Related
I'm new to Typo3.
Inside the Configuration section of my own Content element I need the ID or name of the Content element's page. How would you implement that?
I already tried to use flux:field.input but I dont know what to do with typoscript.
record.pid was the thing I was looking for!
<f:debug>{record}</f:debug>
i am using itext for generating pdf and want to know what happens behind the scene when an element exceeds the size of page.
i am using PdfPageEventHelper to get to know if a new page is added in this case.
resulting pdf shows a new page but don't trigger my functions for event such as onStartPage ,onEndPage.
I am using PdfPageEventHelper and I don't experience any problem with it. When a new page is triggered, the onEndPage() method is called before a new page is initialized, and the onStartPage() method is called after the new page is initialized.
You can trigger a new page in your code like this:
document.newPage();
Or the newPage() method can be triggered implicitly, for instance when you add content using document.add() that exceeds the size of the page.
Your allegation that the functions such as onEndPage() and onStartPage() aren't triggered can't be verified. On the contrary: we have plenty of examples that prove otherwise, some of which are bundled in the book The Best iText Questions on StackOverflow.
In the comments, you say that you have a question about the different between NEWPAGE and NEXTPAGE. This is a very strange question, as I don't know why you'd ever need these objects.
Chunk.NEXTPAGE is a special Chunk that is used internally by iText. It can be used to invoke the newPage() method by adding an object.
For instance:
document.add(Chunk.NEXTPAGE);
is the equivalent of:
document.newPage();
The latter method is the preferred way to trigger a new page, the NEXTPAGE object is used internally in very specific use cases.
As for Chunk.NEWPAGE, that's merely a String (it's value is "NEWPAGE"). This String is the attribute key used to identify a NEXTPAGE chunk.
This belongs to the internal kitchen of iText. As an iText user, you shouldn't worry about it.
When we create a new page in CQ5 'siteadmin' , we get two fields to fill up ("Name" and "Title").
Could there be any way to add more fields here (Say, "Description") which the authors can fill up and it will be saved as a JCR property of the page in CRX ?
Any ideas/solutions will be welcome. I can't think of any.
You want to add custom page properties. From the linked knowledge base article:
(1) Copy /libs/foundation/components/page/dialog node to your template's
component that you want to add dialog properties to.
(2) Add fields to the dialog
Example:
If you had a page component /apps/<myapp>/components/pages/contentpage
that has sling:resourceSuperType=/libs/foundation/components/page then
you would copy /libs/foundation/components/page/dialog to
/apps/<myapp>/components/pages/contentpage/ to make an overlaid dialog
My question is very basic . I am creating a new template and in that template, I will have a concrete structure using DIV elements. But in almost 7-8 if the DIV's, I need the data to be entered by the user.
What component/line of code I can use to have all those 7-8 DIV's editable and customizable by the page creator ?
I tried multiple paragraphs with :
<cq:include path="par" resourceType="foundation/components/parsys"/>
But only the top one appears on the page. !!
For having multiple paragraph just rename the path value in the cq:include tag. also check here
I 'm trying to build my own simple breadcrumb component that pushes a PageRefence onto a List for each and every Link in the application.
Unfortunately, setResponsePage() is final (I use wicket 6).
The only other option that comes to my mind is to add a parameter to my base page constructor. But this would require me to change every link in the app..
Are there any other options?
Since you already have a base page, it's easier to override onBeforeRender() in your base page to update the breadcrumbs list that you'd store in your Session object.
Or am I missing something?
To answer my own question:
In the end I realized, that I do not want to have the breadcrumb updated on each new page.
Therefore I created an object that holds a List of Pagereferences. When I navigate to a new Page, I take the list of the current page, make a copy of it an add the current page. The resulting list is pased onto the new page.
All this is handeld in the base page.
Keeping it in the page, avoids problems with multiple tabs / windows.
Thanks for the help.