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

+3


source to share


5 answers


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.

+5


source


Yes, there is a way, although I don't know. We used it as a joke on a colleague, when printing the document, some completely different images appeared.



0


source


You can also use 2 read-only input fields and draw images in the field. Then, for one field, you set the visibility to VisibleNonPrintable and the other to HiddenButPrintable.

0


source


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. ”

0


source


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");
    }

      

0


source







All Articles