我可以生成在WinRT中
string path = @"ExportPDF.pdf";
var storageFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
// Create empty PDF file.
var file = await storageFolder.CreateFileAsync(path, CreationCollisionOption.ReplaceExisting);
if (file != null)
{
await FileIO.WriteTextAsync(file, string.Empty);
}
// Open to PDF file for read/write.
StorageFile sampleFile = await storageFolder.GetFileAsync(path);
var stream = await sampleFile.OpenAsync(Windows.Storage.FileAccessMode.ReadWrite);
// Create an instance of the document class which represents the PDF document itself.
Document document = new Document(PageSize.A4, 25, 25, 30, 30);
// Create an instance to the PDF file by creating an instance of the PDF
// Writer class using the document and the filestrem in the constructor.
PdfWriter writer = PdfWriter.GetInstance(document, stream.AsStream());
// Add meta information to the document
document.AddAuthor("Jigs");
document.AddCreator("Sample application");
document.AddKeywords("PDF App");
document.AddSubject("Document subject - Describing the steps creating a PDF document");
document.AddTitle("The document title - PDF creation");
// Open the document to enable you to write to the document
document.Open();
// Add a simple and wellknown phrase to the document in a flow layout manner
document.Add(new Paragraph("Hello!"));
// Close the document
document.Close();
// Close the writer instance
writer.Close();
您是否获得运行时错误PDF文件?我不认为WinRT和Windows 8 Pro的应用程序API不同。 – BradleyDotNET
这里是我的代码: 'iTextSharp.text.pdf.PdfWriter作家= iTextSharp.text.pdf.PdfWriter.GetInstance(DOC, 新System.IO.FileStream(System.IO.Directory.GetCurrentDirectory()+“\\ ScienceReport.pdf“, System.IO.FileMode.Create));' 但在文件流,FileMOde和目录中有一条红线,表示命名空间System.IO中不存在这些命名空间。在此先感谢 – Paul
啊,你正试图使用标准的.NET在Windows应用商店中做到这一点。如果我理解正确,那更有意义。为了将来的参考,请使用邮件下方的“编辑”按钮在问题中包含代码,因为它更易于阅读。 – BradleyDotNET