Giter VIP home page Giter VIP logo

Comments (12)

svishnevsky avatar svishnevsky commented on June 5, 2024

Hi @JeffSE97062

Do you run the application with the same permission level as you have? Have you tried to run the app As Administrator?

from pdftoprinter.

JeffSE97062 avatar JeffSE97062 commented on June 5, 2024

I did try running as administrator and the file still wasn't removed.

from pdftoprinter.

svishnevsky avatar svishnevsky commented on June 5, 2024

Is the application a long running one like service or web server or it exists immediately after sending a file to a printer?

from pdftoprinter.

JeffSE97062 avatar JeffSE97062 commented on June 5, 2024

Exits immediately.

from pdftoprinter.

svishnevsky avatar svishnevsky commented on June 5, 2024

from pdftoprinter.

JeffSE97062 avatar JeffSE97062 commented on June 5, 2024

Thanks! And thanks for putting this together.

from pdftoprinter.

svishnevsky avatar svishnevsky commented on June 5, 2024

Hi @JeffSE97062

Could you please try the 1.4.2 version and confirm that it solves your issue?

To turn on awaiting of file deletion you need to pass "true" to CleanupFilesPrinter constructor like below:
new CleanupFilesPrinter(new PDFtoPrinterPrinter(), true);

from pdftoprinter.

JeffSE97062 avatar JeffSE97062 commented on June 5, 2024

Hi @svishnevsky, same issue with the 1.4.2. The file is not removed.

from pdftoprinter.

svishnevsky avatar svishnevsky commented on June 5, 2024

Do you use a similar approach like below?
`var wrapper = new CleanupFilesPrinter(new PDFtoPrinterPrinter(), true);
await wrapper.Print(new PrintingOptions("Microsoft Print to PDF", "somefile.pdf"));'

from pdftoprinter.

JeffSE97062 avatar JeffSE97062 commented on June 5, 2024

Yes.
`
class Program
{
static void Main(string[] args)
{
print();
}

    static async void print()
    {
        // Delete after printing. Doesn't seem to work.
        var wrapper = new CleanupFilesPrinter(new PDFtoPrinterPrinter(), true);

        await wrapper
            .Print(new PrintingOptions(
                Properties.Settings.Default.Printer,
                Properties.Settings.Default.FileToPrint)
                );

    }
}`

from pdftoprinter.

svishnevsky avatar svishnevsky commented on June 5, 2024

Thanks for sharing the code. You call the "print" method with no await, so your application exists before a Task is completed. Could you please try something like:
static sync Task Main(string[] args) { await print() }
or
static void Main(string[] args) { print(),GetAwaiter().GetResult(); }

from pdftoprinter.

JeffSE97062 avatar JeffSE97062 commented on June 5, 2024

That worked. Thanks.

from pdftoprinter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.