Using iTextSharp (4.1.6) in a Xamarin.Forms app.
I have lines of data with CRLF at the end of each. I put these into paragraphs, which I add to the doc. At then end of many, I add to the doc one or more images (photos). Works great.
Now, I'd like to have a page break after the last image, so I get a fresh start.
But iText seems to be flowing the text around the image some, and sometimes I don't get that page break, at last not where I want it. The next paragraph follows immediately after the image.
I tried adding a small paragraph after the image, but this did not solve. I did find that adding a SECTION seems to cause a good break, but puts some text in that I don't want or need.
I don't seem to find anything like API documentation for this, I've been just working from examples.
It seems like this would be really easy. What am I doing wrong?
iText seems to be flowing the text around the image some
Indeed, if you add an image to your document which does not fit on the current page anymore (but there still is some place for text on that page), iText does not immediately start a new page but keeps the image in memory and waits for your next content additions. If you then add text, that text first fills the current page, and only if even text does not fit anymore (or if you add another image), a new page is started and the waiting image is added.
You can switch this off using for your PdfWriter writer using
writer.StrictImageSequence = true;
Related
I have two things I have been using, neither of which are keeping the image/table exactly where I placed it within the text in R markdown when knitted to a pdf.
![caption](path) will place the image where there is space on the page. That is, if the page has space, the image will print between the desired text. However, if the page does not have the space, the text is placed to fill the page and then the image awkwardly inserts itself in the middle of the paragraph on the next page.
I am having a similar problem with my kable tables. I have tried using latex_options = 'hold_position', but this seems to only keep my tables from grouping together.
Is there a way to have my table stay between the text that I want? So if it needs to start a whole new page, to fit it, it can without trying to fill the space with the text below.
Thank you in advance.
Is it possible to detect the end of page in creating PDF file with PDFsharp library? How? Or overflowing text on page? I am generating PDF file with list of users and if the list is too long, I need to add new page and continue on it. I don't want to write ugly code, I want it to be as automatic as possible.
I am aware of MigraDoc library, but I already have a lot of code written in PDFsharp, so if it's not necessary to use MigraDoc (which seems to be better), I would rather stay with PDFsharp. Thanks.
When using PDFsharp, you are responsible to detect the end of page and create a new page for the continuation.
We always say that PDFsharp is low level: no automatic page breaks, but anything can be drawn anywhere.
Still you can write clean code with PDFsharp that handles page breaks properly.
You always have a current page, a current gfx, and a current y position on the page. So when you have to start a new page, re-initialize those variables.
I have a map that is 40x50 that shows when the visitor comes to the website, i would like the visitor to click the map which puts in topmost actual size 400x500 and everything beneath is blacked out, when they click off the pic it will simply vanish.
I have seem it happen in many galleries but can't seem to find one i can recode and don't even know what the actual process of doing this is called.
I believe the word you're looking for is lightbox.
See this: http://lokeshdhakar.com/projects/lightbox2/
By the way, tags are for tagging what languages you are using. Appropriate tags for this post would probably be html and javascript. The image tag is alright, but without context, it's difficult to figure out how your are trying to implement it.
i have an html file and i'm using Itext 2 with flying Saucer to convert it to a pdf file.
The problem is that if an image starts near the page end, flying saucer render a portion of it it the end of the current page and the rest in the beginning of the next page.
How to say that i want the entire image on one page only?
You can add this to your print css:
img {
page-break-inside: avoid;
}
The user guide (PDF) mentions it.
There appears to be a bug in FlyingSaucer that is causing issues with page-break-inside: avoid.
The issue manifests when css: orphans kicks in, when a paragraph is laid out towards the end of a page and the minimum number of lines cannot be rendered on the page. Then the block box layout state machine appears to go wrong.
We have pushed a fix to a fork here: https://github.com/krokiet/flyingsaucer/tree/master
At some point we will raise a pull request to get this merged back into the main code base.
I have the same problem but
img {page-break-inside: avoid;}
is not the final solution. Yes it has impact for result and in some situations it works but not always.
Here is some more details about the same or similar problem.
Similar problem
My PDF consists of a number of blocks (actually, a list of quotations), they go one after another till the end of the document. If the text of a quotation
does not fit on the page, the whole quotation should start from the top of the next page, instead of being torn apart. How can I implement that on any library under ruby?
Try PrinceXML - this is a standalone executable that generates PDF out of HTML or XML. It supports a lot of special CSS properties that will even help you to control page breaks. Refer to http://www.princexml.com/doc/6.0/page-breaks/
This application is available for windows and linux. I was using it for generation of a pretty complicated PDF documents with headers and footers on every page except first one. And since you don't need to output a PDF with precise positioning of elements, it might be a perfect solution for you.
I haven't tried it, but in Prawn I would try using either the Document#text_box method or looking up the table methods and putting your text in cells with invisible borders. The documentation's unclear on how page break functionality fits in with the bounding box models, but it's worth a shot.
HTMLDoc which converts HTML to PDF has a page break facility.