Printing multiple pages causes registration/buy watermark?

PDF-XChange Drivers API (only) V4/V5
This Forum is for the use of Software Developers requiring help and assistance for Tracker Software's PDF-XChange Printer Drivers SDK (only) - VERSION 4 & 5 - Please use the PDF-Tools SDK Forum for Library DLL assistance.

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan

Post Reply
baumlerd
User
Posts: 7
Joined: Mon Apr 23, 2007 3:21 pm

Printing multiple pages causes registration/buy watermark?

Post by baumlerd »

After upgrading to the newest v5 of the Drivers API SDK, I am having an issue where if I print a file to the PDF printer in code it works fine and without any watermarks if I only print once. If I print two different files or the same file more than once the PDF document that is generated contains the registration/buy watermark on all pages.

Code: Select all

            PDFPrinter.SetAsDefaultPrinter();
            bPXCPrinterDefault = true;

            System.Threading.Thread.Sleep(1000);

            System.Diagnostics.Process printJob = new System.Diagnostics.Process();
            printJob.StartInfo.FileName = "testing.txt";
            printJob.StartInfo.UseShellExecute = true;
            printJob.StartInfo.Verb = "print";
            printJob.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Minimized;
            printJob.Start();
            System.Threading.Thread.Sleep(1000);

            //printJob.Start();
            //System.Threading.Thread.Sleep(1000);

            PDFPrinter.RestoreDefaultPrinter();
            bPXCPrinterDefault = false;
            tbEventsLog.Text = "!Restored Default Printer\r\n" + tbEventsLog.Text;
The above code will create a PDF without any watermarks, but if you uncomment

Code: Select all

            //printJob.Start();
            //System.Threading.Thread.Sleep(1000);
then the pdf created will have the buy/registration watermarks.


Is there a new setting that needs to be set as this was working fine before the update?
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3550
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada
Contact:

Re: Printing multiple pages causes registration/buy watermar

Post by Ivan - Tracker Software »

It happens because printing is asynchronous process and you release your printer object before printing job arrives to the printer.
You can use Sleep, or wait until pdf file will be created using events or PDFPrinter.WaitForPrintEvent(event_DocumentSaved);
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
baumlerd
User
Posts: 7
Joined: Mon Apr 23, 2007 3:21 pm

Re: Printing multiple pages causes registration/buy watermar

Post by baumlerd »

I added this after the creation of the PDFPrinter

Code: Select all

PDFPrinter.OnFileSaved += new PXCComLib5._IPXCPrinterEvents_OnFileSavedEventHandler(prn_OnFileSaved);
and declared the event

Code: Select all

        void prn_OnFileSaved(int JobID, string lpszFileName)
        {
            bSaved = true;
        }

and then changed the printing code to this

Code: Select all

            PDFPrinter.SetAsDefaultPrinter();
            bPXCPrinterDefault = true;

            System.Diagnostics.Process printJob = new System.Diagnostics.Process();
            printJob.StartInfo.FileName = "testing.txt";
            printJob.StartInfo.UseShellExecute = true;
            printJob.StartInfo.Verb = "print";
            printJob.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Minimized;
            bSaved = false;
            printJob.Start();
            while (!bSaved)
            {
                System.Threading.Thread.Sleep(100);
            }

            bSaved = false;
            printJob.Start();
            while (!bSaved)
            {
                System.Threading.Thread.Sleep(100);
            }

            PDFPrinter.RestoreDefaultPrinter();
            bPXCPrinterDefault = false;
            tbEventsLog.Text = "!Restored Default Printer\r\n" + tbEventsLog.Text;
and I still have the same issue where if I print the document once, it does not have the watermarks, but if I print it more than once, I get the watermarks.

Thoughts?
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3550
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada
Contact:

Re: Printing multiple pages causes registration/buy watermar

Post by Ivan - Tracker Software »

Will try to reproduce
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
baumlerd
User
Posts: 7
Joined: Mon Apr 23, 2007 3:21 pm

Re: Printing multiple pages causes registration/buy watermar

Post by baumlerd »

Has there been any update on this?
baumlerd
User
Posts: 7
Joined: Mon Apr 23, 2007 3:21 pm

Re: Printing multiple pages causes registration/buy watermar

Post by baumlerd »

It has been one month since the last update on this thread from Tracker Software.

Has there been any new information on this?

We have many users experiencing this issue and I need to find a resolution to this.

Thank you
User avatar
Will - Tracker Supp
Site Admin
Posts: 6815
Joined: Mon Oct 15, 2012 9:21 pm
Location: London, UK
Contact:

Re: Printing multiple pages causes registration/buy watermar

Post by Will - Tracker Supp »

Hi baumlerd,

Apologies for the delay - I'll see if I can get some kind of an update for you today.

Thanks for your patience!
If posting files to this forum, you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded.
Thank you.

Best regards

Will Travaglini
Tracker Support (Europe)
Tracker Software Products Ltd.
http://www.tracker-software.com
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3550
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada
Contact:

Re: Printing multiple pages causes registration/buy watermar

Post by Ivan - Tracker Software »

I did reproduce the issue here on my side and looks like it reproducible when there are orphaned printers from previous app's run.
Checking now why exactly it happens and will come back when will have any result.
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
baumlerd
User
Posts: 7
Joined: Mon Apr 23, 2007 3:21 pm

Re: Printing multiple pages causes registration/buy watermar

Post by baumlerd »

Thank you very much.
User avatar
Will - Tracker Supp
Site Admin
Posts: 6815
Joined: Mon Oct 15, 2012 9:21 pm
Location: London, UK
Contact:

Re: Printing multiple pages causes registration/buy watermar

Post by Will - Tracker Supp »

:)
If posting files to this forum, you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded.
Thank you.

Best regards

Will Travaglini
Tracker Support (Europe)
Tracker Software Products Ltd.
http://www.tracker-software.com
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3550
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada
Contact:

Re: Printing multiple pages causes registration/buy watermar

Post by Ivan - Tracker Software »

Looks like I found where the issue is - you did use our sample as a base for your app, and in that sample in the function the outputs log message there is a code that causes the problem:

Code: Select all

        void AddEventLog(string sText)
        {
            if (this.InvokeRequired)
            {
                AddEventLogCallback d = new AddEventLogCallback(AddEventLog);
                this.Invoke(d, new object[] { sText });
            }
            else
            {
                tbEventsLog.Text = tbEventsLog.Text + sText + "\r\n";
//              if (bPXCPrinterDefault)
//              {
//                  PDFPrinter.RestoreDefaultPrinter();
//                  bPXCPrinterDefault = false;
//                  tbEventsLog.Text = tbEventsLog.Text + "!Restored Default Printer\r\n";
//              }
            }
        }
please comment that code as shown above, as this code restores default printer, and second print job goes to wrong printer.

Also, please change your code that waits for file to be saved to:

Code: Select all

            while (!bSaved)
            {
                Application.DoEvents(); // pump out message queue
                System.Threading.Thread.Sleep(100);
            }
Otherwise application may hang due dead lock in events handling
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
baumlerd
User
Posts: 7
Joined: Mon Apr 23, 2007 3:21 pm

Re: Printing multiple pages causes registration/buy watermar

Post by baumlerd »

I had already removed the AddEventLog event from the code and it is not using this.

I added in the Application.DoEvents(); and I still get the watermarks :(

Here is the code:

Code: Select all

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Printing;
using System.Text;
using System.Windows.Forms;
using PXCComLib5;

namespace PDFdriverAPI
{
    public partial class Form1 : Form
    {
        PXCComLib5.CPXCPrinter PDFPrinter;
        bool bPXCPrinterDefault;
        bool bSaved;

        string pdfFileName = "PDFTOCREATE.PDF";
        string txtFileName = "FILETOPRINT.TXT";

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            System.IO.File.Delete(pdfFileName);

            CPXCControlEx prnFactory = new PXCComLib5.CPXCControlEx();

            PDFPrinter = (PXCComLib5.CPXCPrinter)prnFactory.get_Printer("", "PDF X-Change Printer", "REGINFO", "REGINFO");
            PDFPrinter.OnFileSaved += new PXCComLib5._IPXCPrinterEvents_OnFileSavedEventHandler(prn_OnFileSaved);

            PDFPrinter.set_Option("Save.File", pdfFileName);
            PDFPrinter.set_Option("Save.SaveType", "Save");
            PDFPrinter.set_Option("Save.ShowSaveDialog", "No");
            PDFPrinter.set_Option("Save.WhenExists", "Append");
            PDFPrinter.set_Option("Save.RunApp", "No");
            PDFPrinter.set_Option("Save.RunCustom", "No");
            PDFPrinter.set_Option("Saver.ShowProgress", "Yes");
            PDFPrinter.set_Option("General.ShowDocTitle", "No");
            PDFPrinter.set_Option("Fonts.EmbedAll", "Yes");
            PDFPrinter.set_Option("Compression.Graphics", "Yes");
            PDFPrinter.set_Option("Compression.Text", "Yes");
            PDFPrinter.set_Option("Compression.ASCII", "No");
            PDFPrinter.set_Option("Compression.Color.Enabled", "Yes");
            PDFPrinter.set_Option("Compression.Color.Method", "Auto");
            PDFPrinter.set_Option("Compression.Indexed.Enabled", "Yes");
            PDFPrinter.set_Option("Compression.Indexed.Method", "Auto");
            PDFPrinter.set_Option("Compression.Mono.Enabled", "Yes");
            PDFPrinter.set_Option("Compression.Mono.Method", "Auto");
            PDFPrinter.ApplyOptions(0);
            
            tbEventsLog.Select(0, 0);
            bPXCPrinterDefault = false;

            TestPrinting();
        }

        void prn_OnFileSaved(int JobID, string lpszFileName)
        {
            bSaved = true;
            System.Threading.Thread.Sleep(2000);
        }

        private void Form1_FormClosed(object sender, FormClosedEventArgs e)
        {            
            PDFPrinter = null;
        }

        private void TestPrinting()
        {
            PDFPrinter.SetAsDefaultPrinter();
            bPXCPrinterDefault = true;

            System.Diagnostics.Process printJob = new System.Diagnostics.Process();
            printJob.StartInfo.FileName = txtFileName;
            printJob.StartInfo.UseShellExecute = true;
            printJob.StartInfo.Verb = "print";
            printJob.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Minimized;
            bSaved = false;
            printJob.Start();
            while (!bSaved)
            {
                System.Threading.Thread.Sleep(100);
            }

            bSaved = false;
            printJob.Start();
            while (!bSaved)
            {
                Application.DoEvents();
                System.Threading.Thread.Sleep(100);
            }

            PDFPrinter.RestoreDefaultPrinter();
            bPXCPrinterDefault = false;
            tbEventsLog.Text = "FINISHED";
        }
    }
}
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3550
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada
Contact:

Re: Printing multiple pages causes registration/buy watermar

Post by Ivan - Tracker Software »

I found the issue with applying demo labels when Append feature is used. I fixed the issue already. The fix will be available in the new build that is expected in few weeks.
Thanks for your cooperation and patience.
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
baumlerd
User
Posts: 7
Joined: Mon Apr 23, 2007 3:21 pm

Re: Printing multiple pages causes registration/buy watermar

Post by baumlerd »

Will you be updating this thread when the new build is available?
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17941
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Printing multiple pages causes registration/buy watermar

Post by Tracker Supp-Stefan »

Hello baumlerd,

The new build is planned for the second half of may, and all our products will be updated at that time, so please just check our website weekly and you will see the update as soon as it's available.

Regards,
Stefan
Post Reply