Save Images and PDF Files in C#
Edited PDF documents can be saved by overwriting the original file:
// We assume GdPicture has been correctly installed and unlocked. using (GdPicturePDF oGdPicturePDF = new GdPicturePDF()) { GdPictureStatus status = oGdPicturePDF.LoadFromFile("test.pdf", true); //The file is loaded into memory. if (status == GdPictureStatus.OK) { if (oGdPicturePDF.ClonePage(1) == GdPictureStatus.OK) //Processing... { status = oGdPicturePDF.SaveToFile("test.pdf"); //The file is overwritten. if (status == GdPictureStatus.OK) { MessageBox.Show("The PDF file has been overwritten and saved sucessfully.", "Saving PDF Example", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("The file can't be saved. Status: " + status.ToString(), "Saving PDF Example", MessageBoxButtons.OK, MessageBoxIcon.Error); } oGdPicturePDF.CloseDocument(); } } else { MessageBox.Show("The file can't be opened. Status: " + status.ToString(), "Saving PDF Example", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
'We assume GdPicture has been correctly installed and unlocked. Using oGdPicturePDF As New GdPicturePDF() Dim status As GdPictureStatus = oGdPicturePDF.LoadFromFile("test.pdf", True) 'The file is loaded into memory. If status = GdPictureStatus.OK Then If oGdPicturePDF.ClonePage(1) = GdPictureStatus.OK Then 'Processing... status = oGdPicturePDF.SaveToFile("test.pdf") 'The file is overwritten. If status = GdPictureStatus.OK Then MessageBox.Show("The PDF file has been overwritten and saved sucessfully.", "Saving PDF Example", MessageBoxButtons.OK, MessageBoxIcon.Information) Else MessageBox.Show("The file can't be saved. Status: " + status.ToString(), "Saving PDF Example", MessageBoxButtons.OK, MessageBoxIcon.Error) End If oGdPicturePDF.CloseDocument() End If Else MessageBox.Show("The file can't be opened. Status: " + status.ToString(), "Saving PDF Example", MessageBoxButtons.OK, MessageBoxIcon.Error) End If End Using