Evaluation questions on watermark, linearization, TIFF, etc.

The Amyuni PDF Converter is our Printer Driver that enables you to convert any documents to PDF format. If you have any questions about installing and using the Amyuni PDF Converter please post them here.
Post Reply
Darrel
Posts: 6
Joined: Tue Jun 26 2007

Evaluation questions on watermark, linearization, TIFF, etc.

Post by Darrel »

Hi,

I am evaluating the PDF Converter 3.0 product and am having some difficulty trying to get a couple things to work and have a general question. Perhaps I should have posted these as separate questions, but I thought this would be easier. The issues I have run into are as follows:


1) Unable to get a Watermark produced or Linearization to work using the following initialization (C# code):

Code: Select all

	private static IntPtr m_converter = CDintfDll.DriverInit
                 ("Amyuni PDF Converter");

		...

	
        CDintfDll.EnablePrinter(m_converter,
            "Evaluation Version Developer Pro",
            "07EF ... BA20") <- Real key truncated posting
                  
        CDintfDll.SetWatermark(m_converter, " D R A F T ", "Verdana", 48,
               450,  0xFF00FF, 120, -120, true);
        CDIntfDllInterOp.SetOwnerPassword(m_converter, "Owner");
        CDIntfDllInterOp.SetUserPassword(m_converter, "User");
        CDIntfDllInterOpm.SetPermissions(m_converter, 0xFFFFFFC0 | 0x4);
        CDIntfDllInterOp.SetPrinterConfig(m_converter, 2);
        int options = 0x40 |  // Print watermark
               0x100 |  // Encrypt
               0x8000;  // Linearize for Web
        status = CDIntfDllInterOp.SetFileNameOptions(m_converter, 
            options);
where, CDIntfDllInterOp is just a class that provides P/Invoke signatures for calling functions in cdintf300.dll that are missing from CDintfDlll.


2) Wanted to also try producing a TIFF output using the following code, but I instead get a popup (after the following code is executed, so I presume it is the print driver issuing the popup) saying the evaluation has expired and when I hit Esc key to cancel that the print fails. This is odd because I can create a PDF fine without an evaluation expiration message.

Code: Select all

        private static IntPtr m_converter = CDintfDll.PDFDriverInit(
             "Amyuni TIFF Converter");

		...

        CDintfDll.EnablePrinter(m_converter,
             "Evaluation Version Developer Pro", 
             "07EF ... BA20") <- Real key truncated posting

	// Copied the following for another forum posting, but
                // documentation on the "TIFF Options" would be useful.
        CDIntfDllInterOp.SetPrinterParamInt(m_converter,
             "TIFF Options", 16); 
        CDIntfDllInterOp.SetPrinterParamInt(m_converter,
             "TIFF Resolution", 300);
        CDIntfDllInterOp.SetFileNameOptions(m_converter, 0);  <- Not sure this is needed or correct
        CDintfDll.SetDefaultConfig(m_converter);

The other question I have is:

- I am trying to decide whether it is better to use the DLL (CDintfDll) interface or the ActiveX interface. When I look at the SetOwnerPassowrd/SetUserPassword functions of the DLL I see that the string parameters are delared as 'LPCSTR', which is decorated as ANSI. The ActiveX OwnerPassword/UserPassword methods use 'String' parameters. My question is whether these ActiveX methods just call the same DLL entry points and thus result in the Unicode strings from my C# application being converted to ANSI strings or whether they call entry points that indeed support Unicode characters. My concern is international clients who will be using multi-byte character sets and want to use a password other something restricted to ANSI.



Any help or advice would be greatly appreciated.


Thanks,

Darrel
Darrel
Posts: 6
Joined: Tue Jun 26 2007

Post by Darrel »

Okay, I guess I am on my own since nobody has had any response to give me and given I am evaluating I cannot submit a support question.

However, in regards to my 2nd question, I have concluded that the "Your 30 day evaluation period has expired" popup dialog occurs whenever I use PDFPrinterInit to define a new printer (if I use PrinterInit with the printer installed with the evaluation I do not get the popup). When I dismiss the popup with the Enter key, I get error 21 ("The device is not read")on the Win32 StartDoc API call.

With this in mind, I tried to switch to trying the TIFF code I found in another post in this forum with the installed printer. However, that results in error -30 indicting the printer is not activated.

Again, any help is appreciated as I really want to be able to successfully evaluate this product.


Darrel
Darrel
Posts: 6
Joined: Tue Jun 26 2007

Clarification to last post...

Post by Darrel »

Sorry, I meant to say PDFDriverInit and DriverInit instead of PDFPrinterInit and PrinterInit in my last post description.

:oops:

Darrel
Jose
Amyuni Team
Posts: 553
Joined: Tue Oct 01 2002
Contact:

Post by Jose »

Hello Darrel,

Below are code snippets which illustrate how to implement the PDF Converter through the DLL interface.

Hope this helps?

Code # 1

IntPtr PDF;
PDF = CDintfDll.DriverInit ( PDFprinter );

CDintfDll.SetDefaultPrinter ( PDF );
CDintfDll.SetPrinterParamStr ( PDF, "File Name", "c:\\temp\\test_sharp.pdf");
CDintfDll.SetPrinterParamInt ( PDF, "Options", sNoPrompt + sUseFileName + PrintWatermark );

CDintfDll.SetWatermark( PDF, "WaterMark", "", 36, 0, System.Drawing.ColorTranslator.ToWin32 (Color.Yellow), 0,0, false);
CDintfDll.EnablePrinter( PDF, strLicenseTo, strActivationCode);

//print someting
printDocument1.Print();


Code # 2
IntPtr PDF;
PDF = CDintfDll.DriverInit(PDFprinter);

CDintfDll.SetDefaultPrinter(PDF);

/*

TIFF Resolution Integer Image resolution at which the documentis converted to JPeg
0 – 75 DPI
1 – 150 DPI
2 – 300 DPI
3 – 600 DPI
TIFF Options Integer TIFF compression level. 0 – No TIFF Output
16 – TIFF output with no compression
26 – TIFF output with CCITT Fax Compression
All other values reserved for future use

*/

CDintfDll.SetPrinterParamInt("TIFF Options", 26);
CDintfDll.SetPrinterParamInt("TIFF Resolution", 2);

CDintfDll.SetPrinterParamStr(PDF, "File Name", "c:\\temp\\test_sharp.pdf");
CDintfDll.SetPrinterParamInt(PDF, "Options", sNoPrompt + sUseFileName + PrintWatermark);

CDintfDll.SetWatermark(PDF, "WaterMark", "", 36, 0, System.Drawing.ColorTranslator.ToWin32(Color.Yellow), 0, 0, false);
CDintfDll.EnablePrinter(PDF, strLicenseTo, strActivationCode);

//print someting
printDocument1.Print();
Darrel
Posts: 6
Joined: Tue Jun 26 2007

Post by Darrel »

Hi Jose,

Thanks for the code snippits, which I tried with no success using the code posted below from a console application.

Could you tell me if the following constant values are correct:

const int sNoPrompt = 0x1;
const int sUseFileName = 0x2;
const int PrintWatermark = 0x40;
const int LinearizeForWeb = 0x8000;

Also, I did notice I have to put in a sleep or I get "Printer not activeate error code -30", which I have seen occasionally in my other test program when calling StartDoc but a sleep there does not help. Post http://www.amyuni.com/forum/viewtopic.php?t=2033 seems to imply that should be a problem with the Evaluation version anymore, but I keep hitting it.

Anyway, my console program is as follows and does not produce a watermark or linearization of the PDF file as seen from the PDF file properties.

Code: Select all

using System;
using System.Text;
using System.Drawing;
using System.Drawing.Printing;
using System.IO;
using CDIntfNet;

namespace AmyuniTest
{
   class Program
   {
      private const string InputFile = @"C:\Temp\TestData.txt";   // FILE TO PRINT
      private Font printFont;
      private StreamReader streamToPrint;

      static void Main(string[] args)
      {
         //print something.
         new Program();
      }

      public Program()
      {
         Initialize();
         Printing();
      }

      private void Initialize()
      {
         const int sNoPrompt = 0x1;
         const int sUseFileName = 0x2;
         const int PrintWatermark = 0x40;
         const int LinearizeForWeb = 0x8000;
         const string strLicenseTo = "Evaluation Version Developer Pro";
         const string strActivationCode = "07EFCDAB010001001A62D63A28234ADFD28E5C773A417CBCF622CE045AA431E6CCCFA12932B31B851AAA7C7E11A178A8AF883B10998560A0650A5F27E42FDCD3BADC4C704277F8DC2876EE961D134CE69A4F19730A30176CF265BA20";
         const string PDFprinter = "Amyuni PDF Converter";

         IntPtr PDF;
         PDF = CDintfDll.DriverInit(PDFprinter);
         System.Threading.Thread.Sleep(500);

         CDintfDll.SetDefaultPrinter(PDF);

         CDintfDll.SetPrinterParamInt(PDF, "TIFF Options", 26);
         CDintfDll.SetPrinterParamInt(PDF, "TIFF Resolution", 2);

         CDintfDll.SetPrinterParamStr(PDF, "File Name", "c:\\temp\\test_sharp.pdf");
         CDintfDll.SetPrinterParamInt(PDF, "Options", sNoPrompt + sUseFileName + PrintWatermark + LinearizeForWeb);

         CDintfDll.SetWatermark(PDF, "WaterMark", "", 36, 0, System.Drawing.ColorTranslator.ToWin32(Color.Yellow), 0, 0, false);
         CDintfDll.EnablePrinter(PDF, strLicenseTo, strActivationCode);
      }
      // The PrintPage event is raised for each page to be printed.
      private void pd_PrintPage(object sender, PrintPageEventArgs ev)
      {
         float linesPerPage = 0;
         float yPos = 0;
         int count = 0;
         float leftMargin = ev.MarginBounds.Left;
         float topMargin = ev.MarginBounds.Top;
         String line = null;

         // Calculate the number of lines per page.
         linesPerPage = ev.MarginBounds.Height /
            printFont.GetHeight(ev.Graphics);

         // Iterate over the file, printing each line.
         while (count < linesPerPage &&
            ((line = streamToPrint.ReadLine()) != null))
         {
            yPos = topMargin + (count * printFont.GetHeight(ev.Graphics));
            ev.Graphics.DrawString(line, printFont, Brushes.Black,
               leftMargin, yPos, new StringFormat());
            count++;
         }

         // If more lines exist, print another page.
         if (line != null)
            ev.HasMorePages = true;
         else
            ev.HasMorePages = false;
      }

      // Print the file.
      public void Printing()
      {
         try
         {
            streamToPrint = new StreamReader(InputFile);
            try
            {
               printFont = new Font("Arial", 10);
               PrintDocument pd = new PrintDocument();
               pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
               // Print the document.
               pd.Print();
            }
            finally
            {
               streamToPrint.Close();
            }
         }
         catch (Exception ex)
         {
            Console.WriteLine(ex.Message);
         }
      }

   }
}

Any help you can give me will be greatly appreciated. (I will be on vacation until next week though, so I won't be able to try any suggestions until then).


Thanks,

Darrel
Jose
Amyuni Team
Posts: 553
Joined: Tue Oct 01 2002
Contact:

Post by Jose »

Hello Darrel,

We have just uploaded version 3.01 on to our website and this version resolves the issue you are encountering.

Also, if you have other questions while evaluating the product you can send them directly to support@amyuni.com. We do provide support during the evaluation period.

Thanks
Darrel
Posts: 6
Joined: Tue Jun 26 2007

Post by Darrel »

Hello Jose,

Unfortunately, I have mixed results to report with the new 3.01 version I downloaded today.

- The Linearization option now works. :D

- The watermark worked only once. Actually, it didn't work the first time so I uninstalled and re-installed without checking the "Developer Version" to see if that made a difference. The first time I ran the previous program code I posted the yellow watermark was produced, so I thought maybe unchecking the "Developer Version" had some effect. However, after running another program and going back to the other program the watermark failed to show up and numerous executions since have failed to produce a watermark. :?

- I also can still not get the "TIFF Options" to work. The produced file is always just a PDF (i.e., starts with the "%PDF-" signature).


Darrel
Jose
Amyuni Team
Posts: 553
Joined: Tue Oct 01 2002
Contact:

Post by Jose »

Hello Darrel,

Can you send you sample application to support@amyuni.com? We'll take a look at it here and we'll let you know what we find.

Thanks
Darrel
Posts: 6
Joined: Tue Jun 26 2007

Post by Darrel »

Hi Jose,

Based upon your earlier comment, I did ZIP up my sample program and sent it to support@amyuni.com with a description of the problem and a reference to this forum posting.

Thanks for your help.

Darrel
Post Reply