How to I added a path/rectangle to an existing PDF?

38 views
Skip to first unread message

Support

unread,
Nov 13, 2013, 5:14:14 PM11/13/13
to pdfne...@googlegroups.com
Q:
 
I am simply trying to put a rectangle on a PDF, say white to block out certain areas but I cant get the code to run, can you point me to some sample code please.  

 

Just open a pdf, add a rectangle save and close.
 
-----
A:
 

I suggest taking a look at ElementBuilder sample (included as part of the SDK):

  http://www.pdftron.com/pdfnet/samplecode.html#ElementBuilder

 

For example:

 

using (PDFDoc = new PDFDoc("my.pdf")) {

  ElementBuilder eb = new ElementBuilder();

  ElementWriter writer = new ElementWriter();

  Page page = doc.GetPage(1);

 

  writer.Begin(page);

  Element element = eb.CreateRect(new Rect(100, 100, 300, 400));

  element.SetPathFill(true);

  writer.WriteElement(element);

  writer.End();  // save changes to the current page

  ...

}

 

Btw. it you want to redact PDF, the proper tool to use is 'pdftron.PDF.Redacrtor' (http://www.pdftron.com/pdfnet/samplecode.html#PDFRedact). Adding stuff on top of page does not really remove sensitive info.

Reply all
Reply to author
Forward
0 new messages