I tested using simple code, and it succeeded in creating, appending and replacing PDF pages. In particular, the last part of the code replaced the red page in the middle of the file with a new blue page.
If you can't get your code to work, please create a small test program that only contains my code below and see if it works. If it doesn't, your version of LEADTOOLS might be outdated, so please send your serial number to
support@leadtools.com and ask for the latest build.
Leadtools.RasterImage img = new
Leadtools.RasterImage(
Leadtools.RasterMemoryFlags.Conventional,
300,
200,
24,
Leadtools.RasterByteOrder.Bgr,
Leadtools.RasterViewPerspective.TopLeft, null, IntPtr.Zero, 0);
Leadtools.Codecs.RasterCodecs codecs = new Leadtools.Codecs.RasterCodecs();
Leadtools.ImageProcessing.FillCommand fill = new
Leadtools.ImageProcessing.FillCommand(new Leadtools.RasterColor(Color.Beige));
fill.Run(img);
//create new file, first page color beige
codecs.Save(img, "TryReplace.pdf", Leadtools.RasterImageFormat.RasPdfJpeg411,
24, 1, 1, 1, Leadtools.Codecs.CodecsSavePageMode.Overwrite);
fill.Color = new Leadtools.RasterColor(Color.Red);
fill.Run(img);
//Add second page, color red
codecs.Save(img, "TryReplace.pdf", Leadtools.RasterImageFormat.RasPdfJpeg411,
24, 1, 1, 1, Leadtools.Codecs.CodecsSavePageMode.Append);
fill.Color = new Leadtools.RasterColor(Color.RosyBrown);
fill.Run(img);
//Add third page, color RosyBrown
codecs.Save(img, "TryReplace.pdf", Leadtools.RasterImageFormat.RasPdfJpeg411,
24, 1, 1, 1, Leadtools.Codecs.CodecsSavePageMode.Append);
fill.Color = new Leadtools.RasterColor(Color.Blue);
fill.Run(img);
//Replace second page, color blue
codecs.Save(img, "TryReplace.pdf", Leadtools.RasterImageFormat.RasPdfJpeg411,
24, 1, 1, 2, Leadtools.Codecs.CodecsSavePageMode.Replace);
Amin Dodin
Senior Support Engineer
LEAD Technologies, Inc.