Firdaus Archive

Blog pribadi untuk curhat, share tentang script, software, kuliah, project IT dan seputar IT.

Untuk Cetak di Printer Draft Agar bisa Langsung Cetak ke Printer (Epson) atau RAW Print

 Link bisa dipakai disini 

http://download4.epson.biz/sec_pubs/pos/reference_en/escpos/index.html

Untuk Cetak di Printer Epson Dot Matrix dan Agar Bisa Autocut Menggunakan Bahasa Pemrograman Apapun

Bisa Memakai 2 Cara ini

printData += '<crlf><crlf><crlf><crlf><crlf><char29>V0';

printData += '\r\n\r\n\r\n\x1D\x56\x01';









Untuk Python Bisa Coba di Bawah ini : Original Source Code (https://github.com/python-escpos/python-escpos/issues/129)

This comment is not directly related to Issue #18:


I am describing a possible extension, which I intend to resubmit later as a new 

issue.


Here is an experiment, for people who have a combination thermal & slip 

printer. The paper type can be selected:


HW_PRINT_ROLL = '\x1B\x63\x30\x03' # 80mm roll, thermal

HW_PRINT_SLIP = '\x1B\x63\x30\x04' # Slip / Cheque, dot matrix


Common settings, like the type face and character geometry, can be set on the 

dot matrix slip printer, the same way as done for the thermal engine.


E.paper('slip')


E.set('left','A','B',1,2)


If anyone tests this, please be mindful of both the logical and physical length 

of your slip. My printer seems not to sense the end of a narrow slip. It is 

okay with an A4 sheet.


PAPER_SLIP_OUT  = '\x1B\x4B\xC0' # Eject slip or cheque


The method I use to eject is a slip-reverse command. It reverses the feed 

direction on a flat paper path TM-H5000II, and feeds a slip out forward on the 

TM-H6000.


E.cut('slip')


Always return to the roll paper type when finished.


E.paper('roll')



% hg diff


diff -r 849dabb63ce0 escpos/constants.py

--- a/escpos/constants.py   Thu May 30 08:56:33 2013 -0700

+++ b/escpos/constants.py   Sat Jan 18 15:14:30 2014 +1100

@@ -10,16 +10,21 @@

 HW_INIT   = '\x1b\x40'         # Clear data in buffer and reset modes

 HW_SELECT = '\x1b\x3d\x01'     # Printer select

 HW_RESET  = '\x1b\x3f\x0a\x00' # Reset printer hardware

+# Printer paper

+HW_PRINT_ROLL = '\x1B\x63\x30\x03' # 80mm roll, thermal

+HW_PRINT_SLIP = '\x1B\x63\x30\x04' # Slip / Cheque, dot matrix

 # Cash Drawer

 CD_KICK_2 = '\x1b\x70\x00'     # Sends a pulse to pin 2 [] 

 CD_KICK_5 = '\x1b\x70\x01'     # Sends a pulse to pin 5 [] 

 # Paper

 PAPER_FULL_CUT  = '\x1d\x56\x00' # Full cut paper

 PAPER_PART_CUT  = '\x1d\x56\x01' # Partial cut paper

+PAPER_SLIP_OUT  = '\x1B\x4B\xC0' # Eject slip or cheque

 # Text format   

 TXT_NORMAL      = '\x1b\x21\x00' # Normal text

 TXT_2HEIGHT     = '\x1b\x21\x10' # Double height text

 TXT_2WIDTH      = '\x1b\x21\x20' # Double width text

+TXT_4SQUARE     = '\x1b\x21\x30' # Quad area text

 TXT_UNDERL_OFF  = '\x1b\x2d\x00' # Underline font OFF

 TXT_UNDERL_ON   = '\x1b\x2d\x01' # Underline font 1-dot ON

 TXT_UNDERL2_ON  = '\x1b\x2d\x02' # Underline font 2-dot ON

diff -r 849dabb63ce0 escpos/escpos.py

--- a/escpos/escpos.py  Thu May 30 08:56:33 2013 -0700

+++ b/escpos/escpos.py  Sat Jan 18 15:14:30 2014 +1100

@@ -189,8 +189,8 @@

             self._raw(TXT_NORMAL)

             self._raw(TXT_2HEIGHT)

         elif height == 2 and width == 2:

-            self._raw(TXT_2WIDTH)

-            self._raw(TXT_2HEIGHT)

+            self._raw(TXT_NORMAL)

+            self._raw(TXT_4SQUARE)

         else: # DEFAULT SIZE: NORMAL

             self._raw(TXT_NORMAL)

         # Type

@@ -203,7 +203,6 @@

         elif type.upper() == "U2":

             self._raw(TXT_BOLD_OFF)

             self._raw(TXT_UNDERL2_ON)

-            self._raw(TXT_ITALIC_OFF)

         elif type.upper() == "BU":

             self._raw(TXT_BOLD_ON)

             self._raw(TXT_UNDERL_ON)

@@ -227,6 +226,15 @@

             self._raw(TXT_ALIGN_LT)



+    def paper(self, type='ROLL'):

+        if type.upper() == '':

+            self._raw(HW_PRINT_ROLL)

+        elif type.upper() == 'ROLL':

+            self._raw(HW_PRINT_ROLL)

+        elif type.upper() == 'SLIP':

+            self._raw(HW_PRINT_SLIP)

+

+

     def cut(self, mode=''):

         """ Cut paper """

         # Fix the size between last line and cut

@@ -234,6 +242,10 @@

         self._raw("\n\n\n\n\n\n")

         if mode.upper() == "PART":

             self._raw(PAPER_PART_CUT)

+        if mode.upper() == "FULL":

+            self._raw(PAPER_FULL_CUT)

+        if mode.upper() == "PART":

+            self._raw(PAPER_SLIP_OUT)

         else: # DEFAULT MODE: FULL CUT

             self._raw(PAPER_FULL_CUT) 

Redis

Redis (Remote Dictionary Server) is a fast database used for in-memory caching to reduce server load by reducing disk and/or network read and write operations.


Uses of Redis are:

Caching frequently accessed data to improve access time.

Session storage for web applications

Real-time analytics and leader boards.

Managing queues or task lists in background job systems.


How Redis Work?

Redis acts as a caching layer between the database and the client to speed up data access and reduce the load on the main database. When a client asks for data, the API Gateway forwards the request to Redis.

Working of Redis

If Redis has the data (cache hit), it returns it quickly through the API Gateway to the client. If the data is missing (cache miss), Redis retrieves it from the database, stores it in the cache for future requests, and then passes it back through the API Gateway to the client. This flow speeds up response times and reduces the database load.


Source : https://www.geeksforgeeks.org/system-design/introduction-to-redis-server/


Advanced IP Scanner : Scan Jaringan Lokal / Local Network Scanner Untuk Cek IP dan Komputer

FastReport get the current paper size from the printer and use it for the report

 

FastReport can be configured to get the current paper size from the printer and use it for the report. However, it requires some manual steps in your Delphi code to correctly read the printer's settings and then apply them to the FastReport report object.

Here's a breakdown of how it works and a Delphi script to accomplish this.

Understanding the Process

  1. FastReport's Default Behavior: By default, FastReport uses the TfrxReportPage.PaperSize property to determine the page dimensions. This is often set to a standard size like DMPAPER_A4 at design time.
  2. Getting Printer Information: The key is to use the Windows API and the Delphi Printers unit to access the TPrinter object. This object holds all the configuration for the currently selected printer, including its DM_PAPERSIZE, DM_PAPERWIDTH, and DM_PAPERLENGTH properties.
  3. Applying to FastReport: Once you have the custom dimensions, you can programmatically set the TfrxReportPage.PaperWidth and TfrxReportPage.PaperHeight properties. It's important to set the PaperSize property to DMPAPER_USER (which has a value of 256) to signal that you are using custom dimensions.

Delphi Script to Dynamically Set Paper Size

This script demonstrates a function that can be called before a report is prepared or printed. It gets the current printer's paper size and applies it to a FastReport page.

http://googleusercontent.com/immersive_entry_chip/0

 

unit frxUtils;

 

interface

 

uses

  Windows, Messages, SysUtils, Classes, frxClass, Printers, frxPrinters, frxCustomDB,

  frxDSys, frxDesign, frxGDIplus;

 

// This procedure gets the current printer's paper dimensions and applies them

// to the specified FastReport page.

procedure SetReportPaperSizeFromPrinter(aReport: TfrxReport);

 

implementation

 

procedure SetReportPaperSizeFromPrinter(aReport: TfrxReport);

var

  Device, Driver, Port: array[0..255] of Char;

  hDeviceMode: THandle;

  pDeviceMode: PDeviceMode;

  frxPage: TfrxReportPage;

  PaperWidth, PaperHeight: Integer;

begin

  // Ensure the printer is initialized and there is a report to work with

  if (aReport = nil) or (aReport.Pages[0] = nil) then

    Exit;

 

  // Get the current printer's device mode information

  Printer.GetPrinter(Device, Driver, Port, hDeviceMode);

  pDeviceMode := GlobalLock(hDeviceMode);

 

  try

    // Check if the DeviceMode is valid

    if (pDeviceMode <> nil) and (pDeviceMode.dmSize >= SizeOf(TDeviceMode)) then

    begin

      // Read the paper dimensions from the device mode.

      // dmPaperWidth and dmPaperLength are in 0.1mm units.

      PaperWidth := pDeviceMode.dmPaperWidth;

      PaperHeight := pDeviceMode.dmPaperLength;

 

      // Find the first report page

      frxPage := aReport.Pages[0] as TfrxReportPage;

 

      // Apply the custom paper size to the FastReport page

      // It's crucial to set PaperSize to DMPAPER_USER to enable custom dimensions

      frxPage.PaperSize := DMPAPER_USER;

     

      // FastReport's PaperWidth and PaperHeight properties are in millimeters.

      // So, we divide the DM values (in 0.1mm) by 10.

      frxPage.PaperWidth := PaperWidth / 10;

      frxPage.PaperHeight := PaperHeight / 10;

    end;

  finally

    // Unlock and free the handle

    if hDeviceMode <> 0 then

    begin

      GlobalUnlock(hDeviceMode);

      GlobalFree(hDeviceMode);

    end;

  end;

end;

 

end.

 

 

 

 

### How to Use the Script

 

1.  **Save the Unit:** Save the code above as `frxUtils.pas` and add it to your project.

2.  **Call the Procedure:** Before showing the report preview or printing, call the `SetReportPaperSizeFromPrinter` procedure. This ensures the report is sized correctly for the currently selected printer.

 

 

Here's an example of how you might call it from a button click event:

 

```delphi

procedure TForm1.Button1Click(Sender: TObject);

begin

  // Set the printer before preparing the report

  // This is an optional step if you want to use a specific printer instead of the default

  frxReport1.SelectPrinter;

 

  // Get the printer's custom size and apply it to the report page

  SetReportPaperSizeFromPrinter(frxReport1);

 

  // Prepare and show the report

  frxReport1.ShowPreparedReport;

end;

My Flutter Library and Tutorial

 


My Golang Library and Tutorial

 


Untuk Cetak di Printer Epson Dot Matrix dan Agar Ukurannya bisa 1/4 Letter atau 1/2 Letter Menggunakan Bahasa Pemrograman Apapun

Gunakan fungsi page break di fast-report atau gunakan Character khusus untuk mengirim command ke printer seperti #12 untuk page break


Code Snippet :  CommandString = 'Hello, this is a test page!' + #10#12;

Specifically, the #12 character constant is the control character for a Form Feed, which is the command that an Epson dot-matrix printer like the LX-310 understands as a page break. The #10 character is a Line Feed, which moves the print head to the next line.


Contoh Untuk Delphi memakai di bawah ini untuk Cetak Draft

procedure PrintMe(Content: TStringList);

var

sPrinter, sDriver, sPort, sTitle: array[0..255] of Char;

hPrinter, hDevMode: THandle;

DocInfo1: TDocInfo1;

W: DWORD;

S: String;

C: Char;

I: Integer;

begin

// page-break

C := #12;


// initialize the document structure

with DocInfo1 do begin

pDocName := StrPCopy(sTitle, 'Your Title Here');

pOutputFile := nil;

pDatatype := 'RAW';

end;


// get the current printer (sPrinter)

Printer.GetPrinter(sPrinter, sDriver, sPort, hDevMode);


// open the printer

OpenPrinter(sPrinter, hPrinter, nil);

try

try

// start document to spooler

StartDocPrinter(hPrinter, 1, @DocInfo1);

StartPagePrinter(hPrinter);


// send the 'Source' to the printer

for I := 0 to Source.Count - 1 do begin

S := Source.Strings;

if not WritePrinter(hPrinter, PChar(S), Length(S), W) then

Break;

end;


// send a page-break to the printer (optional)

if not WritePrinter(hPrinter, @C, 1, W) then

Break;


// end the page

EndPagePrinter(hPrinter);


// end the document

EndDocPrinter(hPrinter);

finally

// close the printer

ClosePrinter(hPrinter);

end;

except

// abort the job

AbortPrinter(hPrinter);

raise;

end;

end;


https://www.tek-tips.com/threads/printing-text-on-dotmatrix-printer.921897/

Setting Printer Epson Dot Matrix Agar Urutannya Sesuai Meskipun Dokumen Sangat Banyak

 Pilih opsi Start printing after last page is spooler. lalu save, seharusnya cetakan akan sesuai urutan


Berlaku untuk LX-300, LX-310, LQ-310, LQ-2180, LQ-2190 dan kawan kawannya

Best FTP and File Sharing Apps Windows - Total Commander


Total Commander

https://www.ghisler.com/download.htm

Download Driver IWARE ALL TYPE PRINTER SCANNER BARCODE DLL

Mematikan Windows 10/11 Dengan Registry Tanpa Tool

Copy Script dibawah ini lalu save as reg dan jalankan lalu akan pause sampai 2033, atau bisa di ganti sendiri ke tahun kapanpun 


Windows Registry Editor Version 5.00


[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsUpdate\UpdatePolicy\Settings]

"PausedFeatureStatus"=dword:00000000

"PausedQualityStatus"=dword:00000000


[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings]

"FlightSettingsMaxPauseDays"=dword:00000e42

"PauseFeatureUpdatesStartTime"="2023-11-06T14:03:37Z"

"PauseFeatureUpdatesEndTime"="2033-10-31T14:03:37Z"

"PauseQualityUpdatesStartTime"="2023-11-06T14:03:37Z"

"PauseQualityUpdatesEndTime"="2033-10-31T14:03:37Z"

"PauseUpdatesStartTime"="2023-11-06T14:03:37Z"

"PauseUpdatesExpiryTime"="2033-10-31T14:03:37Z"


windows 10
Windows 10

windows 11
Windows 11



Mematikan Windows Update 10/11 Kill Services (Hard Block) - Menunda Windows Update untuk Windows 10/11 (Soft Block)

Tool ini untuk menunda update sampai ke tanggal tertentu (soft block), atau bisa untuk hard block update  Jalankan saja tool dibawah ini

https://greatis.com/stopupdates10/


atau bisa pakai WUB jika memang benar2 mau kill tasknya (tapi biasanya ini ngefek ke aplikasi yang butuh update)

link Windows Update Blocker sordum.org/downloads/?st-windows-update-blocker