Menu

Is there a component to read PDF file for DPF?

Chris
2014-06-12
2014-06-13
  • Chris

    Chris - 2014-06-12

    is there a component that i can use to read PDF file for iOS?

    please advise

    thanks
    chris

     
  • Diego

    Diego - 2014-06-12

    Check the PDF demos...

     

    Last edit: Diego 2014-06-12
  • Gordon

    Gordon - 2014-06-12

    Funny you should ask.. I just finished my PDF portion.. Heres what I did..
    Since there really isnt a report writer for IOS.. I send the Invoice number to my Server, it generates my PDF.. then I download it and display.. Then I can print on an airprint server.. Works perfect. Takes about 3 seconds..

    I did have trouble taking snapshops of views, and making PDF's.. I couldnt get my report to look right, so I let the server do the work in this case..
    Not sure what Id do if I didnt have internet..

     
    • Chris

      Chris - 2014-06-13

      Hi Gordon
      I am also thinking about this way too. However, i don't like to have a windows as the client to generate the PDF. I am thinking of using linux but which part of linux can i use to work with Delphi or Lazarus?
      Currently i am using fast report to generate reports on windows xp but i thinking of shifting it to linux.
      What would be your advise

      thanks
      chris

       
  • Diego

    Diego - 2014-06-13

    For my App I also considered to use an external server for PDF printing, because sometimes I needed more than one page and the current DPF implementation of PDF print didn´t allow this. For me was a MUST not requiring an internet connection, so I created a new PDF Export function:

    In the UIVIew I want to print, I put a UITableView with fixed RowHeight. In my particular case, I wanted 4 rows/PDF page (I put charts in there).

    So what I do, is to capture this view, then I scroll the TableView to the next 4 rows and so...

    function TfResultados.CreatePDFfromViewCustom2( aView: UIView; FileName: string; Tabla: TDPFUiTableView): Boolean;
    var
      pdfData   : NSMutableData;
      pdfContext: CGContextRef;
      i,paginas:  Integer;
      AuxBounds:  NSRect;
    begin
      AuxBounds:=aView.bounds;
      result := false;
    
      uiFondoResultados.Align:=TAlignLayout.alNone;
      //Fixed iPad sizes
      uiFondoResultados.Width:=768;
      uiFondoResultados.Height:=955+64;
      FondoTitulo.Width:=uiFondoResultados.Width;
    
      //if not an iPad, I change the size of the uiview before printing
      if (NOT fMenu.vEsiPAD) then AjustarVistaParaImpresion(true);
    
      FondoTitulo.Visible:=true;
    
      if frac(Tabla.Sections.Count/4)>0 then
        begin
          paginas:=trunc(Tabla.Sections.Count/4)+1;
        end else paginas:=round(Tabla.Sections.Count/4);
      // Creates a mutable data object for updating with binary data, like a byte array
      pdfData := TNSMutableData.Create;
      // Points the pdf converter to the mutable data object and to the UIView to be converted
    
      UIGraphicsBeginPDFContextToData( ( pdfData as ILocalObject ).GetObjectID, uiFondoResultados.GetUIView.bounds, nil );
    
      for i := 0 to paginas-1 do
        begin
          Tabla.ScrollToRow(i*4,0,spTop,false);
          UIGraphicsBeginPDFPage( );
          pdfContext := UIGraphicsGetCurrentContext( );
          // draws rect to the view and thus this is captured by UIGraphicsBeginPDFContextToData
          if i=0 then
            begin
              uiFondoResultados.GetUIView.layer.renderInContext(pdfContext);
              FondoTitulo.Visible:=false;
            end
            else aView.layer.renderInContext( pdfContext );
        end;
    
      // remove PDF rendering context
      UIGraphicsEndPDFContext( );
      RemoveFile( FileName );
      if pdfData.length > 0 then
        result := pdfData.writeToFile( NSStr( FileName ), false );
      pdfData.release;
    
      uiFondoResultados.Align:=TAlignLayout.alClient;
      if (NOT fMenu.vEsiPAD) then AjustarVistaParaImpresion(False);
    
    //I restore the original Bounds of the UIVIew  
    aView.setBounds(AuxBounds);
    
      Tabla.ScrollToRow(0,0,spTop,false);
    
    end;
    
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.