When I display text file (text/plain) in iframe, it always in wordwrap mode (without horizontal scrollbar) How I can display text file in iframe without wordwrap?
Related
Assuming I print a small amount of text into a PDF document, I like to know how much of the page is actually used by the text.
For example, if I render a short text paragraph into a PDF document, I like to learn the content height of only that text, not of the entire A4 (letter) page.
Background
I need to render a long HTML page into a PDF document that uses a smaller page size. The result is that the content gets rendered into several PDF pages. I currently use NSPrintOperation for this.
The challenge is that I also need to render a footer page into each page. For this, I need to dynamically determine the height of that footer so that I can set the page's bottom margin accordingly, resulting in the footer area be kept free when rendering the main (body) HTML content. Once that's finished, I can then add the footer to each page in a separate step (using CGPDFDocument).
I wish there was a simpler way, but it seems that the macOS HTML renderer cannot handle html footers when printing multiple pages.
I found a solution, though that's a bit ugly:
Generate the PDF with the footer content, so that it renders at the top of the page (margins set to 0).
Read the PDF into NSPDFImageRepMBS
Create a NSImageMBS and add the imageRep to it with addRepresentation:
Now the image has a size of the original PDF page, but contains only the drawable region of the footer content - the rest of the image is clear.
By scanning the image's lines from bottom towards the top, looking for a non-clear line, the height of the footer content can be determined.
With the footer height known, I can now render the main content to a PDF with the bottom margin set to keep free the footer area
Finally, I create a new CGPDFDocument, going over each page of the main PDF, drawing thes main pages along with the footer (offset into the page's footer area) into each page.
I am looking for a GUI control element to store a multiline text. TextArea textArea works fine, but it has a border and doesn't fit textArea to text size unless some broilierplate code is added to compute int rowCount to set textArea.setPrefRowCount(rowCount).
Other options like Label don't support copiable text.
What is the most suitable way to display selectable, non-editable text without a scrollbar/empty rows?
Is it possible to somehow make "find" (ctrl+f) work if you are writing text inside a Canvas?
I checked out the basic examples at https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Drawing_text and when searching for "hello world" in chrome the canvas text is not hilighted.
Is there anyway of doing this?
If there isn't, has anyone seen an implementation of a "box-and-lines" chart (like UML) only using the DOM? (since then native find text would be supported)
Html5 Canvas paints text on its canvas -- the text you see is an inaccessible set of pixels arranged in the shape of letters, so Ctrl-f will not find the text. If you want searchable text you can use CSS to place html divs over the canvas and set their content to your desired text. Then Ctrl-f will find it. You can set pointer-events: none on the div so it doesn't catch events you intend for the canvas.
One wild (and not recommended) workaround is to put an element off-screen containing all your text. When Ctrl-f finds something in that element, you can fetch the selected text and calculate where you painted that same selected text on the canvas. Then you can redraw the selected text on the canvas as white-on-blue text to indicate that it was "found". This wild workaround is totally not recommended, but it would probably work
I would like to align 2 images wrapped with text but I haven't found any way to do it or any post that could help.
Something like this:
text text text text text image1
text text text text text image2
text text text text text text t
text text text text text text t
You could place it in a table, or like Wesley Murch said, you can use the CSS float and clear properties (float:right;clear:right;) to move it to the right of the page and prevent text from appearing to the right of the images.
<img src="image_that_may_or_may_not_load.png" alt="Show this text if image not loaded" />
Safari doesn't seem to show 'alt' text in case the image is not loaded. I'm not sure about other browsers, but Firefox does show the alternate text.
Its so important to display alt text in email templates where the images would be blocked by the client most likely, atleast until the user accepts to "display images from this user/site".
Any workaround for this?
Thanks
So it turns out, setting width and height for the image will show alt text incase the image is unavailable, not otherwise.
Try use the title attribute.
<img src="image_that_may_or_may_not_load.png" alt="Show this text if image not loaded" title="Show this text if image not loaded" />
Apparently from here: Alt text showing in IE and firefox but not in safari?. Safari doesn't support it.