2

私が生成している pdf のシャープなドキュメントがあり、それを単一のファイルに保存するとうまくいきます。同じ PDF ドキュメントから複数のファイルに保存しようとすると、次のエラー メッセージが表示されます。

Test Error : UnitTests.PdfFocusCalResultOutputterTester.Test_MakePDF
System.InvalidOperationException : The dictionary already has a stream.
at PdfSharp.Pdf.PdfDictionary.CreateStream(Byte[] value)
at PdfSharp.Pdf.Advanced.PdfToUnicodeMap.PrepareForSave()
at PdfSharp.Pdf.Advanced.PdfType0Font.PrepareForSave()
at PdfSharp.Pdf.Advanced.PdfFontTable.PrepareForSave()
at PdfSharp.Pdf.PdfDocument.PrepareForSave()
at PdfSharp.Pdf.PdfDocument.DoSave(PdfWriter writer)
at PdfSharp.Pdf.PdfDocument.Save(Stream stream, Boolean closeStream)
at ResultOutputter.PdfFocusCalResultOutputter.RenderToFile(String filename) in c:\projects\testing\pdffocuscalresultoutputter.cpp:line 802

次のようPdfSharp::Pdf::PdfDocument::Saveに、 a のインスタンスを呼び出すだけです。PdfDocument

System::IO::FileStream^ s = gcnew System::IO::FileStream("firstpdf.pdf", System::IO::FileMode::Create);
m_document->Save(s, false);
s->Flush();
s->Close();

System::IO::FileStream^ s2 = gcnew System::IO::FileStream("secondpdf.pdf", System::IO::FileMode::Create);
m_document->Save(s2, false);
s2->Flush();
s2->Close();
4

1 に答える 1

3
  1. これは PDFsharp のバグです。コードは機能するはずです。
  2. あなたのコードは効率的ではありません。一度ストリームに保存してから、そのストリームを 2 つ以上のファイルに書き込みます。
于 2012-05-08T12:43:30.003 に答える