It sounds like your PDF might have multiple overlapping content streams and the new content is being added underneath another content stream, which is resulting in it not being visible.
There's a few different things you could try. As I don't have your document I can suggest the exact solution, but there's a few things to try.
1. Combine all content streams into one using the CombineContentStreams function
DPL.LoadFromFile("file.pdf"), "");
// Count pages int xPageCount = DPL.PageCount();
// Go through each page and combine content streams for (int i = 1; i <= xPageCount; i++) { DPL.SelectPage(i); DPL.CombineContentStreams(); }
// Save the updated file DPL.SaveToFile("new_file.pdf");
2. Reverse the order of the content streams in the document
The sample code below also demonstrates how to create content streams to demonstrate how to reverse them. The code below should produce two PDF files, one with hidden text and one with visible text.
// By default there is a blank document loaded into memory // which consists of one page with one content stream
// 0,0 coordinates start top left of page DPL.SetOrigin(1);
// Draw something on first content stream. DPL.SelectContentStream(1); DPL.DrawText(100, 100, "Hello World");
// Create a new content stream and // add a box with a fill in color // which will hide the text added in // the first content stream int posInIndex = DPL.NewContentStream(); DPL.SelectContentStream(posInIndex); DPL.SetFillColor(0.1, 0.6, 0.9); DPL.DrawBox(100, 80, 100, 100, 1);
// Save the PDF with hidden text to use as comparison later DPL.SaveToFile(@"C:\Temp\Content Streams\hidden_text.pdf");
// Now lets reverse the order of the content streams int xContentStreamCount = DPL.ContentStreamCount();
for (int x = 1; x <= xContentStreamCount; x++) { DPL.SelectContentStream(x); int xMoveContentStreamResult = DPL.MoveContentStream(xContentStreamCount, x); } // Save the new PDF with the content stream order reversed DPL.SaveToFile(@"C:\Temp\Content Streams\visible_text.pdf");
If this doesn't fix the problem for you then we'll need to look at your PDF. This isn't a common issue, the content streams in the reports must have been created in a slightly unusual way.
|