Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to resize a PDF after drawing it #1688

Open
shinxxxxwon opened this issue Jun 26, 2024 · 0 comments
Open

How to resize a PDF after drawing it #1688

shinxxxxwon opened this issue Jun 26, 2024 · 0 comments
Labels
needs triage support Asking for help writing an application

Comments

@shinxxxxwon
Copy link

I changed the value of .a4 to match the coordinate system for drawing sheet music on PDF.

static const PdfPageFormat a4 = PdfPageFormat(2480, 3508);

Below is a simple test code.

scorePdf.addPage(
          pdfWidget.Page(
              pageFormat: PdfPageFormat.a4, ///2480 * 3508
              build: (pdfWidget.Context pContext){
                return pdfWidget.Stack(
                  children: [

                    ///test code
                    for(int i=0; i<5; i++)
                        pdfWidget.Positioned(
                          top: (2900 + (100 * i)).toDouble(),
                          left: 200,
                          child: pdfWidget.Text(
                              "AKBO TEST CODE",
                              style: const pdfWidget.TextStyle(
                                  color: PdfColor.fromInt(0xFFFFFFFF)
                              )
                          ),
                        ),

Now create a pdf with that data.

Uint8List uintData = await scorePdf.save();
await drawScore.makePDF(uintData);

 makePDF(Uint8List doc) async {
    final dir = await getTemporaryDirectory();
    String dirPath = dir!.path + '/score.pdf';
    File pdf = File('$dirPath');
    await pdf.writeAsBytes(doc);
    print('make PDF done');
  }

If you proceed with the above process, a PDF will be created, but the size of the PDF will be 2048 * 3508. Is there a way to readjust this size? However, the sheet music in the pdf must not be truncated.

@shinxxxxwon shinxxxxwon added needs triage support Asking for help writing an application labels Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage support Asking for help writing an application
Projects
None yet
Development

No branches or pull requests

1 participant