View source | View content page | Page history | Printable version   

Projects:PDF Printing Improvements/Technical Specs

Contents

Overview

This article explains how the printing process API was changed to retrieve the same PDF each time a printing request is made.

Technical design

Document Type window

Add a flag to configure if the same version of the document should be printed. This will force the attachment of the PDF when the document is printed the first time. The next time the document is printed this attachment will be used.

Attachment table

Add a flag to determine if the attachment is the printing that should be reused by the process. If the attachment is the last printing it can not be deleted.

Add a process to discard printed documents, this process should not delete attachments but uncheck the last printing flag. This process should discard printings when the document changes status. This way, the next time the document is printed a new PDF is generated.

Change API

Create a new public API to print a document given its ID and Type. Add the ability to get the correct tab to attach the document when it is not printed from the application.

The new API can be found in src/org/openbravo/erpCommon/utility/reporting/printing/PrintController.java file. The ability ti get the correct tab is private but used when the tabId parameter is not passed.

  /**
   * This method generates the list of reports to be printed or get them if already stored, it also
   * attaches the file it that is the case. deleteTemporaryReports should always be called after
   * this method.
   * 
   * @param documentType
   *          the type of document to print
   * @param documentIds
   *          an array of document ids of the same type
   * @param archive
   *          should the document be archived? It will be archive anyway if the document type is set
   *          to store printing
   * @param textForAttachment
   *          a description of the attachment
   * @param tabId
   *          the id where we are attaching the document, it will be generated if null
   * @return a collection of reports that can be printed
   * @throws IOException
   */
  public Collection<Report> generateAndAttachReports(DocumentType documentType,
      String[] documentIds, boolean archive, String textForAttachment, String tabId)
      throws IOException { ... }


  /**
   * This method print a list of reports to a given output.
   * 
   * @param os
   *          the output stream where reports will be printed to
   * @param reports
   *          a collection of reports to be printed
   * @return a pdf copy representing the printing
   */
  public PdfCopy printReports(OutputStream os, Collection<Report> reports) { ... }


    /**
   * This method prints a list of reports to a given output and automatically prints them.
   * 
   * @param os
   *          the output stream where reports will be printed to
   * @param reports
   *          a collection of reports to be printed
   */
  public void directPrintReports(OutputStream os, Collection<Report> reports) { ... }


  /**
   * This method deletes all the temporary reports generated for printing, it keeps attached ones.
   * This should always be called after generateAndAttachReports
   * 
   * @param reports
   *          a collection or generated reports
   */
  public void deleteTemporaryReports(Collection<Report> reports) { ... }

Retrieved from "http://wiki.openbravo.com/wiki/Projects:PDF_Printing_Improvements/Technical_Specs"

This page has been accessed 920 times. This page was last modified on 6 April 2017, at 18:10. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.