title: How can lines, curves, and vector graphic properties be edited in an existing PDF?
body: <p>I have a large collection of PDFs with vector graphics (mostly lines and curves) that need to be batch edited in some way to modify their basic properties like corner types and end types. This could also apply for editing thicknesses and colors.</p>
  
  <p>I am already using iTextSharp to edit these PDFs to insert an image into the background of every file, but I don't have much documentation on curves and lines and I cannot find a way to edit the lines themselves. I'm open to other libraries as well, but I haven't found one that clearly addresses how to edit existing curves and lines, only draw new ones.</p>
  
  <pre><code>using iTextSharp.text;
  using iTextSharp.text.pdf;
  
  // open the reader
  PdfReader reader = new PdfReader(refPath);
  Rectangle size = reader.GetPageSizeWithRotation(1);
  Document document = new Document(size);
  
  // open the writer
  FileStream fs = new FileStream(path, FileMode.Create, FileAccess.Write);
  PdfWriter writer = PdfWriter.GetInstance(document, fs);
  document.Open();
  
  // the pdf content
  PdfContentByte cb = writer.DirectContent;
  
  //get an image to be inserted.
  var screenshot = System.Drawing.Image.FromFile("somefile.png");
  
  //Create iTextSharp image
  Image bg = Image.GetInstance(screenshot, System.Drawing.Imaging.ImageFormat.Png);
  bg.SetDpi(dpi, dpi);
  bg.ScaleToFit(size);
  bg.SetAbsolutePosition(0, 0);
  bg.Alignment = Image.UNDERLYING;
  
  cb.AddImage(bg);
  
  /**
  Get and edit linework properties in here somewhere???
  **/
  
  // create the new page and add it to the pdf
  PdfImportedPage page = writer.GetImportedPage(reader, 1);
  cb.AddTemplate(page, 0, 0);
  
  // close the streams
  document.Close();
  fs.Close();
  writer.Close();
  reader.Close();
  </code></pre>
  
  <p>Ideally the output of all of the lines would look something like this:</p>
  
  <p><img src="https://i.imgur.com/3IOhGDK.png" alt=""></p>
  
  <p>Any ideas are appreciated!</p>