HTML Converter

Is there a way to programmatically remove all blank pages from a PDF file?

Question: Nowadays it is more practical to purchase an eBook than the dead-tree version. But the PDF frequently contain the blank pages used by the print edition. I typically see between 10-30 blank pages (or pages with text "This page intentionally left blank.") per eBook. Is it possible to programmatically remove these blank pages?

    So the hard part is identifying the blank pages. pdftotext would work for the most part, except where the page has only images and no text.Also, even after removing many pages and seeing the resulting file size is smaller, after shrinking both the original file and the new version (using various methods found on the internets), the original file is usually smaller by several hundred KB or more. So it appears the method I'm using to remove the blank pages doesn't create an optimal PDF. I've also tried various programs and see the same results in this respect.

Answer: I don't know of an open source free solution that can detect and remove blank pages. However, VeryDOC commercial HTML Converter can automatically remove blank pages -- both vector and scanned. For scanned, it can remove scan artifacts such as black edges, hole punches and noise prior to determining if page is blank. And during removing all blank pages from PDF, this software will not damage or compress input PDF file. You can have a free trial of HTML Converter and then decide whether pay for it or not. In the following part, I will show you how to use this software.

  There are two versions of this software: GUI version and command line version. But for removing all blank pages from PDF, we’d better use the command line version. When downloading finishes, there will be a zip file. Please extract it to some folder then you can find the executable file and call it from MS Dos Windows. This software also allows you to use it together with ASP, VB, VC, Delphi, BCB, Java, .NET and COM+ etc., so you can use it programmatically.

Here is the usage for your reference: htmltools [options] <EMF-WMF-HTML-URL-RTF-file> [<PDF-PS-Image-file>]

When you need to remove all blank pages from PDF, please refer to the following command line template:
htmltools.exe -noempty -mergepdf C:\test.pdf C:\out.pdf
Please call this software in MS Dos Windows and then input parameters -noempty –mergepdf  then the full path of input PDF and output PDF file. By this method, we can remove all blank pages from PDF. Now let us check related parameters:
-noempty           : Delete empty pages from PDF file
-mergepdf <string> : Merge two PDF files into one PDF file

If you need to know more parameters and functions of this software, please visit its homepage. Now we can use those command line templates to remove all blank pages from PDF. During the using, if you have any question, please contact us as soon as possible.

PostScript to Text Converter

Problem when call PS to Text SDK from C# source code

I have a simple text file that I printed which then converts the files into Postscript. I did this from Texpad, Wordpad, and from IExplorer. While converting the Postscript from Textpad, and Wordpad -11 is returned from ps2txtsdk and the file is not converted. When I print the same file from Internet Explorer it ps2txtsd returns 11, the the file is converted.

I have included these files for your review. Please let me know why this happens. We are trying to deploy an app for our clients where they can print anything to our (pseudo) printer and it will print to a postscript file, then we convert it to text using your SDK and transfer it to an FTP site. We have no control over what application they are going to use and we need to address a fix for this.

Customer

-----------------------------------------------------------

Return 11 is indicate conversion successful, please refer to the return codes at below,
//~~~~~~~~~~~~~~~~~~~
//0: - Success not found any problem.
//1: - Couldn't open PDF file, this PDF file maybe contains an open password or be damaged
//2: - Couldn't open output text file
//10: - Success with found some embed fonts.
//11: - Success with have only embed fonts in PDF file.
//12: - Fail with empty text file such as this PDF is picture scan or PDF have only picture.
//-1: - Fail with other causes (can not convert to text file) such as found exception, time out, not enough memory.
//-11: - Fail with something is wrong in input parameters,
//~~~~~~~~~~~~~~~~~~~

VeryDOC

-----------------------------------------------------------

That doesn't help at all. We printed a small text file using different applications. We used textoad, wordpad and iexplorer. We used only 2 arguments to the app and that was the ps file to convert and the text file to put the results in. I have already sent a zip file with the original text as well as the ps files created by the above applications I mentioned. The ps files produced by all of the applications look good. Your converter does not convert 2 of these files.

Giving me return values doesn't help. I already know I get -11 on two conversions and 11 on one. I don't understand how your reply is going to help.

I need your app to covert all the ps files especially when the original file is purely text.

Customer

-----------------------------------------------------------

Our PS2TXT SDK does convert your PS files to text files without any problem, please look at converted text files in attachment, these text files are all converted by PS2TXT SDK product. Can you get these text files in your system?

VeryDOC

-----------------------------------------------------------

Thanks. It did work.

For your information:

The difference between my application now and before is simply the declaration in C# for the external

The declaration was
[DllImport("ps2txtsdk.dll", EntryPoint = "VeryPDF_PSToText")]
private static extern Int32 VeryPDF_PSToText(string strcmd);

At this point some files would convert but others would not.

The declaration now is
[DllImport("ps2txtsdk.dll")]
internal static extern int VeryPDF_PSToText(string strcmd);

It converts all the test files. I don’t understand why the small declaration difference would cause this. I will do more extensive testing, and if I have a problem I will get back to you.

It would be helpful if you had some documentation that was sent out along with the SDK.

[DllImport("ps2txtsdk.dll")]
internal static extern int VeryPDF_PSToText(string strcmd);

static void Main(string[] args)
{
string sourcePath = Environment.CurrentDirectory;
string[] files = System.IO.Directory.GetFiles(sourcePath, "*.ps", SearchOption.TopDirectoryOnly);

// convert all files from *.ps to *.txt.
foreach (string ps in files)
{
var psFileName = System.IO.Path.GetFileNameWithoutExtension(ps);
var txt = sourcePath + @"\" + psFileName + ".txt";
string strCmd = "ps2txt -$ XXXXXXXXXXXXXXX " + ps + " " + txt;
long nRet = VeryPDF_PSToText(strCmd);
Console.WriteLine("Conversion Result: " + nRet.ToString());
}
}

-----------------------------------------------------------

private static extern Int32 VeryPDF_PSToText(string strcmd);
internal static extern int VeryPDF_PSToText(string strcmd);

The difference is int32 and int two data types,
-----------------------
Int16 is a short integer,
Int32 is a normal integer, in general, int is equal to int32 on 32bit system, however, on 64bit system, int is 64bit length, int32 is still 32bit length,
Int 64 is a double,

Capacities as follows

Int 16 -- (-32768 to +32787)
Int 32 -- (-2,147,483684 to +2,147,483683)
Int 64 -- (-9223372036854775808 to +9223372036854775807)

decide which one you need to use depending on the circumstances
-----------------------

Please look at following web pages for more information,

http://blog.risingperfection.com/2011/04/c-difference-between-int-and-int32.html
http://stackoverflow.com/questions/62503/c-int-or-int32-should-i-care

You can double check the length of int and int32 in your system carefully.

VeryDOC

DOC to Any Converter

How to call Doc to Any Converter SDK from ASP.NET source code?

Hi,

I am using trail version DOC2Any dll in my Asp.net Application. But I am getting problem in conversion some time .docx to PDF.And also when this type issue will be come that time Application will stuck even this service not stop after 24 hours. I am manually stop this service from task manger. Please suggest to me if this type issue will come how to resolve this issue.

After successfully completion of this I move for purchase option. Please give your response as soon as possible with all details. I am also copy that code whatever I am using.

Product Details: Trial Version
https://www.verydoc.com/doc-to-any.html
DOC to Any Converter SDK/COM Version
1 Server License USD$395

Code:
[DllImport(@"pdfshell.dll", CharSet = CharSet.Auto)]
static extern uint DocToAnyRunCmd([MarshalAs(UnmanagedType.LPStr)] string strCmdLine);
public void ConvertFile()
{
    string strCmd;
    strCmd = "-$ XXXXXXXXXXXXXXXXXXXX " + objCommonData.StrFileName + " " +     strOutFile + "";
    uint nRet = DocToAnyRunCmd(strCmd);

    if (nRet != 0)
    {
        // objCommonData.StatusPDFConverter = true;
    }
}

Customer

---------------------------------------------------------------

Yes, our DOC to Any Converter does convert DOCX files to PDF files. Please notice, you need install MS Office 2007 or MS Office 2010 in order to convert DOCX files to PDF files, what version of MS Office installed in your system?

You need also set MS Word DCOM run inside an interactive user account instead of default system user account, please look at following web pages for more information,
https://www.verydoc.com/blog/cannot-test-doc2any-on-net.html
https://www.verydoc.com/blog/how-to-call-doc2any-exe-from-asp-code.html
https://www.verydoc.com/doc-to-any-shell.html
https://www.verydoc.com/blog/run-doc2any-on-windows-2003-or-windows-2008-system.html
http://www.verypdf.com/wordpress/201201/how-to-call-doc2any-exe-or-htmltools-exe-from-a-service-20896.html
https://www.verydoc.com/blog/how-to-call-doc2any-from-php.html
http://www.verypdf.com/wordpress/201107/the-info-from-doc-converter-not-working-1016.html
http://www.verypdf.com/wordpress/201106/combine-word-doc-files-into-one-pdf-file-864.html
http://www.verypdf.com/wordpress/201107/rtf-to-pdf-1051.html

VeryDOC

PDF to Vector Converter

How to convert PDF to flash via programming C#?

For developing software with functions around flash, some time we need to use programming C#. And when you need to create flash from PDF together with programming C#, the following article will be helpful for you. VeryDOC PDF to Vector Converter can be used to convert PDF to flash by programming or scripting languages. Please check more information about this software on homepage, in the following part, let us check how to use this software.

Step 1. Download PDF to Vector Converter 

  • There are different licenses of this software, please choose the proper version according to your needs. And this is Windows application, it can not work under Mac, Linux system for now.
  • When downloading finishes, there will be an zip file. Please extract it to some folder then you can find the examples and executable file. You’d better download SDK version as there are more examples directly related programming C#.

Step 2. Convert PDF to Flash from programming C#.

  • When you use this software, please refer to the usage and examples.
  • Here are some programming C# code examples for your reference:

Sample code #1 (C# example),
Make use of the PROCESS class available in SYSTEM.DIOGNOSTICS namaspace, use the following piece of code to execute the pdf2vec.exe file,
~~~~~~~~~~~~~~~~~
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace ConsoleApplication1
{
    class Program
{
static void Main(string[] args)
{
Process proc = new Process();
proc.StartInfo.FileName = @"C:\\pdf2vec.exe";
string strArguments = "";
strArguments += "-swfburst";
strArguments += " D:\\temp\\sample.pdf D:\\temp\\out.swf";
Console.WriteLine(strArguments);
proc.StartInfo.Arguments = @strArguments;
proc.Start();
proc.WaitForExit();
}
}
}
~~~~~~~~~~~~~~~~~
Sample code #2 (C# example),
Please by following steps to call pdf2vec.exe inside a special user account,
1. Please download and install EXEShell COM Library (freeware) from following URL first,
https://www.verydoc.com/exeshell.html
https://www.verydoc.com/download/exeshell.zip
2. Please use following C# code to run the conversion inside a special user account,
~~~~~~~~~~~~~~~~~
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
    class Program
{
static void Main(string[] args)
{
System.Type otype = System.Type.GetTypeFromProgID("exeshell.shell");
Object o = System.Activator.CreateInstance(otype);
otype.InvokeMember("RunCommandLine", System.Reflection.BindingFlags.InvokeMethod, null, o,
new object[] { "UserName", "Password", @"C:\pdf2vec.exe ""C:\test.pdf"" ""C:\out.swf""" });
otype = null;
}
}
}
~~~~~~~~~~~~~~~~~
Remark:
You may encounter Error 1314 in some Windows systems when you switch between user accounts, this is caused by permission setting, please by following steps to solve this 1314 Error,
ERROR 1314:
~~~~~~~~~~~~~
1314 A required privilege is not held by the client. ERROR_PRIVILEGE_NOT_HELD
~~~~~~~~~~~~~
To resolve this issue:
1. Click Start, click Run, type "secpol.msc", and then press ENTER.
2. Double-click "Local Policies".
3. Double-click "User Rights Assignment".
4. Double-click "Replace a process level token".
5. Click "Add", and then double-click the "Everyone" group
6. Click "OK".
7. You may have to logout or even reboot to have this change take effect.
Please refer to following two screenshots to understand above steps,
https://www.verydoc.com/images/err1314-1.png
https://www.verydoc.com/images/err1314-2.png
Please look at following page for the details about ERROR 1314,
https://www.verydoc.com/exeshell.html

This software also allows you to call it from as Visual Basic, C/C++, Delphi, ASP, PHP.NET, etc. and converting PDF to flash is a part of functions of this software, it can give you more than you can image. During the using, if you have any question, please contact us as soon as possible.  

XPS to PDF and Image Converter

Convert XPS to PDF in WPF C# application

Question: I need to convert an XPS file I create with my application to a PDF file, what is the best way to do so? I prefer this to be done from inside C# using a managed assembly. Open source is preferred upon third party solutions.

Answer: An open source managed assembly might be hard to find, but you can look for a commercial product that might help. You can have a look at VeryDOC.com, where there is software named VeryDOC XPS to PDF Converter. By this software, you can convert large volumes of XPS files in real-time. XPS to PDF Converter is available via an easily integrated COM object (or DLL Library, or Command Line), enabling developers to access the converter via any programming or scripting languages, such as Visual Basic, C/C++, Delphi, ASP, PHP, C#, .NET, etc.  Please check more information of this software on homepage, in the following part, let us check how to use it.

Step 1. Download XPS to PDF Converter Command Line Developer License

  • By this developer version, you can integrate the corresponding SOFTWARE into your developed software and redistribute it with royalty-free. If the SOFTWARE contains source codes, you have the right to modify and reuse the codes under the Developer License.
  • When downloading finishes, there will be a zip folder. Please extract it to some folder then you can check elements in it.

Step 2. Convert XPS to PDF in C# application.

  • When you use this software, please refer to the usage and examples.
  • Here are one example of C#, please have a check.

Make use of the PROCESS class available in SYSTEM.DIOGNOSTICS namaspace, use the following piece of code to execute the xps2pdf.exe file,
~~~~~~~~~~~~~~~~~
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace ConsoleApplication1
{
    class Program
{
static void Main(string[] args)
{
Process proc = new Process();
proc.StartInfo.FileName = @"C:\\xps2pdf.exe";
string strArguments = "";
strArguments += " D:\\temp\\sample.xps D:\\temp\\out.pdf";
Console.WriteLine(strArguments);
proc.StartInfo.Arguments = @strArguments;
proc.Start();
proc.WaitForExit();
}
}
}
~~~~~~~~~~~~~~~~~
Sample code #2 (C# example),
Please by following steps to call xps2pdf.exe inside a special user account,
1. Please download and install EXEShell COM Library (freeware) from following URL first,
https://www.verydoc.com/exeshell.html
https://www.verydoc.com/download/exeshell.zip
2. Please use following C# code to run the conversion inside a special user account,
~~~~~~~~~~~~~~~~~
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
    class Program
{
static void Main(string[] args)
{
System.Type otype = System.Type.GetTypeFromProgID("exeshell.shell");
Object o = System.Activator.CreateInstance(otype);
otype.InvokeMember("RunCommandLine", System.Reflection.BindingFlags.InvokeMethod, null, o,
new object[] { "UserName", "Password", @"C:\xps2pdf.exe ""C:\test.xps"" ""C:\out.pdf""" });
otype = null;
}
}
}
~~~~~~~~~~~~~~~~~
Remark:
You may encounter Error 1314 in some Windows systems when you switch between user accounts, this is caused by permission setting, please by following steps to solve this 1314 Error,
ERROR 1314:
~~~~~~~~~~~~~
1314 A required privilege is not held by the client. ERROR_PRIVILEGE_NOT_HELD
~~~~~~~~~~~~~
To resolve this issue:
1. Click Start, click Run, type "secpol.msc", and then press ENTER.
2. Double-click "Local Policies".
3. Double-click "User Rights Assignment".
4. Double-click "Replace a process level token".
5. Click "Add", and then double-click the "Everyone" group
6. Click "OK".
7. You may have to logout or even reboot to have this change take effect.

If you need to check more examples, please visit homepage. During the using, if you have any question, please contact us as soon as possible.