Have 2 bitmap resolutions in PDF format
Is there a way to put 2 instances of bitmap in PDF for one image? One for display when viewed on screen and one for printing?
The problem is in rendering the chart to a bitmap. If we are doing 300 dpi, then axes, borders, etc. Disappear. If we do 96 dpi then the print looks bad.
thanks - dave
source to share
You can use optional content for this. Delivery of use application dictionaries with the Print event forces the content to be printable. (Note that not all printing applications will honor this.)
See the PDF Reference Manual in Section 1.7 of Section 4.10 "Additional Content" starting on page 364.
source to share
You can add an Alternative Image Dictionary ( PDF Specification , section 8.9.5.4) that can specify an image to print. In the meantime, there is no need to worry about it. ”
source to share
I have implemented this (using iText). For anyone else who needs this code here is the code. And you can download the source on my blog .
static void Main(string[] args)
{
Document document = new Document(new Rectangle(0, 0, 8.5f * 72.0f, 11 * 72));
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(Path.GetFullPath(@"..\..\test_dotnet.pdf"), FileMode.OpenOrCreate, FileAccess.ReadWrite));
document.Open();
document.Add(new Paragraph("Visibility test"));
// not displayed on printer
PdfLayer layer = new PdfLayer("screen", writer);
layer.OnPanel = false;
layer.SetPrint("Print", false);
layer.View = true;
PdfContentByte cb = writer.DirectContent;
cb.BeginLayer(layer);
Image img = Image.GetInstance(Path.GetFullPath(@"..\..\building_01.png"));
img.SetAbsolutePosition(72, 72 * 7);
cb.AddImage(img);
cb.EndLayer();
// not displayed on screen
layer = new PdfLayer("print", writer);
layer.OnPanel = false;
layer.SetPrint("Print", true);
layer.View = false;
cb = writer.DirectContent;
cb.BeginLayer(layer);
img = Image.GetInstance(Path.GetFullPath(@"..\..\building_02.png"));
img.SetAbsolutePosition(72, 72 * 3);
cb.AddImage(img);
cb.EndLayer();
document.Close();
Console.Out.WriteLine("all done");
}
source to share