我正在尝试将pdf文件拆分为单独的pdf。我无法弄清楚为什么继续让我访问该路径被拒绝错误。我将用户名设置为admin,并对文件夹进行完全控制。
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);
}