Hi Team,
I want To create an Bookmark.with position set Destionation of the Bookmark.
Thanks and regards,
vijayanathan444
Hi Team,
I want To create an Bookmark.with position set Destionation of the Bookmark.
Thanks and regards,
vijayanathan444
You can do an explicit destination using a height or horizontal position. But not both at the same time.
Here is the code sample;
private void Logic()
{
Document doc = new Document($"{PartialPath}_input.pdf");
OutlineItemCollection pdfOutlines = new OutlineItemCollection(doc.Outlines);
pdfOutlines.Title = "Test Bookmark Color";
pdfOutlines.Bold = true;
pdfOutlines.Color = System.Drawing.Color.IndianRed;
pdfOutlines.Italic = true;
pdfOutlines.Action = new GoToAction(doc.Pages[2], ExplicitDestinationType.FitH, 300);
doc.Outlines.Add(pdfOutlines);
doc.Save($"{PartialPath}_output.pdf");
}
Here are the input and output files:
ExplicitDestinationBookmark_input.pdf (202.1 KB)
ExplicitDestinationBookmark_output.pdf (188.4 KB)
HI Team,
It is Working But i have One Issue . Using This Approach File Size To be increased .
How TO handle It.
Thanks and Regard,
Vijayanathan444
Hi Team,
Each and Every Bookmark creating using the above code .It generates 2mb for every single bookmark added in PDF.
Thanks and Regards,
Vijayanathan444
I am not able to replicate the size increase. In fact, if you see my example, the output is smaller.
Can you provide a one page example where this increase happened? I am not asking for a long document because I will have to check for any other changes you might have done.
But if it is a simple will it will be easier to check if it is like you have described.
Hi Team I am Trying these Line Of Code
OutlineItemCollection pdfOutlines = new OutlineItemCollection(pdfDocumentsource.Outlines);
pdfOutlines.Title = controliddata;
pdfOutlines.Bold = true;
pdfOutlines.Color = System.Drawing.Color.IndianRed;
pdfOutlines.Italic = true;
double[] values= new double[1000 * 1000];
values[0] = pdfDocumentsource.Form.Fields[i].Rect.LLX;
values[1] = pdfDocumentsource.Form.Fields[i].Rect.URY;
pdfOutlines.Action = new GoToAction(pagedata, ExplicitDestinationType.XYZ, values);
Thanks ,
Vijayanathan444
Hi Team I Will share my sample code and sample file in this below
ExplicitDestinationBookmark_input.pdf (181.9 KB)
ExplicitDestinationBookmark_output.pdf (7.9 MB)
var path = directoryName.Replace("file:\\", "");
path = path.Replace("bin\\Debug", "Data\\ExplicitDestinationBookmark_input.pdf");
var outpath = directoryName.Replace("file:\\", "");
outpath = outpath.Replace("bin\\Debug", "Data\\ExplicitDestinationBookmark_output.pdf");
Document doc = new Document(path);
int totalcount = doc.Form.Fields.Count();
for (int i = 0; i < totalcount; i++)
{
Aspose.Pdf.Page pagedata = doc.Pages[doc.Form.Fields[i].PageIndex];
var controliddata = doc.Form.Fields[i].FullName;
OutlineItemCollection pdfOutlines = new OutlineItemCollection(doc.Outlines);
pdfOutlines.Title = controliddata;
pdfOutlines.Bold = true;
pdfOutlines.Italic = true;
double[] values = new double[1000 * 1000];
values[0] = doc.Form.Fields[i].Rect.LLX;
values[1] = doc.Form.Fields[i].Rect.URY;
pdfOutlines.Action = new GoToAction(pagedata, ExplicitDestinationType.XYZ, values);
doc.Outlines.Add(pdfOutlines);
}
doc.Save(outpath);
Thanks,
Vijayanathan444
This line is the culprit(double[] values = new double[1000 * 1000];).
GoToAction are javascript instruction, and you are giving one million lines to write(per page), even with no asignation value , is still a line.
I replaced your line by this and problem solved.
double[] values = new double[2];
Hi Team,
Now issue Resolved Thanks for Your Greatful Support
Thanks,
Vijayanathan444