|
|
|
I actually want to encrypt the processor ID and/or other hardware ID then convert it into a 24 character as a license key.
Technology News @ www.JassimRahma.com
|
|
|
|
|
Jassim Rahma wrote: want to encrypt
No, you want a hash.
|
|
|
|
|
I need to remove a handwriting signature from the pdf using itextsharp.
this handwriting signature can not be selected by mouse, i can access all the object buy this hand writing signature is not in the list of objects or signatures. how can i remove it?
here is part of my code to replace one of images. I need to replace image and signature.
public void ReplaceImage()
{
string pdfFilePath = Server.MapPath(".") + "/PDFFiles/Receipt.pdf";
string imageURL = Server.MapPath("/PdfImagesFiles") + "/img3.jpg";
string OutputFilePath = Server.MapPath("/PDFFiles/result.pdf");
PdfReader pdf = new PdfReader(pdfFilePath);
PdfStamper stp = new PdfStamper(pdf, new FileStream(OutputFilePath, FileMode.Create));
PdfWriter writer = stp.Writer;
var reader = new PdfReader(pdfFilePath);
var pdfContentByte = stp.GetOverContent(1);
iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(imageURL);
PdfDictionary pg = pdf.GetPageN(1);
PdfDictionary res = (PdfDictionary)PdfReader.GetPdfObject(pg.Get(PdfName.RESOURCES));
PdfDictionary xobj = (PdfDictionary)PdfReader.GetPdfObject(res.Get(PdfName.XOBJECT));
Document doc = new Document();
if (xobj != null)
{
foreach (PdfName name in xobj.Keys)
{
PdfObject obj = xobj.Get(name);
if (obj.IsIndirect())
{
PdfDictionary tg = (PdfDictionary)PdfReader.GetPdfObject(obj);
PdfName type = (PdfName)PdfReader.GetPdfObject(tg.Get(PdfName.SUBTYPE));
if (PdfName.IMAGE.Equals(type))
{
PdfReader.KillIndirect(obj);//remove the object
writer.AddDirectImageSimple(img, (PRIndirectReference)obj);//add new image
}
}
}
}
stp.Close();
}
A.Hakak
|
|
|
|
|
If the signature is not its own object, its part of another one.
Now you have a situation where the signature is an image, part of a bigger image. You cannot remove it using iTextSharp alone.
You'd get the object that it's a part of, export that, do some image editing to "paint over" the signature, then use iTextSharp to replace the image in the PDF with the edited one.
If you're trying to do this automated, you're going to have an extremely difficult time getting the code to identify the signature and, just as difficult, separating that from the line that the signature is on.
Good luck. You're going to need it as I can't find a single example of anyone doing this.
|
|
|
|
|
The following Function gets called by a program running on several station in a workgroup. The file resides on a shared resources. I need to make this routine network safe so only one station can read and write the file at a time. The other stations should just wait until the file is not in use. I assume I must attempt open the file for read write access and lock other users out of the file. Not sure how this is done in C#
private static string GetNextCounter(string destpath, string address, int port, String XMLString)
{
if (Directory.Exists(destpath + "\\" + address.Replace(".", "-")))
{
}
else
{
string registerRepsonse = register(destpath, address, port, XMLString);
};
string nextCounter = File.ReadAllText(destpath + "\\" + address.Replace(".", "-") + "\\Counter.xml");
int nextCounterInt = Convert.ToInt32(nextCounter);
nextCounterInt = nextCounterInt + 1;
File.WriteAllText(destpath + "\\" + address.Replace(".", "-") + "\\Counter.xml", nextCounterInt.ToString());
return nextCounterInt.ToString();
}
|
|
|
|
|
Open the file exclusively for writing, that way it would be locked. It is also the most wrong way of keeping a sequential number synchronized over multiple stations.
Install a database-server, use a primary key - that is the only good option. That eliminates mucking with file-locking, mucking with getting the network-resource and potential concurrency problems.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hello guys.
I have toolStrip1 and toolStrip2. I need it to c # code:
when tool.Strip1.Visible = false and toolStrip2.Visible = false (together both are visible = false), then:
textBox1.Location = new Point(3, 71);
textBox1.Width = 377;
textBox1.Height = 490;
label3.Location = new Point(3, 51);
How do I do? Thank you!
|
|
|
|
|
Where ever you change the visibility state...and we have no idea where that is, because we can't see your screen, access your HDD, or read your mind...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Are these controls added to the form at runtime? if so have you added them to the controls collection of where they are placed?
e.g.
Form1.Controls.add(textbox1);
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
Ehr..?
if (!toolStrip1.Visible && !toolStrip2.Visible)
{
textBox1.Location = new Point(3, 71);
textBox1.Width = 377;
textBox1.Height = 490;
label3.Location = new Point(3, 51);
}
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Thanks Eddy, that's it.Resolved.
|
|
|
|
|
Welcome to CodeProject !
If you are at a beginning level in programming WinForms and C#, you may want to consider asking questions in the C# QA Forum, rather than in this forum; I say this based on my observation that questions with very little information about the context (lack of code, lack of information about whether it's WinForms or ASP.NET or WPF, etc.) often get a better reception in QA.
And, please do, in any future questions, give more information about what you are working with, what you have tried, and what your overall goals are.
There's one tricky part about dealing with the VisibleChanged Event of the WinForms ToolStrip: it will be fired/triggered when your Application starts, and, in that first event, the 'Visible property of the ToolStrip will be 'false, even though you did not set that Property to 'false at design-time.
Unfortunately, this fire-on-Application-start behavior only happens with certain Controls.
Here's how you deal with the possibility that your code would execute when your Application launches"
1. define a Form scoped variable: private bool intializing = true;
2. in the Form Load EventHandler set it to 'false
private bool initializing = true;
private void Form1_Load(object sender, EventArgs e)
{
initializing = false;
} 3. define a VisibleChanged EventHandler for both your ToolStrip Controls: you can do this by selecting both of them, hitting F4 in Visual Studio to bring up the Property Browser, select Events, and click on 'VisibleChanged. Or, wire-them=up individually.
private void ToolStrips_VisibleChanged(object sender, EventArgs e)
{
if (initializing || toolStrip1.Visible || toolStrip2.Visible) return;
textBox1.Location = new Point(3, 71);
textBox1.Width = 377;
textBox1.Height = 490;
label3.Location = new Point(3, 51);
} The logic here tests for whether you are initializing, or whether either one of the two ToolStrips is visible, and, if that's true, exits: else it executes your code.
«OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. » Alan Kay's clarification on what he meant by the term "Object" in "Object-Oriented Programming."
|
|
|
|
|
Thank you very much. Resolved.
|
|
|
|
|
I want to save data send by GPS Device using TCP/IP Port.
I want to store that that data in my database.
help me....
Code IF Possible in Vb.net or C#
|
|
|
|
|
What is your problem and where did you stuck.Did you get the data from your GPS Device.If you get the data from GPS device whats your problem with saving to Database.
|
|
|
|
|
That is not a question on how to code something, but a request for a complete project.
heyvid wrote: help me. Only if you learn to code and intend to write this yourself.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
// Server
using System;
using System.Text;
using System.Collections.Generic;
using System.Net.Sockets;
namespace OurSpiffyServer_ConsoleApp
{
class Program
{
const int Port = YourPort;
static void Main(string[] args)
{
try
{
System.Net.IPAddress serverAddress = System.Net.IPAddress.Parse(Your IP);
TcpListener listener = new TcpListener(serverAddress, Port);
listener.Start();
TcpClient ourTCP_Client = listener.AcceptTcpClient();
NetworkStream ourStream = ourTCP_Client.GetStream();
byte[] data = new byte[ourTCP_Client.ReceiveBufferSize];
int bytesRead = ourStream.Read(data, 0, System.Convert.ToInt32(ourTCP_Client.ReceiveBufferSize));
Console.WriteLine("Received : " + Encoding.ASCII.GetString(data, 0, bytesRead));
Console.ReadLine();
}
catch (Exception e) { }
}
}
}
// Client
using System;
using System.Text;
using System.Collections.Generic;
using System.Net.Sockets;
namespace consoleTCPClient
{
class Program22
{
const int ourPort = yourPort;
static void Main1(string[] args)
{
TcpClient ourMagicClient = new TcpClient();
ourMagicClient.Connect(YourIP, ourPort);
NetworkStream ourStream = ourMagicClient.GetStream();
byte[] data = Encoding.ASCII.GetBytes(" Welcome !");
ourStream.Write(data, 0, data.Length);
}
}
}
|
|
|
|
|
It was merely an observation, and that's a nice example for a TCP/IP client/server.
The easy way of getting a location would be the location api, described here[^]. Alternatively, you'd find a GPS that comes with an SDK.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Here how I would approach it.
1. work out the best data type to store the GPS info in depending on what database system you have chosen.
2. work out if you are going to be saving one or more GPS info in a transaction.
3. Connect to your database
4. save
SqlConnection[^]
SqlCommand[^]
Parameterized Query Example[^]
Hopefully this will help you solve your problem, if you are still having problems after this please postcode the code where you are having problems with and a brief explination on whats happening etc and we will help you further.
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
Message Removed
modified 14-Dec-14 20:44pm.
|
|
|
|
|
Hi,
I would like to get a unique ID from my computer but I am not sure if the network MAC is a good idea because many people change network cards, similarly with he hard disk so I thought if possible to get the Processor / Bios MAC address?
Is this possible? How please?
Thanks,
Jassim
Technology News @ www.JassimRahma.com
|
|
|
|
|
|
get processor id is possible.
The following code will retrieve the CPU ID (processor id):
ManagementObjectCollection mbsList = null;
ManagementObjectSearcher mbs = new ManagementObjectSearcher("Select * From Win32_processor");
mbsList = mbs.Get();
string id="";
foreach (ManagementObject mo in mbsList)
{
id = mo["ProcessorID"].ToString();
}
|
|
|
|