I am trying to split pdf files into separate individual pdfs. I can't figure out why keep giving me access to the path is denied error. I set my user name as an admin and full control for the folder.
public void ExtractPage()
{
string sourcePdfPath = "C:\\SOURCECODE\\OAPdfSplitter\\OAPdfSplitter\\PDFSource\\Xerox Scan_05022019151254.PDF";
string outputPdfPath = "C:\\SOURCECODE\\OAPdfSplitter\\OAPdfSplitter\\PDFOutput";
int pageNumber = 1;
PdfReader reader = null;
Document document = null;
PdfCopy pdfCopyProvider = null;
PdfImportedPage importedPage = null;
try
{
reader = new PdfReader(sourcePdfPath);
document = new Document(reader.GetPageSizeWithRotation(pageNumber));
pdfCopyProvider = new PdfCopy(document,new System.IO.FileStream(outputPdfPath, System.IO.FileMode.Create));
document.Open();
importedPage = pdfCopyProvider.GetImportedPage(reader, pageNumber);
pdfCopyProvider.AddPage(importedPage);
document.Close();
reader.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error message:", MessageBoxButton.OK, MessageBoxImage.Error);
}