- Code: Select all
A generic error occurred in GDI+.
Form Vars:
Stack Trace: at
System.Drawing.Imaging.Metafile..ctor(Stream stream, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type, String description) at
System.Drawing.Imaging.Metafile..ctor(Stream stream, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type) at
spr᪸.ᜀ(PageSetup A_0, ImageType A_1, MemoryStream A_2, Int32 A_3, GraphicsUnit A_4) at
spr᪸.ᜀ(PageSetup A_0, ImageType A_1, MemoryStream A_2, Int32 A_3) at
spr᪸.ᜒ() at
spr᪸.ᜁ(IDocument A_0) at
spr⊈.ᜀ(Document A_0) at
Spire.Doc.Document.ᜀ(Stream A_0, ToPdfParameterList A_1) at
MAC.Common.Utility.TMR.TMRPDFUtil.SaveToStream(Document wordDocument, String reportName, Stream stream) in E:\TeamCity\buildAgent\work\167110223c6d33dd\Common\MAC.Common.Utility\TMR\TMRPDFUtil.cs:line 349 at
Here is the method that contains the line 349 that causes the error.
- Code: Select all
private static void SaveToStream(Document wordDocument, string reportName, Stream stream)
{
var mStream = new MemoryStream();
ToPdfParameterList toPdf = new ToPdfParameterList();
toPdf.EmbeddedFontNameList.Add("Letter Gothic");
toPdf.CreateWordBookmarks = true;
toPdf.WordBookmarksTitle = reportName;
toPdf.WordBookmarksColor = Color.Red;
toPdf.WordBookmarksTextStyle = BookmarkTextStyle.Bold;
wordDocument.BookmarkLayout += document_BookmarkLayout;
Line349: -->> wordDocument.SaveToStream(mStream, toPdf);
//now opend it backup and enable the bookmarks to be visible in the browser.
PdfDocument pdfdoc = new PdfDocument();
pdfdoc.LoadFromStream(mStream);
pdfdoc.ViewerPreferences.FitWindow = true;
pdfdoc.ViewerPreferences.PageMode = PdfPageMode.UseOutlines;
pdfdoc.SaveToStream(stream);
stream.Flush();
wordDocument.Close();
}