open pdf file in new tab in asp.net c# : Remove text watermark from pdf Library application class asp.net html wpf ajax pdflib-manual-5_023-part1350

2.9  PHP Binding 31
2.8.2 The »Hello world« Example in Perl
use pdflib_pl 5.0.2;
$p = PDF_new();
eval {
if (PDF_open_file($p, "hello.pdf") == -1) {
printf("Error: %s\n", PDF_get_errmsg($p));
exit;
}
PDF_set_info($p, "Creator", "hello.pl");
PDF_set_info($p, "Author", "Thomas Merz");
PDF_set_info($p, "Title", "Hello world (Perl)");
PDF_begin_page($p, 595, 842);
$font = PDF_load_font($p, "Helvetica-Bold", "host", "");
PDF_setfont($p, $font, 18.0);
PDF_set_text_pos($p, 50, 700);
PDF_show($p, "Hello world!");
PDF_continue_text($p, "(says Perl)");
PDF_end_page($p);
PDF_close($p);
};
if ($@) {
printf("hello: PDFlib Exception occurred:\n");
printf(" $@\n");
exit;
}
PDF_delete($p);
2.8.3 Error Handling in Perl
The Perl binding installs a special error handler which translates PDFlib errors to native 
Perl exceptions. The Perl exceptions can be dealt with by applying the appropriate lan-
guage constructs, i.e., by bracketing critical sections:
eval {
...some PDFlib instructions...
};
die "Exception caught" if $@;
2.9 PHP Binding
2.9.1 Installing the PDFlib PHP Edition
Detailed information about the various flavors and options for using PDFlib with PHP
1
including the question of whether or not to use a loadable PDFlib module for PHP, can 
be found in the readme.txt file which is part of the PDFlib distribution.
1. See http://www.php.net 
Remove text watermark from pdf - delete, remove text from PDF file in C#.net, ASP.NET, MVC, Ajax, WinForms, WPF
Allow C# developers to use mature APIs to delete and remove text content from PDF document
remove text from pdf acrobat; how to delete text in pdf file
Remove text watermark from pdf - VB.NET PDF delete text library: delete, remove text from PDF file in vb.net, ASP.NET, MVC, Ajax, WinForms, WPF
VB.NET Programming Guide to Delete Text from PDF File
how to delete text from a pdf document; how to erase text in pdf online
32
Chapter 2:  PDFlib Language Bindings
Note We do not recommend using the PDFlib COM edition with PHP. Use the native PDFlib binding 
for PHP instead.
You must configure PHP so that it knows about the external PDFlib library. You have 
two choices:
>Add one of the following lines in php.ini:
extension=libpdf_php.so
; for Unix
extension=libpdf_php.dylib
; for Mac OS X
extension=libpdf_php.dll
; for Windows
PHP will search the library in the directory specified in the extension_dir variable in 
php.ini on Unix, and in the standard system directories on Windows. You can test 
which version of the PHP PDFlib binding you have installed with the following one-
line PHP script:
<?phpinfo()?>
This will display a long info page about your current PHP configuration. On this page 
check the section titled pdf.  If this section contains PDFlib GmbH Version (and the 
PDFlib version number) you are using the supported new PDFlib wrapper. The un-
supported old wrapper will display PDFlib Version instead.
>Load PDFlib at runtime with one of the following lines at the start of your script:
dl("libpdf_php.so");
# for Unix
dl("libpdf_php.dll");
# for Windows
Modified error return for PDFlib functions in PHP. Since PHP uses the convention of re-
turning the value 0 (FALSE) when an error occurs within a function, all PDFlib functions 
have been adjusted to return 0 instead of -1 in case of an error. This difference is noted 
in the function descriptions in Section 7, »API Reference for PDFlib, PDI, and PPS«, page 
143. However, take care when reading the code fragment examples in Section 3, »PDFlib 
Programming«, page 41 since these use the usual PDFlib convention of returning -1 in 
case of an error.
File name handling in PHP. Unqualified file names (without any path component) and 
relative file names for PDF, image, font and other disk files are handled differently in 
Unix and Windows versions of PHP:
>PHP on Unix systems will find files without any path component in the directory 
where the script is located.
>PHP on Windows will find files without any path component only in the directory 
where the PHP DLL is located.
In order to provide platform-independent file name handling use of PDFlib’s Search-
Path facility (see Section 3.1.6, »Resource Configuration and File Searching«, page 47) is 
strongly recommended.
2.9.2 The »Hello world« Example in PHP
<?php
$p = PDF_new();
/*  open new PDF file; insert a file name to create the PDF on disk */
if (PDF_open_file($p, "") == 0) {
die("Error: " . PDF_get_errmsg($p));
C# PDF Page Delete Library: remove PDF pages in C#.net, ASP.NET
console application. Able to remove a single page from PDF document. Ability to remove a range of pages from PDF file. Free trial package
remove text from pdf; how to delete text from a pdf
C# PDF Password Library: add, remove, edit PDF file password in C#
String outputFilePath = Program.RootPath + "\\" Remove.pdf"; // Remove password in the input file and output to a new file. int
how to erase in pdf text; how to edit and delete text in pdf file online
2.10  Python Binding 33
}
PDF_set_info($p, "Creator", "hello.php");
PDF_set_info($p, "Author", "Rainer Schaaf");
PDF_set_info($p, "Title", "Hello world (PHP)");
PDF_begin_page($p, 595, 842); /* start a new page     */
# Change "host" encoding to "winansi" or whatever you need!
$font = PDF_load_font($p, "Helvetica-Bold", "host", "");
PDF_setfont($p, $font, 24.0);
PDF_set_text_pos($p, 50, 700);
PDF_show($p, "Hello world!");
PDF_continue_text($p, "(says PHP)");
PDF_end_page($p);
/* close page*/
PDF_close($p);
/* close PDF document*/
$buf = PDF_get_buffer($p);
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=hello.pdf");
print $buf;
PDF_delete($p);
/* delete the PDFlib object */
?>
2.9.3 Error Handling in PHP
When a PDFlib exception occurs, a PHP exception is thrown. Unfortunately, PHP does 
not yet support structured exception handling: there is no way to catch exceptions and 
act appropriately. Do not disable PHP exceptions when using PDFlib, or you will run 
into serious trouble.
PDFlib warnings (nonfatal errors) are mapped to PHP warnings, which can be dis-
abled in php.ini. Alternatively, warnings can be disabled at runtime with a PDFlib func-
tion like in any other language binding:
PDF_set_parameter($p, "warning", "false");
2.10 Python Binding
2.10.1 Installing the PDFlib Python Edition
The Python
1
extension mechanism works by loading shared libraries at runtime. For the 
PDFlib binding to work, the Python interpreter must have access to the PDFlib Python 
wrapper:
Unix. The library pdflib_py.so (on Mac OS X: pdflib_py.dylib) will be searched in the direc-
tories listed in the PYTHONPATH environment variable.
1. See http://www.python.org 
C# PDF bookmark Library: add, remove, update PDF bookmarks in C#.
Ability to remove and delete bookmark and outline entry.GetLocation()); Console.WriteLine("Text: " + entry.GetText NET Sample Code: Update PDF Document Outline
how to delete text from pdf document; how to delete text from pdf reader
C# PDF metadata Library: add, remove, update PDF metadata in C#.
Add metadata to PDF document in C# .NET framework program. Remove and delete metadata from PDF file. Also a PDF metadata extraction control.
delete text from pdf online; delete text pdf acrobat
34
Chapter 2:  PDFlib Language Bindings
Windows. The library pdflib_py.dll will be searched in the directories listed in the 
PYTHONPATH environment variable.
2.10.2 The »Hello world« Example in Python
from sys import *
from pdflib_py import *
p = PDF_new()
if PDF_open_file(p, "hello.pdf") == -1:
print "Error: " + PDF_get_errmsg(p) + "\n"
exit(2);
PDF_set_info(p, "Author", "Thomas Merz")
PDF_set_info(p, "Creator", "hello.py")
PDF_set_info(p, "Title", "Hello world (Python)")
PDF_begin_page(p, 595, 842)
font = PDF_load_font(p, "Helvetica-Bold", "host", "")
PDF_setfont(p, font, 18.0)
PDF_set_text_pos(p, 50, 700)
PDF_show(p, "Hello world!")
PDF_continue_text(p, "(says Python)")
PDF_end_page(p)
PDF_close(p)
PDF_delete(p);
2.10.3 Error Handling in Python
The Python binding installs a special error handler which translates PDFlib errors to na-
tive Python exceptions. The Python exceptions can be dealt with by the usual try/catch 
technique:
try:
...some PDFlib instructions...
except:
print 'Exception caught!'
2.11 RPG Binding
PDFlib provides a  /copy module that defines all prototypes and some useful constants 
needed to compile ILE-RPG programs with embedded PDFlib functions.
Since all functions provided by PDFlib are implemented in the C language, you have 
to add x'00' at the end of each string value passed to a PDFlib function. All strings re-
turned from PDFlib will have this terminating x'00' as well.
2.11.1 Compiling and Binding RPG Programs for PDFlib
Using PDFlib functions from RPG requires the compiled PDFlib service program. To in-
clude the PDFlib definitions at compile time you have to specify the name in the D 
specs of your ILE-RPG program:
C# PDF url edit Library: insert, remove PDF links in C#.net, ASP.
Able to insert and delete PDF links. Able to embed link to specific PDF pages. Easy to put link into specified position of PDF text, image and PDF table.
how to erase text in pdf file; pdf editor online delete text
C# PDF File Compress Library: Compress reduce PDF size in C#.net
NET framework. Remove bookmarks, annotations, watermark, page labels and article threads from PDF while compressing. C# class demo
delete text from pdf preview; how to delete text in pdf acrobat
2.11  RPG Binding 35
d/copy QRPGLESRC,PDFLIB
If the PDFlib source file library is not on top of your library list you have to specify the li-
brary as well:
d/copy PDFsrclib/QRPGLESRC,PDFLIB
Before you start compiling your ILE-RPG program you have to create a binding directory 
that includes the PDFLIB service program shipped with PDFlib. The following example 
assumes that you want to create a binding directory called PDFLIB in the library PDFLIB:
CRTBNDDIR BNDDIR(PDFLIB/PDFLIB) TEXT('PDFlib Binding Directory')
After creating the binding directory you need to add the PDFLIB service program to your 
binding directory. The following example assumes that you want to add the service pro-
gram PDFLIB in the library PDFLIB to the binding directory created earlier.
ADDBNDDIRE BNDDIR(PDFLIB/PDFLIB) OBJ((PDFLIB/PDFLIB *SRVPGM))
Now you can compile your program using the CRTBNDRPG command (or option 14 in 
PDM):
CRTBNDRPG PGM(PDFLIB/HELLO) SRCFILE(PDFLIB/QRPGLESRC) SRCMBR(*PGM) DFTACTGRP(*NO)  
BNDDIR(PDFLIB/PDFLIB)
2.11.2 The »Hello world« Example in RPG
*****************************************************************************************
d/copy QRPGLESRC,PDFLIB
*****************************************************************************************
d p               S               *
d font            s             10i 0
*
d error           s             50
d errmsg_p        s               *
d errmsg          s            200    based(errmsg_p)
*
d filename        s            256
d fontname        s             50
d fontenc         s             50
d infokey         s             50
d infoval         s            200
d text            s            200
d n               s              1    inz(x'00')
*****************************************************************************************
                  clear                   error
*
   Init on PDFlib
                  eval      p=pdf_new
                  if        p=*null
                  eval      error='Couldn''t create PDFlib object '+
                                  '(out of memory)!'
                  exsr      exit
                  endif
*
   Open new pdf file
                  eval      filename='hello.pdf'+x'00'
C# PDF Convert to Word SDK: Convert PDF to Word library in C#.net
key. Quick to remove watermark and save PDF text, image, table, hyperlink and bookmark to Word without losing format. Powerful components
how to erase text in pdf; how to delete text from a pdf in acrobat
C# PDF Text Redact Library: select, redact text content from PDF
Text: Delete Text from PDF. Text: Replace Text in PDF. Image: Remove Image from PDF Page. Image: Copy, Paste Edit, Delete Metadata. Watermark: Add Watermark to PDF
erase pdf text; erase text from pdf
36
Chapter 2:  PDFlib Language Bindings
                  if        PDF_open_file(p:filename) = -1
                  exsr      geterrmsg
                  exsr      exit
                  endif
   Set info "Creator"
                  eval      infokey='Creator'+x'00'
                  eval      infoval='hello.rpg'+x'00'
                  callp     PDF_set_info(p:infokey:infoval)
   Set info "Author"
                  eval      infokey='Author'+x'00'
                  eval      infoval='Thomas Merz'+x'00'
                  callp     PDF_set_info(p:infokey:infoval)
   Set info "Title"
                  eval      infokey='Title'+x'00'
                  eval      infoval='Hello, world (RPG)!'+x'00'
                  callp     PDF_set_info(p:infokey:infoval)
   Start a new page
                  callp     PDF_begin_page(p:a4_width:a4_height)
*
                  eval      fontname='Helvetica-Bold'+x'00'
   Change "host" encoding to "ebcdic" or whatever you need!
                  eval      fontenc='host'+x'00'
                  eval      font=PDF_load_font(p:fontname:0:fontenc:n)
*
                  callp     PDF_setfont(p:font:24)
                  callp     PDF_set_text_pos(p:50:700)
*
                  eval      text='Hello world!'+x'00'
                  callp     PDF_show(p:text)
                  eval      text='(says ILE RPG)'+x'00'
                  callp     PDF_continue_text(p:text)
   Close page
                  callp     PDF_end_page(p)
   Close PDF document
                  callp     PDF_close(p)
   Delete the PDF object
                  callp     PDF_delete(p)
*
                  exsr      exit
*****************************************************************************************
    geterrmsg     begsr
                  eval      errmsg_p=PDF_get_errmsg(p)
                  if        errmsg_p<>*NULL
                  eval      error=%subst(errmsg:1:%scan(x'00':errmsg)-1)
                  endif
                  endsr
*****************************************************************************************
    exit          begsr
                  if        error<>*blanks
                  eval      error='Error: '+error
    error         dsply
                  endif
                  seton                                        lr
                  return
                  endsr
You can compile this program as follows:
C# PDF Text Highlight Library: add, delete, update PDF text
etc. Able to remove highlighted text in PDF document in C#.NET. Support to change PDF highlight color in Visual C# .NET class. Able
how to delete text from pdf; delete text in pdf file online
2.11  RPG Binding 37
CRTBNDDIR BNDDIR(PDFLIB/PDFLIB) TEXT('PDFlib Binding Directory')
ADDBNDDIRE BNDDIR(PDFLIB/PDFLIB) OBJ((PDFLIB/PDFLIB *SRVPGM))
CRTBNDRPG PGM(PDFLIB/HELLO) SRCFILE(PDFLIB/QRPGLESRC) SRCMBR(*PGM) DFTACTGRP(*NO) +
BNDDIR(PDFLIB/PDFLIB)
2.11.3 Error Handling in RPG
PDFlib clients written in ILE-RPG can install an error handler in PDFlib which will be ac-
tivated when an exception occurs. Since ILE-RPG translates all procedure names to up-
percase, the name of the error handler procedure should be specified in uppercase. The 
following skeleton demonstrates this technique:
*****************************************************************************************
d/copy QRPGLESRC,PDFLIB
*****************************************************************************************
d p               S               *
d font            s             10i 0
*
d error           s             50
*
d errhdl          s               *   procptr
*
 Prototype for exception handling procedure
*
d errhandler      PR
 p                              *   value
 type                         10i 0 value
 shortmsg                   2048
*****************************************************************************************
                  clear                   error
*
       Set the procedure pointer to the ERRHANDLER procedure.
*
                  eval      errhdl=%paddr('ERRHANDLER')
*
                  eval      p=pdf_new2(errhdl:*null:*null:*null:*null)
...PDFlib instructions...
                  callp     PDF_delete(p)
*
                  exsr      exit
*****************************************************************************************
    exit          begsr
                  if        error<>*blanks
    error         dsply
                  endif
                  seton                                        lr
                  return
                  endsr
*****************************************************************************************
 If any of the PDFlib functions will cause an exception, first the error handler
 will be called and after that we will get a regular RPG exception.
    *pssr         begsr
                  exsr      exit
                  endsr
*****************************************************************************************
 Exception Handler Procedure
38
Chapter 2:  PDFlib Language Bindings
 This procedure will be linked to PDFlib by passing the procedure pointer to
 PDF_new2. This procedure will be called when a PDFlib exception occurs.
*
*****************************************************************************************
p errhandler      B
d errhandler      PI
 p                              *   value
 type                         10i 0 value
 c_message                  2048
*
 length         s             10i 0
*
   Chop off the trailing x'00' (we are called by a C program)
   and set the error (global) string
                  clear                   error
    x'00'         scan      c_message     length                   50
                  sub       1             length
                  if        *in50 and length>0
                  if        length>%size(error)
                  eval      error=c_message
                  else
                  eval      error=%subst(c_message:1:length)
                  endif
                  endif
*
   Always call PDF_delete to clean up PDFlib
                  callp     PDF_delete(p)
*
                  return
*
p errhandler      E
2.12 Tcl Binding
2.12.1 Installing the PDFlib Tcl Edition
The Tcl 
1
extension mechanism works by loading shared libraries at runtime. For the 
PDFlib binding to work, the Tcl shell must have access to the PDFlib Tcl wrapper shared 
library and the package index file pkgIndex.tcl. You can use the following idiom in your 
script to make the library available from a certain directory (this may be useful if you 
want to deploy PDFlib on a machine where you don’t have root privilege for installing 
PDFlib):
lappend auto_path /path/to/pdflib
Unix. The library pdflib_tcl.so (on Mac OS X: pdflib_tcl.dylib) must be placed in one of 
the default locations for shared libraries, or in an appropriately configured directory. 
Usually both pkgIndex.tcl and pdflib_tcl.so will be placed in the directory
/usr/lib/tcl8.3/pdflib
Windows. The files pkgIndex.tcl and pdflib_tcl.dll  will be searched for in the directories
1. See http://dev.scriptics.com 
2.12  Tcl Binding 39
C:\Program Files\Tcl\lib\pdflib
C:\Program Files\Tcl\lib\tcl8.3\pdflib
2.12.2 The »Hello world« Example in Tcl
package require pdflib 5.0.2
set p [PDF_new]
if {[PDF_open_file $p "hello.pdf"] == -1} {
puts stderr "Error:  [PDF_get_errmsg $p]"
exit
}
PDF_set_info $p "Creator" "hello.tcl"
PDF_set_info $p "Author" "Thomas Merz"
PDF_set_info $p "Title" "Hello world (Tcl)"
PDF_begin_page $p 595 842
set font [PDF_load_font $p "Helvetica-Bold" "host" "" ]
PDF_setfont $p $font 18.0
PDF_set_text_pos $p 50 700
PDF_show $p "Hello world!"
PDF_continue_text $p "(says Tcl)"
PDF_end_page $p
PDF_close $p
PDF_delete $p
2.12.3 Error Handling in Tcl
The Tcl binding installs a special error handler which translates PDFlib errors to native 
Tcl exceptions. The Tcl exceptions can be dealt with by the usual try/catch technique:
if [ catch { ...some PDFlib instructions... } result ] {
puts stderr "Exception caught!"
puts stderr $result
}
40
Chapter 2:  PDFlib Language Bindings
Documents you may be interested
Documents you may be interested