|
tmiklos67 wrote: but it does'n work. Can anybody help me? Maybe. But you'll need to explain what you mean by "it doesn't work".
/ravi
|
|
|
|
|
The code product no output (file). I'm not sure, but I think the problem is how the file handler passing as pointer...
|
|
|
|
|
In your C code you have:
ctx = fz_new_context(NULL, NULL, FZ_STORE_DEFAULT);
doc = fz_open_document(ctx, "c:\test\test.pdf");
In your C# you have:
var context = NativeMethods.NewContext(IntPtr.Zero, IntPtr.Zero, FZ_STORE_DEFAULT);
var stream = NativeMethods.OpenFile(context, @"c:\test\test.pdf");
var document = NativeMethods.OpenDocumentStream(context, ".pdf", stream);
var context = fz_new_context(IntPtr.Zero, IntPtr.Zero, FZ_STORE_DEFAULT);
var stream = fz_open_file_w(context, @"c:\test\test.pdf");
var document = fz_open_document_with_stream(context, ".pdf", stream);
Why the difference?
|
|
|
|
|
Very good observation. The C code is working and the C# don't.
Maybe this is the solution and I don't need to use the OpenDocumentStream.
Thanks, I will try your tipp.
|
|
|
|
|
My email is:- vivek.1370@gmail.com
And second iemail is:- vivekpalmailbox@gmail.com
private void ExportToWord()
{
int s1;
for(s1=0;s1<3;s1++)
{
string strForPrint = "";
//first student detail
strForPrint += " S.J.S. PUBLIC SCHOOL" + "\n";
strForPrint += "An English Medium Co-educational School Based on C.B.S.E. Curriculum" + "\n\n\n\n\n";
pic_logo_sjs.Image.Save("E:\\myimage\\myimage.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
Word.Application wordApp = new Word.Application();
wordApp.Visible = false;
Word.Document doc = wordApp.Documents.Add();
doc.InlineShapes.AddPicture("E:\\myimage\\myimage.doc");
// strForPrint += richTextBox1.Text + "\r\n";
strForPrint += " REPORT BOOK" + "\n";
strForPrint += " Session 2014-2015" + "\n\n";
strForPrint += "Student Name : " + txt_stu_name.Text + "\r\t\r\t\r\t";
strForPrint += "Roll No : " + txt_roll.Text + "\n\n";
strForPrint += "Class : " + txt_class.Text + "\t";
strForPrint += "Section : " + txt_section.Text + "\t";
strForPrint += "Scholar No : " + txt_scholar.Text + "\r\n\r\n\r\n";
strForPrint += "Date Of Birth : " + txt_dob.Text + "\r\n\r\n\r\n";
strForPrint += "Mother's Name : " + txt_mother.Text + "\r\n\r\n\r\n";
strForPrint += "Father's Name : " + txt_father.Text + "\r\n\r\n\r\n";
strForPrint += "Address : " + txt_address.Text + "\r\n\r\n\r\n\n\n\n\n";
strForPrint += "Tear here line-----------------------------------------------------------" + "\r\n";
//second student detail
strForPrint += " S.J.S. PUBLIC SCHOOL" + "\n";
strForPrint += "An English Medium Co-educational School Based on C.B.S.E. Curriculum" + "\n\n\n\n\n";
strForPrint += " REPORT BOOK" + "\n";
strForPrint += " Session 2014-2015" + "\n\n";
strForPrint += "Student Name : " + txt_name1.Text + "\t\t\t";
strForPrint += "Roll No : " + txt_roll1.Text + "\r\n\r\n";
strForPrint += "Class : " + txt_class1.Text + "\r\t";
strForPrint += "Section : " + txt_section1.Text + "\r\t";
strForPrint += "Scholar No : " + txt_scholar1.Text + "\r\n\r\n\r\n";
strForPrint += "Date Of Birth : " + txt_dob1.Text + "\r\n\r\n\r\n";
strForPrint += "Mother's Name : " + txt_mother1.Text + "\r\n\r\n\r\n";
strForPrint += "Father's Name : " + txt_father1.Text + "\r\n\r\n\r\n";
strForPrint += "Address : " + txt_address1.Text + "\r\n\n";
//First student marks
strForPrint += Exam_I_Term.Text + "\n\n";
strForPrint += "\r\t\r\t" + label1.Text + "\n\n";
strForPrint += lbl_sub.Text + "\r\t" + lbl_english.Text + "\r\t" + lbl_evs.Text + "\r\t" + lbl_hindi.Text + "\r\t" + lbl_math.Text + "\r\t" + lbl_total_marks.Text + "\r\t\n\n";
strForPrint += lbl_marks.Text + "\r\t\r" + lbl_fa_1_english.Text + "\r\t\r\t" + lbl_fa_1_evs.Text + "\r\t\r\t" + lbl_fa_1_hindi.Text + "\r\t\r\t" + lbl_fa_1_math.Text + "\r\t\r\t" + lbl_fa_1_total.Text + "\r\t\r\t\n\n";
strForPrint += lbl_grade.Text + "\r\t\r\t\r\t\r\t\r\t\r\t\r\t\r\t\r\t\r\t" + lbl_fa_1_grade.Text + "\r\n\n";
strForPrint += lbl_attendance.Text + "\r\t\r\t\r\t\r\t\r\t\r\t\r\t\r\t\r\t" + lbl_fa_1_attendance.Text + "\r\n\n\n\n";
strForPrint += lbl_dash_teacher.Text + "\r\t\r\t\r\t\r\t\r\t\r\t" + lbl_dash_principal.Text + "\r\n";
strForPrint += lbl_teacher_signature.Text + "\r\t\r\t\r\t\r\t\r\t\r\t" + lbl_principal_signature.Text + "\r\n\n\n";
strForPrint += "\r\t\r\t\r\t\r\t" + lbl_grading_norm_index.Text + "\r\n\n";
strForPrint += lbl_A_outstainding.Text + "" + lbl_B_Excellent.Text + "" + lbl_C_very_good.Text+ "\r\n\r\n";
strForPrint += lbl_D_good.Text + "\r\t\r\t\r\t" + label3.Text + "\r\n\n\n\n\n\n\n";
//second student marks
strForPrint += Exam_I_Term1.Text + "\n\n";
strForPrint += "\r\t\r\t" + label1_1.Text + "\n\n";
strForPrint += lbl_sub1.Text + "\r\t" + lbl_english1.Text + "\r\t" + lbl_evs1.Text + "\r\t" + lbl_hindi1.Text + "\r\t" + lbl_math1.Text + "\r\t" + lbl_total_marks1.Text + "\r\t\n\n";
strForPrint += lbl_marks1.Text + "\r\t\r" + lbl_fa_1_english1.Text + "\r\t\r\t" + lbl_fa_1_evs1.Text + "\r\t\r\t" + lbl_fa_1_hindi1.Text + "\r\t\r\t" + lbl_fa_1_math1.Text + "\r\t\r\t" + lbl_fa_1_total1.Text + "\r\t\r\t\n\n";
strForPrint += lbl_grade1.Text + "\r\t\r\t\r\t\r\t\r\t\r\t\r\t\r\t\r\t\r\t" + lbl_fa_1_grade1.Text + "\r\n\n";
strForPrint += lbl_attendance1.Text + "\r\t\r\t\r\t\r\t\r\t\r\t\r\t\r\t\r\t" + lbl_fa_1_attendance1.Text + "\r\n\n\n\n";
strForPrint += lbl_dash_teacher1.Text + "\r\t\r\t\r\t\r\t\r\t\r\t" + lbl_dash_principal1.Text + "\r\n";
strForPrint += lbl_teacher_signature1.Text + "\r\t\r\t\r\t\r\t\r\t\r\t" + lbl_principal_signature1.Text + "\r\n\n\n";
strForPrint += "\r\t\r\t\r\t\r\t" + lbl_grading_norm_index1.Text+ "\r\n\n";
strForPrint += lbl_A_outstainding1.Text + "\r\t" + lbl_B_Excellent1.Text + "\r\t" + lbl_C_very_good1.Text + "\r\n\r\n";
strForPrint += lbl_D_good1.Text + "\r\t\r\t\r\t" + label3.Text + "\r\n\n";
label2.Text = "hello.......";
label2.ForeColor = Color.Green;
Encoding utf16 = Encoding.GetEncoding(1254);
byte[] output = utf16.GetBytes(strForPrint);
FileStream fs = new FileStream(sfd.FileName, FileMode.Create);
BinaryWriter bw = new BinaryWriter(fs);
bw.Write(output, 0, output.Length); //write data into file
bw.Flush();
bw.Close();
fs.Close();
}
}
private void button1_Click(object sender, EventArgs e)
{
sfd.Filter = "Word Documents (*.doc)|*.doc";
if (sfd.ShowDialog() == DialogResult.OK)
{
ExportToWord();
}
}
|
|
|
|
|
Where are you stuck?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
The only people who are interested in your email addresses in a public forum are spammers. Nobody is going to email you directly except them.
|
|
|
|
|
I have three mouse events hooked up to an image control. (MouseLeftButtonDown, MouseMove, MouseLeftButtonUp).
I want to draw a rectangle by click - drag - release.
The Down and move events always do the trick, but only sometimes does the MouseLeftButtonUp event fire.
I don't know why.
What could be the problem?
[EDIT]Not solved yet, but if I release very quickly after a move it works, when I'm too slow, it doesn't.[/EDIT]
[SOLUTION]
This is somewhat weird. The workflow is that on MouseDown I create a Rectangle and ad it to the Canvas control.
In Mousemove I update this rectangle to follow my cursor. When I release the button, the cursor is on the Rectangle, not on the image. The solution is to add an event handler to the created rectangle and bubble it further to the image handler .
[/SOLUTION]
modified 30-Jul-14 5:41am.
|
|
|
|
|
Your mouse is f**ked?
Hardware problems aside, it's not at all obvious from that little exactly what is causing the problem - but you might be better off asking in the WPF forum[^] (for that I assume it to be) - it is not something I've seen in a WinForms app, which doesn't have those events anyway!
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
As a matter of fact, I just solved the issue the moment you replied.
I'll update the question
|
|
|
|
|
I've got to bookmark that one it is sure to come back and bite me on the arse sometime. It is so OBVIOUS when explained.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
tell me about it
|
|
|
|
|
Thanks in advance
I have an asp.net web application which integrates with Google API and oauth2 authentication. I have completed authentication part, now what I want really is , I need to display user's google drive files and folders in my application as it is listed in Google Drive and also I need to download files.
Need your help.
|
|
|
|
|
The documentation[^] seems to be a good place to start. The Children section seems like a reasonable bet.
|
|
|
|
|
I'm aware of at least two possibilities for reading directly from xls files:
- Microsoft.Office.Interop.Excel
- Microsoft.ACE.OLEDB.12.0 OleDB provider
From what little information I've been able to find on the subject, it seems that the Microsoft.Office.Interop.Excel method requires that Excel be installed on the system where this will be run. Is this true?
Basically, I want a reliable (read: can be run on any system Windows 7 or higher with or without office installed) to read data from an XLS or XLSX spreadsheet. I don't need to do any writing to the format, I just need to read from it and dump the data into a SQLite or SQL Server Compact database table.
Are there any methods other than those two I mentioned, and which would be the highest recommended method of doing what I need?
Thanks.
|
|
|
|
|
agent154 wrote: Is this true?
Yes. So I avoid it.
agent154 wrote: Microsoft.ACE.OLEDB.12.0 OleDB provider
That's my preference.
agent154 wrote: read from it and dump the data into a SQLite or SQL Server Compact database table.
That's the sort of thing that SSIS does.
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
Just an FYI since the other guy didn't mention it at all...
* Your first choice, of course requires that Excel be installed, but is a lot less work and is more platform independent.
* Your second choice does not... HOWEVER, and this is a BIG HOWEVER because if you don't know about this, you'll spend **weeks** trying to figure out what's going on... Microsoft ACE is the 64-bit driver. That's for a 64-bit OS and a 64-bit process **ONLY**. Won't run on a 32-bit OS or if your process is 32-bit. No big deal you're thinking, right? Not quite... if the machine happens to have 32-bit Office installed, you can't even install the 64-bit Ace driver, regardless of your OS because you aren't allowed to mix bitage. You have to install a different 32-bit driver and that limits your process to running as 32-bit because you can't use the 32-bit driver from a 64-bit process or vice versa.
This causes a lot of issues... you'd have to have a 32-bit build that uses the 32-bit driver if the machine has 32-bit Office installed and a 64-bit build that uses the 64-bit driver if the machine has 64-bit Office installed.
Most 64-bit machines I've seen have 32-bit Office installed... just sayin'... so you're limiting yourself to a 32-bit process.
|
|
|
|
|
AAAHHhhhh and they wonder why I dump on Office from a great height every opportunity I get. I hate having to deal with Office version incompatibilities, now you tell me the processor type may be an issue.
Ok so now I can see a benefit to the 32 bit OS policy I have been muttering about for some time.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
|
Both EPPlus[^] and ClosedXml[^] will allow you to read and write Excel 2007+ files (*.xlsx ).
If you need support for the older format files (*.xls ) as well, then NPOI[^] is pretty good.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
agent154 wrote: requires that Excel be installed on the system where this will be run.
What is the Business case where that matters?
If this is a client machine and the spread sheet is just a read only data store that comes with the application why not use a different format?
If a client machine where a user can modify the file then they would need excel anyways.
If a server machine then the situation is similar to the above but there should be less concern about cost.
|
|
|
|
|
Could someone elaborate on how the runtime determines where to allocate a variable (stack/heap)?
class MyClass()
{
int x;
}
private void AssignmentCheck()
{
MyClass mc = new MyClass();
mc.x = 10;
int MyInt = 5;
}
space will be allocated on the heap for the new instance of MyClass and the reference to the heap location will be saved to the variable mc.
mc.x is on the heap and MyInt will be on the stack.
My question is how does the runtime know to allocate space on the heap for MyClass and space on the stack for myInt ?
Does the runtime do some kind of type checking prior to assignment ?
i.e.
ok, MyClass is a ref type, I'd better put it on the heap
MyInt derives from System.ValueType and it's a local variable, I'd better put it on the stack.
Obviously an implementation detail but curious to know..
thx in advance
|
|
|
|
|
|
taking_liberties wrote: ok, MyClass is a ref type, I'd better put it on the heap
MyInt derives from System.ValueType and it's a local variable, I'd better put it on the stack. Obviously it can't do that, since not all instances of value types always go on the heap (for example, MyClass.x ).
The MSIL tells it what to do. Your example code was unfortunately a poor example, because int s are magic and therefore don't show how code with value types compiles in general.
So I changed the code a bit.
.maxstack 2
.locals init (
[0] class Test.Program/MyClass mc,
[1] valuetype Test.Vec2 v
)
IL_0000: nop
IL_0001: newobj instance void Test.Program/MyClass::.ctor()
IL_0006: stloc.0
IL_0007: ldloca.s v
IL_0009: initobj Test.Vec2
IL_000f: ldloc.0
IL_0010: ldloc.1
IL_0011: stfld valuetype Test.Vec2 Test.Program/MyClass::x
IL_0016: ret
This should make some things clear. A reference to a MyClass and an instance of Vec2 both conceptually go on the stack (that is, they are locals). The instance of MyClass is "newobj"-ed, while the instance of Vec2 is "initobj"-ed. newobj allocates an object and pushed a reference to it on the evaluation stack - not "the stack", this is just the stack that MSIL conceptually uses because it's a stack language, that's really just to connect instructions implicitly to their operands. "initobj" takes an address and zeroes out the fields of the value type there in-place.
When the JIT compiler gets its hands on this, it could do anything that preserves the semantics, and what it actually does, depends. In debug mode (ie ran in a debugger and Suppress JIT Optimizations is ON (default)) it really likes The Stack (the real deal, nothing conceptual at this point) and all locals are always written back to the stack even when they are then immediately read back. In optimized mode, most temporaries only appear in registers, and locals are often completely enregistered as well (unless it doesn't fit or they have to be preserved across a call). It seems to have a tendency to put non-primitive value types on the stack though. (other JIT compilers may behave differently, YMMV)
|
|
|
|
|
Thx. I'm assuming then that there is some kind of type-checking going on as newobj is called for MyClass ?
|
|
|
|