简体   繁体   中英

PDFSharp not working

I'm trying to save my bitmaps in a .pdf file. It doesn't work. I'm not getting an error, but it doesn't open the dialog to save the .pdf file.

Here is my code:

PdfDocument doc = new PdfDocument();

for (int iCnt = 0; iCnt < nPaginasPDF; iCnt++)
{
    doc.Pages.Add(new PdfPage());
    XGraphics xgr = XGraphics.FromPdfPage(doc.Pages[iCnt]);
    XImage img = XImage.FromFile("C:\\" + (iCnt+1) + ".bmp"); (In this directory have these image files)

    xgr.DrawImage(img, panel1.ClientRectangle);
}

using (var Stream = saveFileDialog1.OpenFile())
{
    doc.Save(Stream);
}

doc.Close();

The SaveFileDialog 's OpenFile method opens the file returned by SaveFileDialog.Filename property file with read/write permission.

To select a file before saving, you must use the ShowDialog method first. Have you debugged and checked the value of Stream with a break point?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM