I need to be able to open a pdf and recolor a black object to some other color. I was doing this through abcPDF but I am looking to get away from their library (trash)
Below is the code I was using from their library. Perhaps someone can help me translate it to PDFSharp. Thanks
Doc theSource = new Doc();
theSource.Read(PDFUtilities.ServerMapPath(filepath));
// recolor the black portions
theSource.Flatten(); // ensure compressed
int thecount = Convert.ToInt32(theSource.GetInfo(theSource.Page, "/Contents:Count")); // get contents stream
int tempFor1 = thecount;
for (int j = 0; j < tempFor1; j++)
{
int theID = Convert.ToInt32(theSource.GetInfo(theSource.Page, "/Contents[" + j + "]:Ref"));
theSource.GetInfo(theID, "Decompress"); // ensure stream decompressed
string theContents = theSource.GetInfo(theID, "stream");
if (this.GetPDFColorCode(color) != string.Empty)
theContents = theContents.Replace("0 0 0 rg", this.GetPDFColorCode(color));
theSource.SetInfo(theID, "stream", theContents);
}
|