Thanks for the reply.
Here is a sample PDF
https://www.dropbox.com/s/hp8bxr7ehxqn8 ... e.pdf?dl=0I essentially need to either copy the 6 Vector icons which are located in OCG Layers to a new PDF, or delete all the Stroke/Vector Lines from the original file and save that.
When the artwork gets sent to a printer if the other lines are there i am not able to fill the Icons as a Vector since the outside box encloses them.
EDIT: I have discovered if using Adobe Acrobat DC if i manually move all the OCG items into the one OCG Container i get the desired results from my software. Is there a way with PDFSharp to merge these 6 OCG Groups into one?
EDIT2:
I have now found out how i can change the way the OCG Layers are referenced i believe...
When i set the Name key to PrintingLayer for each OCG element, when i import the file into the software it recognises it as a sigle layer which is great!
Code:
var properties = resource?.Elements.GetDictionary("/Properties");
if (!(properties is null))
{
foreach (var property in properties)
{
if (property.Value is PdfReference propertyValue &&
propertyValue.Value is PdfDictionary propertyDict)
{
// Write the key and name of the layer
var layerName = propertyDict.Elements.GetString("/Name");
propertyDict.Elements.SetName("/Name", "PrintingLayer");
Debug.WriteLine($"Key: {property.Key} Value: {layerName}");
vectors.Add(property.Key);
}
}
}
So now the only issue is, since sometimes these 6 icons in the sample PDF can sometimes be replaced by Text Objects, the text objects are not read in onto an OCG Layer.
Is there a way for me to Parse all Text Objects, find their Position and Value and then just use the XGraphics options in PDFSharp to just re-draw the text to a layer?
Thanks!