Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Hiding areas on PDF

Hi, we have a PDF which is rendered with logos and stuff which we want to use when emailing the file to the customer. however when we print the PDF we want to hide the logo because its preprinted. Is there a way to mark a component as not printable so that PDF can recognize and not print it?

Comments

  • Hi Vassilis,

    Once the report has been exported to PDF, how the PDF is printed to a printer is out of ReportBuilder's hands. This would be a feature of the PDF viewer you are using to display the PDF file.

    One option would be to keep the image when exporting to PDF, but remove them when printing to the printer from ReportBuilder. You can use the OnPrinterDeviceCreate event to determine whether the report is printed to the printer or not. Then you can find and set the visibility of certain report objects using a report object loop.

    http://rbwiki.digital-metaphors.com/delphi-code/layouts-delphi-code/report-object-loop/
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • I'm not an expert at this sort of thing at all, but I have a printSlip routine that sort of matches your requirement Vassilis. You should DEFINITELY prefer Nico's methodology, but maybe this can be useful in a small way to get you thinking. ON the form where I have the print button, there are rollers for NUMBER of copies and checkboxes for whether to print slips at all and whether to print Proforma documents for international orders. The CHECKBOX for whether normal paperwork should be printed was a recent ad hoc add-on to make suppressing printed (and wasted) paperwork a quicker thing to do rather than change the roller box 2 down to zero. I left both ways in. AND our slips represent either bulk or packaged (bin) shipments. When I designed the master form, I did a lot of colouring for the layers, knowing that each one would print in black and white. Helped make sense out of the it by thinking in Blue, Maroon, Dark Green and Black layers. So, here goes ... I removed a lot of codesite code

    procedure TFrmShipping.PrintSlip(ProformaNeeded:boolean);
    var
    Gross : extended;
    XtraTxt, fn: string;
    begin
    try
    // set the information to go on the slips here ...
    XtraTxt := eXtra.text;
    fn := OT6Globals.ReprintDir + getS(dMain.mTblShipping,'SlipNum');
    Gross := dMain.mTblJobs.fieldbyname('PriceSell').asFloat
    * dMain.mTblShipping.fieldbyname('Shipped').asInteger;
    // set labels on the various VERSIONS of the objects here
    proforma2bin.caption := gmDollarString(Gross);
    proforma2bulk.caption := proforma2bin.caption;
    proforma8bin.caption := gmDollarString(Gross);
    proforma8bulk.caption := proforma8bin.caption;
    LblCommentFooterBin.caption := 'Comment: ' + cmt;
    LblCommentFooterBulk.caption := LblCommentFooterBin.caption;
    // IF there is extra text instructions, fill the label here
    if XtraTxt <> ''
    then LblXtraBin.caption := 'Extra Instructions: ' + XtraTxt
    else LblXtraBin.caption := '';
    LblXtraBulk.caption := lblXtraBin.caption;
    // Change Company logos based on a field in the Customer for this part
    if GetS(dMain.mTblCustomers,'HdrCode') = 'MST'
    then begin
    LogoBin.visible := false;
    LblMSTBin.visible := true;
    end;
    // Make the BULK logos visible here (a word stamp)
    LogoBulk.visible := LogoBin.visible;
    LblMSTBulk.visible := LblMSTBin.visible;
    // based on a menu option that is checked or not, print to screen or just skip (the default status)
    with pipSlipBulk do begin
    ShowPrintDialog := FrmMainOT6.mOShowBinDlg.checked;
    if ShowPrintDialog
    then begin
    DeviceType := 'Screen';
    ModalPreview := true;
    end;
    end;
    // Replicate the setup for the bins based on those values for Bulk
    pipSlipBin.ShowPrintDialog := pipSlipBulk.ShowPrintDialog;
    pipSlipBin.DeviceType := pipSlipBulk.DeviceType;
    pipSlipBin.ModalPreview := pipSlipBulk.ModalPreview;
    // Turn on the Word Stamp for whether it's an Office Copy or not (We are TRYING to go paperless NOW)
    LblCopyBulk.caption := 'OFFICE COPY';
    LblCopyBin.caption := LblCopyBulk.caption;
    Application.ProcessMessages;
    // AND Here's the toggle that lets us get out of printing anything if we can
    // Now, print either bulk or bin based on what page of the notebook is showing the details
    if eSlipCopies.Value > 0 // 3/9/2018 4:17:59 AM ED: Cuts out paper waste
    then case nbk.pageIndex of
    0: pipSlipBulk.print;
    1: pipSlipBin.print;
    end;
    // toggle the word stamp to Customer Copy and repeat what we just did.
    LblCopyBulk.caption := 'CUSTOMER COPY';
    LblCopyBin.caption := LblCopyBulk.caption;
    Application.ProcessMessages;
    if eSlipCopies.Value > 1 // 3/9/2018 4:17:59 AM ED: Cuts out paper waste
    then case nbk.pageIndex of
    0: begin
    pipSlipBulk.print;
    // We export all of these slips to PDF
    ExportToAdobe(false,fn + '.PDF',pipSlipBulk);
    end;
    1: begin
    pipSlipBin.print;
    ExportToAdobe(false,fn + '.PDF',pipSlipBin);
    end;
    end;
    // IF we ship cross border, we need a Proforma slip.
    if ProformaNeeded
    then begin
    // Toggle the word stamp now to PROFORMA INVOICE
    // repeat printing accordingly to the options from the menu
    lblSlipKindbulk.caption := 'PROFORMA INVOICE';
    lblSlipKindbin.caption := lblSlipKindbulk.caption;
    ToggleProformaView(true);
    Application.ProcessMessages;
    case nbk.pageIndex of
    0: begin
    // 3/9/2018 4:10:20 AM ED: Make it optional based on checkbox
    if ePrintProforma.Checked
    then pipSlipBulk.print;
    // export it to Adobe anyways
    ExportToAdobe(false,fn + 'PF.PDF',pipSlipBulk);
    end;
    1: begin
    // 3/9/2018 4:10:20 AM ED: Make it optional based on checkbox
    if ePrintProforma.Checked
    then pipSlipBin.print;
    // export it to Adobe anyways
    ExportToAdobe(false,fn + 'PF.PDF',pipSlipBin);
    end;
    end;
    end;
    // Time to turn most things to their invisible default status
    // Print a Dock Slip for our shippers because that is mandatory and we can't make it paperless
    if FrmMainOT6.mODockSlip.checked
    then begin
    // print a dock slip
    LogoAddBulk.visible := false;
    LogoPhoneBulk.visible := false;
    LogoFaxBulk.visible := false;
    LogoEMailBulk.visible := false;
    lblSlipKindBulk.visible := false;
    LogoDockBulk.visible := true;
    LogoAddBin.visible := false;
    LogoPhoneBin.visible := false;
    LogoFaxBin.visible := false;
    LogoEMailBin.visible := false;
    lblSlipKindBin.visible := false;
    LogoDockBin.visible := true;
    case nbk.pageIndex of
    0: pipSlipBulk.print;
    1: pipSlipBin.print;
    end;
    end;
    finally Codesite.exitMethod('PrintSlip');
    end;
    end;

    Hope this helps in some small way. I need to CONTRIBUTE AT LEAST A LITTLE, in appreciation for what Nico, Nard and others do for me. GM
Sign In or Register to comment.