star-micronics / StarPRNT-SDK-iOS-Swift

StarPRNT SDK for iOS including libraries for supporting application development for Star printers.
https://www.star-m.jp/products/s_print/sdk/starprnt_sdk/manual/ios_swift/en/index.html
Other
41 stars 7 forks source link

Print cash receipt from PDF #15

Closed stan96D closed 6 months ago

stan96D commented 2 years ago

Hi again,

We followed your advice of getting a LAN printer and it worked, so thanks! But now we have the problem that our cash receipts are way too (approx 16) long. It kinda makes sense since the PDF has a lot of whitespace at the bottom but we would like to cut this if possible. We apply the PDF as an image through the appendBitmap function and this works, besides the receipts being too long. Even if we crop the cash receipts's PDF to delete the whitespace at the bottom it's still the same. I hope you can help us!

In the attachment we have an example how it's currently printed. We disrupted the printing process to waste more paper so it's not at its full length but I think the idea is clear.

Thanks in advance! IMG_4531

Tatsuki-Yamamoto2731 commented 1 year ago

@stan96D Sorry, I could not see the image you attached. I modified "createBitmapData" in StarPRNT SDK like below. Then, the whitespace was approximately 10mm. Is this whitespace acceptable to you? If so, could you try printing with the below code?

Here is a sample code ("SampleImage" is a pdf file):

static func createBitmapData(_ emulation: StarIoExtEmulation, width: Int) -> Data {
        let sampleImage:   UIImage = UIImage(named: "SampleImage")!

        let builder: ISCBBuilder = StarIoExt.createCommandBuilder(emulation)

        builder.beginDocument()

        builder.appendBitmap(sampleImage, diffusion: true, width: width, bothScale: true)

        builder.appendCutPaper(SCBCutPaperAction.partialCutWithFeed)

        builder.endDocument()

        return builder.commands.copy() as! Data
 }

Printing result: image