I am using xslfo to generate PDF from my XML file, but whenever I edit something in my source documents, it will impact on pagination of output, that cause some indexing issue that runs according to there appearance.
Are there any attributes or elements to handle or to fix this behaviour?
I assume you have the following situation:
Initially, a page is almost filled with text.
The text is edited and becomes longer. Now it doesn't fit on one page any more.
You want to know if there's a way to automatically change the formatting so the text will fit on one page again.
Unfortunately you can't do this with XSL-FO alone. As far as I know, there is no way to specify "this block of text has to fit on one page, and if it doesn't fit, make the font size smaller until it fits".
You'd have to do some post-processing, along the line of 'count the pages in the PDF, if the page count is larger than X, change a variable in the FO template to make the text smaller and render again'.
Related
I have a BrowseSupportFragment with multiple pages which are VerticalGridSupportFragments. The relevant code for this is essentially in this file here.
Sometimes these pages or VerticalGridSupportFragments don't have content to show. I'd like to display a brief message or image explaining this, but I cannot find how to modify the layout to include this text. I have found where I can add text and images to the Activity, but is there a way to make the text a part of the fragments individually rather than the activity?
I have a header, a body, and a footer set up for an Xsl Fo page sequence. There are certain items displayed on this page in blocks with a keep-together.within-page value of 1. This works really well for the most part, but I've noticed that when stuff that will span an entire page or more absolutely has to break it will end up on a new page and then get cut (which is fine) but then the header gets drawn in the middle of this making everything look a little gross/confusing (not fine) as whatever remains is drawn onto the next page.
So I'm wondering, is there some way to suppress the header on content overflow into the next page?
Or is there some way with alternative page sequences or something to achieve what I want?
Sorry for the vagueness here, and a lack of a current working representation of what's going on. I am very new to Xsl Fo, and most of our working code is under an abstracted framework, but if I knew of the correct directives or if this was possible I'm sure I could implement them into the framework and get things working.
Edit: I have attached a picture to hopefully clarify what is going on
You could put the content that you want to hide in an fo:marker and use fo:retrieve-marker in the fo:static-content that flows into the 'region-before' region.
The trick is to put a copy of the 'real' fo:marker before each of the blocks with the keep-together and also put an empty fo:marker with the same marker-class-name as the first thing inside the block. (I don't know what your XSL-FO markup is like, but you may need to put an fo:wrapper around each block as a place to put the 'real' marker.)
If retrieve-position is first-including-carryover (see https://www.w3.org/TR/xsl11/#retrieve-position), then you should get an empty fo:marker for blocks that broke across the page boundary and get the 'real' fo:marker on other pages.
I try to integrate docmosis into my product, using the docmosis-java.
I’ve encountered an issue where there is a Java object that contains a member with huge text.
I have declared a repeating-row in my template (as I may have more than one instance from this type). In this case, the text (which is huge, contains many pages) appears partially in the report; only a single page is shown; it seems that instead of wrapping to the next page, to show the rest of the text, it is cut hence invisible in the report.
This is my template:
As mentioned, when “getBody()” return HUGE text, it is not visible in the report – only the first page of it.
Any ideas?
It looks like your template is using a table. If so, you should check that your table allows the rows to break across pages. If this is disabled, it is likely to produce only partial results since you have said the row must be on a a single page.
Does that help?
We are developing an application which takes the user input as Html and render the same Html as output in a different page. And the input should never have any dynamic behaviour in it like script tags.
We Html Encode the value in Javascript and save the encoded value in DB. We Html Decode the saved value and render it in the new page to get the expected result(check below example).
From what I have read so far, I should Html Encode the input before rendering it as output in a different page. The problem I am facing in this is that whatever the Html added by user is displayed the same in the new page
Example:
User Input:
<div><h2>Header</h2><p>this is the body text</p></div>
Output in the new page when Html encoded and assigned it to another div:
<div><h2>Header</h2><p>this is the body text</p></div>
Expected:
Header
this is the body text
The only way I was able to achieve the expected result was when I Html decoded the saved value and assigned it to another container control.
Am I missing something, I tried all the ways I am aware of Html Encoding the user input and rendering it back is not giving me the expected result. Any idea on how to achieve this?
If there is no other solution, is there any validation framework in .net available to avoid XSS attacks. I have went through AntiXSS framework from microsoft they are more for stripping any harmfull html and encoding. They do not help in letting the user know that they should not be entering some tags.
Thanks for any help in advance.
If the user input is HTML, and you encode it before saving it, then when you display it, you should decode it.
The reason the recommendation exists to encode before displaying is if the user input is expected to be text, it is recommended to encode for general display purposes (so that an ampersand actually displays as &) and also to prevent potentially malicious input from being rendered on the page and interpreted by the browser (e.g. <script> tags).
Please be careful: If you are intending to display HTML that is provided by a user that you try to sanitize the input as much as possible -- make sure they aren't trying to do anything malicious and also to make sure they don't make a simple mistake that could wreck the entire layout of a webpage (e.g. have an opening tag without a closing tag). This type of sanitation is no simple task and one of the major factors why other flavors of markup exist in the first place (e.g. Mark Down, BBCode, etc.).
#Brian Ball has answered the question, but I feel some further explanation is warranted.
The many and varied encoding protocols are context-specific.
As I understand it, the only point of HTMLencoding (as opposed to other encoding protocols like URIencoding etc) is to allow text to be rendered by a browser 'as is' if it contains elements that otherwise would be parsed as HTML (e.g. the characters & < > / and double and single quotes). The endcoding 'hides' these characters from the browser's HTML parser.
So really, the only place HTMLencoding serves any purpose is at the point of preparing the text to be rendered by a browser. There is no purpose served by HTMLencoding user-entered text that is heading for a database. You may need to use other encodings for transmission, for ensuring appropriate handling by server-side languages, etc., but HTMLencoding has no place in these contexts.
In your situation, it is the very fact that you previously HTMLencoded the content that is preventing it from being rendered as HTML when you later retrieve it from the database. The encoding is doing exactly what it is meant to.
So the simple answer is,
a. there's no point HTMLencoding the user-entered data before saving it to your database, and
b. if you want it rendered as HTML rather than printed to the screen 'as is', do not HTMLencode it at the point of displaying it on another page.
I'v done a tree view in xsl using a javascript function
I want to change the icons depending on the status (+ for to open , - for to close)
This questions is as clear as thick molasses in a pool of mud. (Will try to answer, though.)
I assume you mean XML stylesheets with xsl. If you meant Excel, it should have been xls. But let's assume you mean stylesheets and you're using it to generate a webpage which contains a treeview. In this treeview there are icons indicating if the node is expanded or not. If expanded, display +, else display -. Am I right, here?
Now, it depends on how you've implemented this treeview in your stylesheet. The most practical way would be to just send the tree data fully expanded to the page and let the Javascript handle this client-side. In that case, all you need to know is how to expand and collapse nodes in Javascript with the additional icon change.
Another possible implementation would be when expanding and collapsing is done serverside, thus you'd only send the visible data. In that case you can also just tell the page which icon to use and there would be no need for any javascript. The icon would just be a link back to the server, updating the data through a new requests which builds a new webpage.
A third option would be the WEB 2.0 solution, where you just send the list as a collapsed treeview and every time the user clicks an icon, a AJAX event gets triggered, collecing the additional node data and changing the icon of the treenode.
These are three very different techniques and they're not always the best solution. The first solution is a problem when dealing with lots of data in your tree. It needs to load it all. The second option will generate a lot more traffic with the server but handles better with large amounts of data because you only display the open node. The third option is a bit of a mixture between the first two options. You don't need all data from the beginning and you're not recreating the webpage over and over again. But it's also more complex to code.
Now, I wonder which of these options you use. Once we know this, we can help you. (Edit your question to provide this information and perhaps even add the JavaScript tag to it.)
To be honest, xsl is only used to change the shape of an XML document and it knows nothing about treeviews or whatever. So I don't see any link between xsl and treeviews. It's just that you use xsl to transform your data into something that some Javascript library can process as a treeview. Which Javascript library is this?