Good evening,
I have developed a program and need to implement the print PDF functionality.
Doing research on the internet found what I need, but there is a problem. When I run the code in a separate console program, it opens the window of the option to choose the printer and then prints. I implemented this code in my project, but it is displaying the following error:
Error 1 Could not load file or assembly 'file: /// C: \ Work \ Projects \ NET \ MAILS \ CtzEmisEtiqCorreios \ CtzEmisEtiqCorreios \ bin \ Debug \ Spire.License.dll' or one of your dependencies. Unsupported operation. (Exception from HRESULT: 0x80131515) C: \ Work \ Projects \ NET \ MAILS \ CtzEmisEtiqCreates \ CtzEmisEtiqCreates \ SGEN CtzEmisEtiq Couriers
I'm using external dlls:
using Spire.Pdf; using Spire.Pdf.Annotations; using Spire.Pdf.Widget;
These libraries I attached inside the debug folder and in the project release folder, it still did not solve.
The method is as follows:
// Bibliotecas externas
using Spire.Pdf;
using Spire.Pdf.Annotations;
using Spire.Pdf.Widget;
private void PrintPdf(string pstrNomeArqTxt)
{
PdfDocument doc = new PdfDocument();
//Set the printer and select the pages you want to print
PrintDialog dialogPrint = new PrintDialog();
dialogPrint.AllowPrintToFile = true;
dialogPrint.AllowSomePages = true;
dialogPrint.PrinterSettings.MinimumPage = 1;
dialogPrint.PrinterSettings.MaximumPage = doc.Pages.Count;
dialogPrint.PrinterSettings.FromPage = 1;
dialogPrint.PrinterSettings.ToPage = doc.Pages.Count;
if (dialogPrint.ShowDialog() == DialogResult.OK)
{
//Set the pagenumber which you choose as the start page to print
doc.PrintFromPage = dialogPrint.PrinterSettings.FromPage;
//Set the pagenumber which you choose as the final page to print
doc.PrintToPage = dialogPrint.PrinterSettings.ToPage;
//Set the name of the printer which is to print the PDF
doc.PrinterName = dialogPrint.PrinterSettings.PrinterName;
PrintDocument printDoc = doc.PrintDocument;
dialogPrint.Document = printDoc;
printDoc.Print();
}
}
Does anyone know what's causing the error?
Thank you