I am trying to understand what the process is of turning HTML into a PDF/Postscript programmatically
All Google searches turn up libraries to do this, but I am more interested in the actual process required.
I know you could just set up a Postscript printer and print directly to that, but some of these libraries appear to create the PDF on the fly to allow previews etc.
has anyone had any experience in this, or can provide any guidance?
I have a SQL Server 2000 database with a column of type VARCHAR(255). All the data is either NULL, or numeric data with up to two points of precision (e.g. '11.85'). I tried to run the following T-SQL query but received the error 'Error converting data type varchar to numeric'
SELECT CAST([MyColumn] AS DECIMAL)
FROM [MyTable];
I tried a more specific cast, which also failed.
SELECT CAST([MyColumn] AS DECIMAL(6,2))
FROM [MyTable];
I also tried the following to see if any data is non-numeric, and the only values returned were NULL.
SELECT ISNUMERIC([MyColumn]), [MyColumn]
FROM [MyTable]
WHERE ISNUMERIC([MyColumn]) = 0;
I tried to convert to other data types, such as FLOAT and MONEY, but only MONEY was successful. So I tried the following:
SELECT CAST(CAST([MyColumn] AS MONEY) AS DECIMAL)
FROM [MyTable];
...which worked just fine. Any ideas why the original query failed? Will there be a problem if I first convert to MONEY and then to DECIMAL?
Thanks!
Sorry, I'm new to flash I have this line of code:
BaseEntry( _entryList[i] ).topTeamName = ((Team)(teamList.getNameAtIndex( i*2 ))).Name;
and I get the error:
TypeError: Error #1034: Type Coercion
failed: cannot convert "[object Team]"
to ncaa.Data.Team.
What do I need to do to fix it?
Hi,
I made a small RGB to HSV converter algorithm with C. It seems to work pretty well, but there is one strange problem: If I first convert i.e. a 800x600 picture into HSV map and then back to RGB map without doing any changes in the values, I get some pixels that are convertet incorrectly. Then if I try to convert those misbehaving single pixels alone to and back, they're converted correctly. Any idea what could be the problem? I'm using Daniel Karlings PNGLite to open that PNG file.
Here are the source code of my main.c, rgbtohsv.c and rgbtohsv.h
rgbToHsv.h
rgbToHsv.c
pngmain.c
I linked pngmain only that if somebody wants to test and run this on his own system.
-zaplec
So I have this code:
p.Value = 1;
decimal avg = p.Value * 100 / 10000;
string prntout = p.Key + " : " + avg.ToString();
Console.WriteLine(prntout);
But the program prints out 0, instead of 0.01. p.Value is an int. How do I fix that?
Hi..
I have a hex string and i want to convert it utf8 to insert mysql. (my database is utf8)
hex_string = 'kitap ara\xfet\xfdrmas\xfd'
..
..
..
result='kitap arastirmasi'
How can i do that?
Best regards.
I'm writing a C# frontend to a legacy database that uses VB6 Rnd() and Randomize() methods for user password encryption. The encryption function is very simplistic and really not all that secure, but it's what all current passwords are stored with.
What I'd like to be able to do is authenticate legacy users from a C# application. I can write new encryption (or preferably hashing) code for VB6 so that all future users have a more secure password, and that can be duplicated in C#. But I don't want to require current users to have had their password reset before they can use the new frontend.
Is there any way I can reimplement that algorithm in C# so that it produces identical results to the legacy VB6 code?
I am looking for a small linux tool that would be able to extract text from odt file.
It just needs to be human-readable and it can have problems with complicated objects etc.
It's almost a duplicate of this question but I need it to be small and have no dependencies on OpenOffice or X server
I remember having a 1MB MS-DOS program that could render .doc files quite readibly (with some weird markup getting through from time to time), so i expect it to be possible in the linux world too ;)
I've got to convert a not terribly complicated bespoke project management system from MsAccess Application to PHP/MySQL. I've been programming for donkey's years but embarrassingly know practically nothing about modern methodologies.
So the old 'learning curve' versus 'improved efficiency' conundrum rears its ugly head once again.
Although I've Googled up some stuff I don't want to prejudice your suggestions, where would you start, I'm at your mercy?
I am trying to convert an ASF video with FFMPEG using an interface called mediahandler.
The issue is, the metadata on the ASF video appears to be corrupt. It states that the video is 640x240, and 4:3 aspect ratio.
The aspect ratio is correct, but obviously the resolution is not. This causes the converter to incorrectly scale the video, because it uses the resolution to determine the original aspect ratio.
I am able to get the aspect ratio metadata, but I'm not sure this solves the issue, because I would think that if the resolution could be incorrect, then so could the aspect ratio metadata.
So, is there any way to get the actual height/width? It appears that players like VLC have no issue with this. How do I do such a thing w/ FFMPEG?
hello
I'm trying to write an rss feed viewer for my iPhone. In my DetailView I have a UIWebView where I want to display specific link retrieved with the rss item.:
NSString* url = [data objectForKey:@"link"];
NSString *encodedUrl = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding ];
NSLog(@"Selected link:%@",url);
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:encodedUrl]];
[itemWebpage loadRequest:request];
[request release];
now,if the retrieved link is something like
www.shazaam.com
it works. But as soon as the link is something like:
http://www.shazam.com/music/web/track?id=41970148"
it doesn't. I suppose it's because of the parameter...but how can I fix the problem????
thanks a lot!
elos
I'm having trouble understanding the result of the following statements:
>>> from array import array
>>> array('L',[0xff,0xff,0xff,0xff])
array('L', [255L, 255L, 255L, 255L])
>>> from array import array
>>> array('L','\xff\xff\xff\xff')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: string length not a multiple of item size
Hi all, i need to generate the same number of text files as the xml files i have. Within the text files, i need the title and maybe some other tags of it. I can generate text files with the elements i wanted but not all xml files can be generated. Only some of them are generated. Something might be wrong with my parser so help out please thanks.
This is my code. Please have a look and give me suggestions. Thanks in advance.
import java.io.File;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.*;
import java.io.*;
public class AccessingXmlFile1 {
public static void main(String argv[]) {
try {
//File file = new File("C:\\MyFile.xml");
// create a file that is really a directory
File aDirectory = new File("C:/Documents and Settings/I2R/Desktop/test");
// get a listing of all files in the directory
String[] filesInDir = aDirectory.list();
System.out.println(""+filesInDir.length);
// sort the list of files (optional)
// Arrays.sort(filesInDir);
////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
// have everything i need, just print it now
for ( int a=0; a<filesInDir.length; a++ )
{
String xmlFile = filesInDir[a];
String newLine = System.getProperty("line.separator");
File file = new File(xmlFile);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document document = db.parse(file);
document.getDocumentElement().normalize();
//System.out.println("Root element " + document.getDocumentElement().getNodeName());
NodeList node = document.getElementsByTagName("metadata");
System.out.println("Information of Xml File");
System.out.println(xmlFile.substring(0, xmlFile.length() - 4));
////////////////////////////////////////////////////////////////////////////////////
String titleStoreText = "";
String descriptionStoreText = "";
String collectionStoreText = "";
String textToWrite = "";
////////////////////////////////////////////////////////////////////////////////////
for (int i = 0; i < node.getLength(); i++) {
Node firstNode = node.item(i);
if (firstNode.getNodeType() == Node.ELEMENT_NODE) {
Element element = (Element) firstNode;
NodeList titleElementList = element.getElementsByTagName("title");
Element titleElement = (Element) titleElementList.item(0);
NodeList title = titleElement.getChildNodes();
////////////////////////////////////////////////////////////////////////////////////
if(titleElement == null)
titleStoreText = " There is no title for this file."+ newLine;
else
titleStoreText = titleStoreText+((Node) title.item(0)).getNodeValue() + newLine;
//titleStoreText = titleStoreText+((Node) title.item(0)).getNodeValue()+ newLine;
////////////////////////////////////////////////////////////////////////////////////
System.out.println("Title : " + titleStoreText);
NodeList collectionElementList = element.getElementsByTagName("collection");
Element collectionElement = (Element) collectionElementList.item(0);
NodeList collection = collectionElement.getChildNodes();
////////////////////////////////////////////////////////////////////////////////////
if(collectionElement == null)
collectionStoreText = " There is no collection for this file."+ newLine;
else
collectionStoreText = collectionStoreText+((Node) collection.item(0)).getNodeValue() + newLine;
//collectionStoreText = collectionStoreText+((Node) collection.item(0)).getNodeValue()+ newLine;
////////////////////////////////////////////////////////////////////////////////////
System.out.println("Collection : " + collectionStoreText);
NodeList descriptionElementList = element.getElementsByTagName("description");
Element descriptionElement = (Element) descriptionElementList.item(0);
NodeList description = descriptionElement.getChildNodes();
////////////////////////////////////////////////////////////////////////////////////
if(descriptionElement == null)
descriptionStoreText = " There is no description for this file."+ newLine;
else
descriptionStoreText = descriptionStoreText+((Node) description.item(0)).getNodeValue() + newLine;
//descriptionStoreText = descriptionStoreText+((Node) description.item(0)).getNodeValue() + newLine;
////////////////////////////////////////////////////////////////////////////////////
System.out.println("Description : " + descriptionStoreText);
////////////////////////////////////////////////////////////////////////////////////
textToWrite = "=====Title=====" + newLine + titleStoreText + newLine + "=====Collection=====" + newLine + collectionStoreText + newLine + "=====Description=====" + newLine + descriptionStoreText;// + newLine + "=====Subject=====" + newLine + subjectStoreText;
////////////////////////////////////////////////////////////////////////////////////
}
}
///////////////////////////////////////////write to file part is here/////////////////////////////////////////
Writer output = null;
File file2 = new File(xmlFile.substring(0, xmlFile.length() - 4)+".txt");
output = new BufferedWriter(new FileWriter(file2));
output.write(textToWrite);
output.close();
System.out.println("Your file has been written");
////////////////////////////////////////////////////////////////////////////////////
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
Some code for context:
class a
{
}
class b
{
public a a{get;set;}
public static implicit operator a(b b)
{
return b.a;
}
}
a a=null;
b b=null;
a = b;
//compiler: cannot apply operator '==' to operands of type tralala...
bool c = a == b;
Is it possible to use == operator on different type instances, where one can implicitly convert to another? What did i miss?
Edit:
If types must be the same calling ==, then why
int a=1;
double b=1;
bool c=a==b;
works?
I get output files from very old Fortran programs, which look like:
0.81667E+00 -0.12650E+01 -0.69389E-03
0.94381E+00 -0.11985E+01 -0.11502E+00
0.96064E+00 -0.11333E+01 -0.17616E+00
0.10202E+01 -0.12435E+01 -0.93917E-01
0.10026E+01 -0.10904E+01 -0.15108E+00
0.90516E+00 -0.11030E+01 -0.19139E+00
0.98624E+00 -0.11598E+01 -0.22970E+00
Is it possible to read this in Python and convert the numbers to "normal" floats?
Hi,
I am trying to convert an integer number in C into an array containing each of that number's digits
i.e. if I have
int number = 5400
how can I get to
int numberArray[4]
where
numberArray[0] = 0;
numberArray[1] = 0;
numberArray[2] = 4;
numberArray[3] = 5;
Any suggestions gratefully received
--dave
I just started using C# and I've got a couple of issues.
I hook several controls to one event handler as in the following and I want to perform a slightly different action for each control:
Private Sub Button_Click(sender as Object, e as EventArgs) _
Handles button1.Click, Button2.Click
'do a general activity
Select CType(sender, Button).Name
Case button1.Name
'do something
Case button2.Name
'do something else
Case Else
'do the defalut action
End Select
End Sub
Is there any way of doing the above select statement in C# without having to use nested ifs?
Take the following class:
class mytype {
double num;
public:
mytype(int a) {
num = sqrt(a);
}
void print() {
cout << num;
}
}
Say there is a method which takes a mytype:
void foo(mytype a) {
a.print();
}
Is it legal c++ (or is there a way to implement this) to call foo(4), which would (in theory) output 2? From what I can glean you can overload type casts from a user defined class, but not to. Can constructor do this in a standards-compliant manner (assuming, of course, the constructor is not explicit). Hopefully there is a way to in the end have this legal:
int a;
cin >> a;
foo(a);
Note: this is quite obviously not the actual issue, but just an example for posting purposes. I can't just overload the function because of inheritance and other program-specific issues.
Hi,
I cannot initialize a non-const reference to type T1 from a convertible type T2. However, I can with a const reference.
long l;
const long long &const_ref = l; // fine
long long &ref = l; // error: invalid initialization of reference of
// type 'long long int&' from expression of type
// 'long int'
Most problems I encountered were related to r-values that cannot be assigned to a non-const reference. This is not the case here -- can someone explain? Thanks.
I’m looking for a solution to send DRY multipart emails in Rails. With DRY I mean that the content for the mail is only defined once.
I’ve thought about some possible solutions but haven’t found any existing implementations.
The solutions I’ve thought about are:
load the text from I18n and apply Markdown for the html mail and apply Markdown with a special output type for the text mail where
links are put in parenthesis after the link text
bold, italic and other formatting that doesn't make sense are removed
ordered and unordered lists are maintained
generate only the html mail and convert that to text according to the above conditions
Is there any available solution out there? Which one is probably the better way to do it?
Hey there, this is part of a question i got in class, im at the final stretch but this has become a major problem. In it im given a certain value which is called the "gold value" and it is 40.5, this value changes in input.
and i have these constants
const int RUBIES_PER_DIAMOND = 5; // relative values. *
const int EMERALDS_PER_RUBY = 2;
const int GOLDS_PER_EMERALDS = 5;
const int SILVERS_PER_GOLD = 4;
const int COPPERS_PER_SILVER = 5;
const int DIAMOND_VALUE = 50; // gold values. *
const int RUBY_VALUE = 10;
const int EMERALD_VALUE = 5;
const float SILVER_VALUE = 0.25;
const float COPPER_VALUE = 0.05;
which means that basically for every diamond there are 5 rubies, and for every ruby there are 2 emeralds. So on and so forth.
and the "gold value" for every diamond for example is 50 (diamond value = 50) this is how much one diamond is worth in golds.
my problem is converting 40.5 into these diamonds and ruby values. I know the answer is 4rubies and 2silvers but how do i write the algorithm for this so that it gives the best estimate for every goldvalue that comes along??
please help!, im at my wits end
Steps to produce this:
prompt>rails test_app
prompt>cd test_app
prompt>script/generate scaffold date_test my_date:datetime
prompt>rake db:migrate
now edit your app/views/date_tests/edit.html.erb:
<h1>Editing date_test</h1>
<% form_for(@date_test) do |f| %>
<%= f.error_messages %>
<p>
RIGHT!<br/>
<%= text_field_tag @date_test, f.object.my_date %>
</p>
<p>
WRONG!<br />
<%= f.text_field :my_date %>
</p>
<p>
<%= f.submit 'Update' %>
</p>
<% end %>
<%= link_to 'Show', @date_test %> |
<%= link_to 'Back', date_tests_path %>
now edit your config/environment.rb:
#add this
config.time_zone = 'Central Time (US & Canada)'
This recreates the problem I am having in my actual app. The problem with my app is that I'm storing a date in a hidden field and rendering a "user friendly" version. Creating a resource works fine but as soon as I try to edit it the time changes (it adds the difference between my current time zone configuration and UTC). go to http://localhost:3000/date_tests/new and save the time then go to reedit it and you will have two different representations of the date/time one which will save incorrectly and the other that will.
Hello,
How can I get java classes from an xml file?
In this situation, I don't have an XML schemma and this way I cant't use JAXB, Castor or other xml binding API as far as I know.