Do you have an example on how I can use C# to pass through all of the pages of a pdf file and check each page to determine whether it is color or black and white?
I have a license for Spool File Page Counter SDK.
I found this url,
http://www.verypdf.com/wordpress/201106/counting-the-exact-number-of-pages-in-any-pdf-document-732.html#comments
It appears that I am using the demo version. How do I get the production version?
Customer
----------------------------------------------
Thanks for your message, you may download "Spool File Page Counter SDK" from this web page,
https://www.verydoc.com/spool-page-count.html
https://www.verydoc.com/ps-and-pcl-info-sdk.zip
after you download it, please unzip it to a folder, you will see "C-Sharp" and "C-Sharp-AnyCPU" two folders are included in the ps-and-pcl-info-sdk.zip file, these folders are C# examples, you can compile and run them in "Microsoft Visual Studio" properly.
You can call "ReadInfo.dll" from C# code directly, this is a C# example to call the "ReadInfo.dll" directly,
-----------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
namespace ParsingTest {
class Program {
[DllImport("ReadInfo.dll", EntryPoint = "ReadInfoFromPCLFile")]
public static extern Int32 ReadInfoFromPCLFile(
string fileName,
Int32 bIsRenderToPDF,
ref uint bwPageCount,
ref uint colorPageCount,
ref uint copyCount,
ref double pagewidth,
ref double pageheight,
StringBuilder paperSizeName);
[DllImport("ReadInfo.dll", EntryPoint = "ReadInfoSetCode")]
public static extern void ReadInfoSetCode(string strCode);
static void Main(string[] args)
{
if (args.Length != 1)
{
Console.WriteLine("test.exe C:\\test.pcl");
Console.WriteLine("test.exe C:\\test.ps");
return;
}
Console.Write("args length is ");
Console.WriteLine(args.Length); // Write array length
for (int i = 0; i < args.Length; i++) // Loop through array
{
string argument = args[i];
Console.Write("args index ");
Console.Write(i); // Write index
Console.Write(" is [");
Console.Write(argument); // Write string
Console.WriteLine("]");
}
string fileName = args[0];
int bIsRenderToPDF = 1;
uint bwPageCount = 0;
uint colorPageCount = 0;
uint copyCount = 0;
double nPageWidth = 0;
double nPageHeight = 0;
StringBuilder strPaperSizeName = new StringBuilder(300);
ReadInfoSetCode("XXXXXXXXXXXXXXXXXX");
ReadInfoFromPCLFile(fileName, bIsRenderToPDF, ref bwPageCount, ref colorPageCount, ref copyCount, ref nPageWidth, ref nPageHeight, strPaperSizeName);
Console.WriteLine(String.Format("File: {0}", fileName));
Console.WriteLine(String.Format("Render To PDF: {0}", bIsRenderToPDF));
Console.WriteLine(String.Format("BW Pages: {0}", bwPageCount));
Console.WriteLine(String.Format("Color Pages: {0}", colorPageCount));
Console.WriteLine(String.Format("Width: {0}", nPageWidth));
Console.WriteLine(String.Format("Height: {0}", nPageHeight));
Console.WriteLine(String.Format("Paper name: {0}", strPaperSizeName));
}
}
}
-----------------------------------
We are also provide a COM interface (FileInfoCOM.exe) based on ReadInfo.dll library, you can also call FileInfoCOM.exe from C# code instead of ReadInfo.dll library, please by following steps to use FileInfoCOM.exe COM interface,
1. Launch a CMD window by administrator privilege, run following command line to register FileInfoCOM.exe,
FileInfoCOM.exe /regserver
You can also run "install.vbs" to register FileInfoCOM.exe into your system.
2. After you register FileInfoCOM.exe into your system, you can add a reference to FileInfoCOM.exe from your C# code,
-----------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using FileInfoCOM;
namespace ParsingTest {
class Program {
static void Main(string[] args)
{
if (args.Length != 1)
{
Console.WriteLine("test.exe C:\\test.pcl");
Console.WriteLine("test.exe C:\\test.ps");
return;
}
Console.Write("args length is ");
Console.WriteLine(args.Length); // Write array length
for (int i = 0; i < args.Length; i++) // Loop through array
{
string argument = args[i];
Console.Write("args index ");
Console.Write(i); // Write index
Console.Write(" is [");
Console.Write(argument); // Write string
Console.WriteLine("]");
}
string fileName = args[0];
int bIsRenderToPDF = 0;
int bwPageCount = 0;
int colorPageCount = 0;
int copyCount = 0;
double nPageWidth = 0;
double nPageHeight = 0;
string strPaperSizeName = new string(' ', 300);
FileInfoCOM.FileInfoClass objFileInfoCom = new FileInfoCOM.FileInfoClassClass();
objFileInfoCom.com_ReadInfoSetCode("XXXXXXXXXXXXXXXXXX");
objFileInfoCom.com_ReadInfoFromPCLFile(fileName, bIsRenderToPDF, ref bwPageCount, ref colorPageCount, ref copyCount, ref nPageWidth, ref nPageHeight, ref strPaperSizeName);
Console.WriteLine(String.Format("File: {0}", fileName));
Console.WriteLine(String.Format("Render To PDF: {0}", bIsRenderToPDF));
Console.WriteLine(String.Format("BW Pages: {0}", bwPageCount));
Console.WriteLine(String.Format("Color Pages: {0}", colorPageCount));
Console.WriteLine(String.Format("Width: {0}", nPageWidth));
Console.WriteLine(String.Format("Height: {0}", nPageHeight));
Console.WriteLine(String.Format("Paper name: {0}", strPaperSizeName));
}
}
}
-----------------------------------
If you encounter any problem, please feel free to let us know, we will assist you asap.