PDFsharp & MigraDoc Foundation http://forum.pdfsharp.com/ |
|
PDF Size and Bookmarks http://forum.pdfsharp.com/viewtopic.php?f=2&t=3987 |
Page 1 of 1 |
Author: | chwe [ Wed Jun 19, 2019 8:15 am ] |
Post subject: | PDF Size and Bookmarks |
Hello, i've written a little program which opens an existing PDF, looks for three bookmarks i wish to remove an, removes it and saves the file. It works, but i have two problems. my file size was 3,5mb and after saving its about 8mb. it only removes 2 of 3 bookmarks. That was one of my debugging codes, it works but may you have to change some things Code: #region Member Variablen string path = @args[0]; //string path = @"C:\Users\chwe\Desktop\test.pdf"; PdfDocument pdfDocument = PdfReader.Open(path, PdfDocumentOpenMode.Modify); List<PdfOutline> unpleasantBookmarks = new List<PdfOutline>(); #endregion #region Debug 1 Console.WriteLine("Steht in der Quell-Datei:"); Console.WriteLine(pdfDocument.Outlines.Count); for (int i = 0; i < pdfDocument.Outlines.Count; i++) { Console.WriteLine(pdfDocument.Outlines[i].Title.ToString()); } #endregion #region Programm foreach (PdfOutline item in pdfDocument.Outlines) { if (item.Title.Contains("Seitenbaum")) { unpleasantBookmarks.Add(item); } } var outlines = pdfDocument.Outlines.ToList(); outlines.ForEach(x => pdfDocument.Outlines.Remove(x)); pdfDocument.Outlines.Clear(); pdfDocument.Outlines.Add(unpleasantBookmarks.First()); PdfDocument test = (PdfDocument)pdfDocument.Clone(); test.Outlines.Add(unpleasantBookmarks.First()); test.Save(path); #endregion #region Debug2 Console.WriteLine("Steht in der neuen Datei:"); Console.WriteLine(pdfDocument.Outlines.Count); for (int i = 0; i < pdfDocument.Outlines.Count; i++) { Console.WriteLine(pdfDocument.Outlines[i].Title.ToString()); } #endregion //pdfDocument.Save(path); Console.ReadKey(); } catch (Exception e) { Console.WriteLine(e.Message); Console.ReadKey(); } } could you please help me? thanks |
Author: | Thomas Hoevel [ Wed Jun 19, 2019 8:53 am ] |
Post subject: | Re: PDF Size and Bookmarks |
Hi! chwe wrote: my file size was 3,5mb and after saving its about 8mb. Without seeing those two files I can only speculate what might cause the increase in size.Would you share them? |
Author: | chwe [ Wed Jun 19, 2019 9:18 am ] |
Post subject: | Re: PDF Size and Bookmarks |
Thomas Hoevel wrote: Hi! chwe wrote: my file size was 3,5mb and after saving its about 8mb. Without seeing those two files I can only speculate what might cause the increase in size.Would you share them? please look at your pm |
Author: | chwe [ Mon Jul 01, 2019 5:57 am ] |
Post subject: | Re: PDF Size and Bookmarks |
Hello Thomas, did you forget me? |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |