TB: write the modified pdf to the diskįile.WriteAllBytes(documentLocation, targetStream. TB: close the reader to be able to access the source pdf TB: same problem as above with stamper ? Using (PdfStamper stamper = new PdfStamper(targetReader, targetStream)) Using (MemoryStream targetStream = new MemoryStream((int)concatenatedTargetStream.Length)) Using (PdfReader targetReader = new PdfReader(concatenatedTargetStream)) TB: create a list with the page numbers to keepįor (int i = 1 i ERROR here: "Rebuild trailer not found. PdfConcatenate concatenator = new PdfConcatenate(concatenatedTargetStream) TB: use a concatenator to create a new pdf containing only the desired pages Using (MemoryStream concatenatedTargetStream = new MemoryStream((int)sourcePdfReader.FileLength)) Using (PdfReader sourcePdfReader = new PdfReader(documentLocation)) #TRACK CONCATENATOR CODE#Here my current code (see comments for problem related lines): public void RemovePagesInFile(string documentLocation, int pageIndexFrom, int pageCount) #TRACK CONCATENATOR HOW TO#So can anybody tell me/giva an example on how to achieve this (better) or am I on the completely wrong track? The problem is NOT adding or removing the pages but to keep the metadata in the same step. To speed things up I want to do the modifications in memory before storing the result to disk. To keep the metadata I use a PdfStamper afterwards. I use iTextSharp and found examples how to add or remove pages by using the PdfConcatenate class.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |