Background
I've a document that I build up throu various steps.
In one of these steps I add content to a Document from a chapter structure I've built containing the content.
This part in particular is very simple. It simply adds the content to the document.
Sometimes my structure specifies there should be a page break, and thus document.NewPage(); gets executed. This works, usually.
We are using ITextSharp version 5.3.2.0. ( A few month old or so)
The problem
When document.NewPage() get's executed and is very close to the end of the document or perhaps just entered a new page I am guessing, I get an empty page with the rest of my content being added on the following page.
Only having the Document to work with at this point I can not seem to find a way how to determine if document.NewPage() should be skipped or not to work around this bug or issue.
Thanks
This can be caused by three things:
You're using a very old version of iTextSharp. If so, please upgrade to a more recent version of iTextSharp. We don't fix obsolete versions.
You're using page events and contrary to what is advised in the documentation, you're adding content in the onStartPage() method.
You're using writer.setPageEmpty(false); which is kind of asking iText to consider an empty page as not being empty.
In all other cases, the newPage() method is ignored if you're currently on a page that doesn't have any content.
Related
I have a block of markup I use to link to the next and previous pages. I would like this markup to appear both before and after a table of data.
Is there a way to define this markup only once but show it twice, without using a partial view?
I seem to remember MVC having some sort of page subroutine that creates markup and could be called from anywhere in the page. But I don't recall the syntax for this and can find it anywhere online.
You're looking for #helper, but it's not supported in ASP.NET Core for reasons explained here.
Right at the end of this discussion, there's a comment that they've added support for HTML code in #functions blocks. There's an example there too. But that commit was just on March 14, 2019, so it may not have made it to any released version yet. (maybe when ASP.NET Core 3 is released?)
But if that's not available, you could just use a function in #functions that returns a string of HTML using Html.Raw(), like the answer here.
I am creating an ASP.NET app in Visual Studio 2013 which has about 12 pages. However, in one of the page's aspx page in VS, when I save or auto format the page it will insert/create hundreds of empty lines. Most recently it has managed to create over 300,000 lines.
I keep deleting these lines, which is quite time consuming because the lines are spread throughout the code, but they just keep getting inserted.
This bug does not occur on any other page, the only thing that is different about this page is that it uses a DevExpress ASPxPageControl, but I'm not sure how that would have anything to do with it.
I have tried deleting the page and copying the code over to a new page, but the same bug keeps occuring. Does anybody have any idea how I would go about fixing this bug?
UPDATE: I have created another page which also uses the DevExpress ASPxPageControl and it has started to happen on this as well. So I am assuming that this issue has to do with the control.
UPDATE 19/09: This issue no longer happens, but I have no idea why or how it has been fixed.
UPDATE 06/12: The issue appears to happen only when design view is opened. If I only ever look at the source view, it never happens.
There is a question that looks like the same problem you have.
Try checking if you are missing any closing tags.
I work on an MVC application that generates reports from rdlc files. Particularly, i have a WS that generates a PDF document with one or more DataSources with a single page rdlc file.
Now my problem is : the customer wants to add a page between each page, only if a certain condition is satisfied. I can modify my rdlc file to add this document, but i can't get it to show only certain times...
I've tried playing with visibility, page breaks but it doesn't work. I've even thought about generating each page independently and merging it in one PDF file.
What would be a clean way to do it ?
If you have all your page-breaking set correctly, which you claim you did, you could wrap the extra page inside a Rectangle where you define an expression for the hidden property.
When this rectangle becomes hidden the entire page shouldn't be rendered.
If you need help with defining the expression you'll have to share a lot more information but this shouldn't really be a problem to achieve by yourself.
I am facing a pesky problem at the moment on a large website with multiple languages. On arrival at the website, it detects what country you are from and prompts you to confirm this. On confirmation, it swaps out the pages languages from the DB and displays the relevant language. This is done using jQuery. Now the problem is that Arabic reads rtl, so I need to either:
-- swap out the stylesheets for "rtl" version
or
-- change the HTML tag and include a "dir='rtl'" arrtribute
Now, I have tried both of these, with failures on both. When I view the page source, it still shows the old Css file or HTML tag without the "dir" attribute. Correct me if I'm wrong but I believe this to be due to the DOM not registering the new changes, as they have happened asynchronously via jQuery after the DOM has been instantiated.
After all that blah blah and tldr;
Is there not an easier way to swap out the text direction dynamically? If this is a DOM issue, how can I reload the DOM after the asynchronous callback?
I have been at this issue for hours now and have had very little luck on the interwebz.
Any and all help is welcome and greatly appreciated.
Kind Regards,
William Francis
EDIT:
After much investigation I found that the only way to truly work the Arabic way is with a post-back. Once the language has been selected you do a postback, then its just a simple process of changing the Stylesheet HREF attribute from code behind. There doesn't seem to be any form of JavaScript or jQuery that can change it without a post-back and still reflect the new Stylesheet. NOTE: you need to set the Stylesheet HREF on each post-back, i.e. through a master page. The Stylsheet changes do not persist across pages.
Here's a website that helped greatly and explains a whole lot on Stylesheet changes using JavaScript. sadly, it didn't work for me.
http://www.alistapart.com/articles/alternate/
There could be several things going on. I found this page to be very helpful when I was dealing with a similar thing, so I highly recommend it:
http://www.w3.org/International/tutorials/bidi-xhtml/
Also, if you aren't already doing so, use a tool like Firebug to examine the generated DOM after your AJAX has run to be sure you are seeing the altered state of the DOM and not the initial source of the page. It is possible to change the dir dynamically--you can use Firebug to add a new attribute to the HTML tag of this very page (set dir="rtl") to see it change dynamically. It could be some other element is overriding the direction, it could be that the AJAX changes aren't loading correctly, or other things. If you can post more of your code it would be helpful to give a better answer, but I hope this will help.
I have the requirement to create a page which contains a graph at the top, and for each item in the graph there's a fact sheet below. I already produce the fact sheets as stand-alone pages. Now, rather than recreating the fact sheet to include in the page I have to create, I'd like to use the work that already exists.
Is it realistic that I dynamically generate each fact sheet as needed, strip out the body and insert that into the new page? If so, does anyone have any pointers or suggestions? Thanks
I would suggest moving the content of the existing page into an ASCX user control - it should be a fairly quick job, and then you can incorporate it into other pages as required.
A quick way to implement this feature would be to use an iframe to load the other pages in to. This would allow you to keep using the work that already exists. Not the most elegant solution but it would work.
Hope this helps.
No, generating stuff you don't need and then removing it is inelegant at best, hackish, and will likely contribute to lowering the quality (including reliability, security etc.) of your code.
Refactor your factsheet page code to generate a header, but use a self-contained class/widget to generate the actual factsheet content. Then just instanciate and use that same class/widget on the other page as well.