w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Printing contents of string-variable to local printer ASP.NET
Because of how web browsers are designed the server (your code) will not have direct access to the client's printer. Instead, you can have a link/button to a 'print page' or a page that only has the information you need (the contents of that list). The client can then print that page selecting their own local printer. You could include some javascript in the print page after the main body that will prompt the user to print. window.print() Should do what you want.

Categories : C#

Printing out contents of an array?
You need to override toString() method in SelectionSortArray something like this class SelectionSortArray { .... public String toString() { return String.valueOf(num); } } When you System.out.println your object, JVM will print toString() representation of the object If this method is not overridden, it will display the default toString() implementation of Object, which is classname@hexdecimal_code.

Categories : Java

ConcurrentModificationException when printing the contents of a vector
You created your iterator too early, before you even added anything to the Vector. Move this line: Iterator<Integer> itr = v.iterator(); to immediately before you use it in the last while loop: Iterator<Integer> itr = v.iterator(); while(itr.hasNext()){ ...and after you have finished modifying the Vector. The reason you saw a ConcurrentModificationException is that you modified the Vector while the Iterator existed.

Categories : Java

Can printf suspend after printing half the contents
printf ultimately calls write(). If the write() system call returns a -1 because the system call received EINTR, for example, then it is possible for some data to have been written. However, the tty (screen) is line buffered. This means nothing appears on the screen until a character is placed on the output stream. The EINTR would happen on a system that is being really hammered by I/O, for example. Because write() is not guaranteed to complete, it can be interrupted. So, I do not get what you are seeing. What problem do you see?

Categories : C

printing swt browser contents with Header and Footer
The only possible solution I can think of. Open a new Browser Get the text (browser.getText()) from the parent Browser Wrap it in your header and footer html Set the text (browser.setText()) on newly opened Browser Hide it - shell.setVisible(false) (Only if you don't want to show the popup) And invoke browser.execute("javascript:print()"); I suspect printing the content after hiding the Shell. But, you can give it a try!!

Categories : Java

Primefaces Printing Dynamic Streamed Contents
I used css to hide all other divs during print time and used window.print command. Print button <p:commandButton styleClass="noPrintBlock" ajax="false" value="Print" onclick="window.print();" actionListener="#{patientReportController.markAsPrinted()}" /> The component which I want to print. <p:panel styleClass="printBlock" id="divPrint" > </p:panel> Example of a component which I do not want to print <h:panelGroup styleClass="noPrintBlock"> </h:panelGroup> CSS @media print{ .noPrintBlock{ display: none; } .printBlock{ height: 100%; width: 100%; position: fixed; top: 0; left: 0; margin: 0; } }

Categories : JSF

Reading and printing file contents using Perl
You can use the glob feature in perl to get a list of filenames with the ".out" extension in the specified directory. You can then open these files one by one using a loop and print their contents to the screen. Here's the code, # get all file-names with ".out" extension into array my @outFiles = glob "/home/hclabv/*.out"; # loop through list of file names in array foreach my $outFileName ( @outFiles ) { # open the file for processing open $outFile, '<', $outFileName or die "Unable to open file for reading : $!"; # iterate through each line in the file while ( $line = <$outFile> ) { # print the individual line print "$line "; } # close the file close $outFile; } Please clarify what you mean by "including command lines", so we c

Categories : Perl

Printing Entire Contents of WebView in Cocoa, Not Just Displayed
I see that this is an old question, but since there aren't any answers yet, I thought I would provide this for anyone searching. NSPrintInfo *printInfo = [NSPrintInfo sharedPrintInfo]; // This is your chance to modify printInfo if you need to change // the page orientation, margins, etc [printInfo setOrientation:NSLandscapeOrientation]; NSPrintOperation *printOperation = [yourWebView.mainFrame.frameView printOperationWithPrintInfo:printInfo]; // Open the print dialog [printOperation runOperation]; // If you want your print window to appear as a sheet instead of a popup, // use this method instead of -[runOperation] [printOperation runOperationModalForWindow:yourWindow delegate:self did

Categories : Xcode

Printing table contents using Html::TreeBuilder::XPath
You need to process each table separately, same for rows: foreach my $table ( $tree->findnodes('//table') ) { foreach my $row ( $table->findnodes('.//tr') ) { my @cells = $row->findvalues('.//td'); print join(" ", @cells), " "; } print " "; } Of course this is solution only for simple tables (think about columnspans, th, table inside table etc.)

Categories : HTML

FormCollection to expandoObject
Well, not the most elegant code (probably better ways to do it), but one way could be something like this: [HttpPost] public ActionResult Test(FormCollection collection) { dynamic expando = new ExpandoObject(); var dictionary = (IDictionary<string, object>) expando; foreach (var item in collection.AllKeys.ToDictionary(key => key, value => collection[value])) { dictionary.Add(item.Key, item.Value); } // your expando will be populated here ... // do awesomeness } I hope this helps (at least it might give you an idea).

Categories : C#

Is it possible to query list of ExpandoObject?
Your suggestion is right, you would be able to query a collection of dynamic objects using the dot notation. var ids = generatedItems.Cast<dynamic>().Select(x => x.Id); However, keep in mind that there's no type safety here and, as you stated, IntelliSense is of no use, since you're using dynamic objects. If your code depends on whether one of those objects have an optional property (e.g., some have "Title", others don't), then it will require a little more manual labor. if((generatedItems as IDictionary<String, object>).ContainsKey("Title")) { }

Categories : C#

"'System.Dynamic.ExpandoObject' does not contain a definition for "PropertyName"
I gather this is expected behavior when using an ExpandoObject. I took a look at the IntelliTrace log for this code and the entries for the exceptions you are seeing are paired up: Exception:Thrown: "'System.Dynamic.ExpandoObject' does not contain a definition for 'clients'" (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException) Exception:Caught: "'System.Dynamic.ExpandoObject' does not contain a definition for 'clients'" (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException) i.e. The exception is being thrown and then caught. If you look at the Call Stack Window you will see that the throws and catches are within the .NET Framework. BTW, I did have to make a small change to your code to make it run: I changed: root.clients.client.Count to root.clients.Count in the for loop.

Categories : C#

How to modify file contents as string whilst having access to methods effecting lines within string?
Use a for-loop, a for-loop over a file object returns one line at a time. #use `with` statement for handling files, it automatically closes the file for you. with open('file.html') as fo, open('file1.html', 'w') as fo1: for line in fo: #reads one line at a time, memory efficient #do something with line, line.strip() fo1.write(line + ' ') #write line to to fo1 If you're trying to modify the same file then use fileinput module: import fileinput for line in fileinput.input('file.html', inplace = True): #do something with line print line #writes the line back to 'file.html' You can also get individual lines from file.read() as well, split it using: fo_as_string = fo.read() lines = fo_as_string.splitlines() But file.read() loads the

Categories : Python

Invert the order of a string, while preserving the original contents of the string
Split it into a list with str.split(), then print the reversed string with str.join(): >>> s = "31/12/9999" >>> L = s.split('/') # L now contains ['31', '12', '9999'] >>> print '/'.join(L[::-1]) # Reverse the list, then print all the content in the list joined by a / 9999/12/31 Or, in one line: >>> print '/'.join(s.split('/')[::-1]) However, if you're working with dates, you should use the datetime module so you can do other stuff later with the dates: >>> import datetime >>> s = "31/12/9999" >>> date = datetime.datetime.strptime(s, '%d/%m/%Y') >>> print date.strftime('%Y/%m/%d') 9999/12/31 Timing comparisons: $ python -m timeit 's = "31/12/9999"' "'/'.join(s.split('/')[::-1])" 1000000 loops, best of 3: 0.7

Categories : Python

Python how to retrieve list of changes by new additional contents, changes contents and deleted contents
I think you need to use difflib.Differ to do that: http://docs.python.org/2/library/difflib.html if you google "difflib.Differ Example" you'll find plenty of examples that will help you. edit: here's an example text1 = """Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer eu lacus accumsan arcu fermentum euismod. Donec pulvinar porttitor tellus. Aliquam venenatis. Donec facilisis pharetra tortor. In nec""" text1_lines = text1.splitlines() text2 = """Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer eu lacus accumsan arcu fermentum euismod. Donec pulvinar, porttitor tellus. Aliquam venenatis. Donec facilisis pharetra tortor. In nec""" text2_lines = text2.splitlines() import difflib d = difflib.Differ() diff = d.compare(text1_lines, text2_lines) print '

Categories : Python

How to get ServiceStack to serialize a dynamic (ExpandoObject) property on request
You may have seen this announcement: The next major v4.0 will also be a "breaking-release", with new features protected under an "AGPL/FOSS License Exception" and include a number of breaking changes that have built up over time, including upgrading all projects (to .NET 4+), major code and NuGet package re-factoring, clean-up and removal of deprecated code, better consistency / simplification of some concepts and implementation of some roadmap features I've been wanting to add but never had time for. Fixes and releases will continue to v3.x and be maintained in a separate v3 branch until v4.0 comes out of beta. As there's no reason to fix dynamic object support in the current 3.x branch, which doesn't support .Net4.0, the answer is 'No, ServiceStack can't serialize the JSON request

Categories : Json

How to use a lambda expression on an ExpandoObject C# to find an array element value?
I assume gifts is of the type List<Gift[]>. Then you would do: var test = ((List<Gift[]>)Model.moduleData.gifts).FirstOrDefault(item => item[index][0] == 99); The reason is that the type of gifts is not known at compile time, so the C# compiler has no way of resolving the type of lambda that's being specified.

Categories : C#

searching a string and printing the complete line containing that string
Only using strings could be faster: for line in all_blocks.splitlines(): if MAC in line: print(line) This gives you all the lines that the mac address is in, using regular expresssions: prog = re.compile('^.*' + re.escape(MAC) + '.*$', re.MULTILINE) lines = prog.findall(all_blocks)

Categories : Regex

How to convert continous XML to indented XML?
Load the text into an XDocument (see XDocument.Parse) and then use XDocument.ToString on the new instance.

Categories : C#

d3.js Indented tree with straight links
You're almost there. You need to use a normal line with a suitable interpolation, e.g. var line = d3.svg.line().interpolation("step") .x(function(d) { return d.y; }) .y(function(d) { return d.x; }); You may have to tweak the exact interpolation mode.

Categories : D3 Js

C - Not printing out the whole string
Read scanf(3) documentation. For %s is says s Matches a sequence of non-white-space characters; the next pointer must be a pointer to character array that is long enough to hold the input sequence and the terminating null byte (''), which is added automatically. The input string stops at white space or at the maximum field width, whichever occurs first. So your code is wrong, because it should have an array for studentName i.e. char studentName[32]; scanf("%s", studentName); which is still dangerous because of possible buffer overflow (e.g. if you type a name of 32 or more letters). Using %32s instead of %s might be safer. Take also the habit of compiling with all warnings enabled and with debugging information (i.e. if usin

Categories : C

Why does Python not allow my comments to be indented at the proper level?
The triple quotes are actually strings, not comments. So you need to indent the strings accordingly, (since every colon (:) must be immediately followed by an indented block)

Categories : Python

Lyrics API returns indented text, but how do I fix it for html?
I am not sure what are you trying to do, but try nl2br($text) to add html line endings and then use CSS to style it the way you want, other option is to put it in <pre></pre> tags and style the element.

Categories : PHP

Excel Create Collapsible Indented Row Hierachies
Create a Pivot Table. It has these features and many more. If you are dead-set on doing this yourself then you could add shapes to the worksheet and use VBA to hide and unhide rows and columns on clicking the shapes.

Categories : Excel

HTML/php header include only works when indented
This because your file encoding is currently (UTF8-BOM) try save it as (UTF-8) only. See this post also for more information: What's different between utf-8 and utf-8 without BOM?

Categories : PHP

Text indented on the right in PDFs generated with Prawn
Phone numbers are always indented on the right because in the text method is used :align => :right, so all strings of text aligned to the right. You could try to use text_box method with left alignment and put this box manualy on the page by defining indentation of its top-left corner from the top and right edges of the page (bounds.right and bounds.top values). Something like this (full working example): require 'prawn' require 'ostruct' p = OpenStruct.new( :telephone => "+1-201-555-2233", :email => "test@example.com", :url => "http://example.com") Prawn::Document.generate('simple_text.pdf', :skip_page_creation => true) do start_new_page text_box("#{p.telephone} #{p.email} #{p.url}", :at => [bounds.right - 100, bounds.top - 100], :align => :left, :height => 50

Categories : Ruby On Rails

Jquery not printing var as string
You are selecting the html elements in place of the value present in it. It should be this uname = document.getElementById("username").value.toString(); pword = document.getElementById("password").value.toString();

Categories : Jquery

Silverlight Printing string value
You can use PrintDocument.Print method and in PageVisual send a grid with text block ? Sample code in C# /// <summary> /// Text to print. /// </summary> private string _textToPrint; /// <summary> /// Method that print text. /// </summary> /// <param name="textToPrint">Text to print</param> /// <param name="documentName">Optional document name.</param> public void SendStringToPrinter(string textToPrint, string documentName = "My Document") { // Set print content in private property _textToPrint = textToPrint; // Create a new print dialog PrintDocument pd = new PrintDocument(); // Catch print event pd.PrintPage += onPrintPage; // Start print request pd.Print(documentName); } /// <summary> /// Called duri

Categories : String

Why it is printing reverse string?
You are using a multi-character literal 'ABC' to initialize an int. How the multi-character literal (which is an uncommon way of using '') is interpreted is implementation-defined. Specifically, the order of the individual characters in the int interpretation is implementation-defined. There is no portable (i.e. implementation-independent) way to predict what this program will do in terms of the order of the characters in 'ABC'. From the Standard (C++11, §2.14.3/1): [...] A multicharacter literal has type int and implementation-defined value.

Categories : C++

Printing formatted string in C
Very direct: printf("%5.3s ", Original + 4); ^ ^ | | | +--- precision, causes only 3 characters to be printed | +----- field width, sets total width of printed item Since right-adjusting is the default, you get the desired output. The precision "saves" us from having to extract the three characters into a properly terminated string of their own, very handy. You can use dynamic values for either precision or field width (or both, of course) by specifying the width as * and passing an int argument: const int width = 5, precision = 3; printf("%*.*s ", width, precision, Original + 4);

Categories : C

printing int array as string
Think about the way integers are represented - use a debugger if you must. Looking at the memory you will see plenty of 0 bytes, and %s stops when it reaches a 0 byte. It prints just a. That's why it prints just a. Afterwards it encounters a 0 byte and it stops.

Categories : C

How to get Contents from HTML string in Array
something like MatchCollection matches = Regex.Matches(HTMLString, "</ul>.*?<ul>", RegexOptions.SingleLine); foreach (Match match in matches) { String oddstring = match.ToString().Replace("</ul>","").Replace("<ul>",""); }

Categories : C#

string printing in an API server call but not outside of it
Check the top of the console. It looks like your logging the completion handler of an asynchronous operation, in which case, the order in which your log statements get called will look like this: NSLog(@"---RAN BADGE CALL---"); NSLog(@"2nd badge print %@",_badgeValue); NSLog(@"1st badge print %@",_badgeValue); "2nd badge print" might just be hiding above the JSON response.

Categories : IOS

Error when printing string.length
You cannot concatenate to a String with a Fixnum: >> "A" + 1 TypeError: can't convert Fixnum into String from (irb):1:in `+' from (irb):1 from /usr/bin/irb:12:in `<main>' >> "A" + 1.to_s => "A1" And, you don't need Name.to_s, because Name is already a String object. Just Name is enough. Convert the Fixnum (length) to String: puts "My name has " + Name.length.to_s + " characters." Or, as an alternative: puts "My name has #{Name.length} characters."

Categories : Ruby

Printing string text in C does not print
I think you are misunderstanding that code. The code you submitted writes a string "This is a test printing" to a file in the same directory called "lpt1". What you are probably wanting is to write out to something like "/dev/lpt1", and you should be able to test this by running echo "this is my printed text" >/dev/lpt1

Categories : C

Printing text after searching for a string
You can use string formatting here with the use of the str.format() function: def findFruit(f): found = re.search(r'.*? (.*?) Lemon (.*?) .*?$', f) if found is not None: print '"{}" # "{}"'.format(found.group(1), found.group(2)) Or, a lovely solution Kimvais posted in the comments: print '"{0}" # "{1}"'.format(*found.groups()) I've done some edits. Firstly, a for-loop isn't needed here (nor is a list comprehension. You're iterating through each letter of the string, instead of each word. Even then you don't want to iterate through each word. I also changed your regular expression (Do note that I'm not that great in regex, so there probably is a better solution).

Categories : Python

String array contents become null except the last index
appUsernames = new String[userDetails.length()]; appUserIDs = new String[userDetails.length()]; move the creation of the arrays outside the for loop try { JSONArray userDetails = json.getJSONArray("userDetails"); appUsernames = new String[userDetails.length()]; appUserIDs = new String[userDetails.length()]; for (int i = 0; i < userDetails.length(); i++) { JSONObject c = userDetails.getJSONObject(i); String name = c.getString("username"); String id = c.getString("id"); appUsernames[i] = name; appUserIDs[i] = id; Log.d("First", appUserIDs[i] + ": " + appUsernames[i]); } } catch (JSONException e) { e.printStackTrace(); }

Categories : Android

Convert ArrayList Contents to String with Commas
Just use ArrayList#toString(): public void getOptionsText() { String OptionsText = ListOptions.toString(); Options.setText(OptionsText.substring(1, OptionsText.length-1); }

Categories : Java

how to read the contents of a String with XML content and save it as an XML
Maybe I broke your question a little with the formation, however if your problems are only the qoutes you just need to mask them with a backslash that will look like that: String example = "My string with "quotes""; If your problem is primary about parsing the xml please read eebbesen's answer.

Categories : Java

Python 3: Store the contents of a file into one big string
You could use a regex, eg: import re with open('input') as fin: long_string = re.sub(r'W', '', fin.read()) # HelloWorldMynameisSamIam12yearsoldandaboyIlikePizza Note that W is equiv. to [^a-zA-Z0-9_] so you could change it to [^a-zA-Z0-9] if you wanted to be explicit about anything that's a non ascii letter/digit.

Categories : Python



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.